mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 03:19:06 +00:00
Bug 673154 - Use nsAutoArrayPtr for SoundDataValue allocations to simplify ownership. r=cpearce
This commit is contained in:
parent
2f39e6408b
commit
e446815189
@ -369,7 +369,7 @@ nsresult nsOggReader::DecodeVorbis(ogg_packet* aPacket) {
|
||||
ogg_int64_t endSample = aPacket->granulepos;
|
||||
while ((samples = vorbis_synthesis_pcmout(&mVorbisState->mDsp, &pcm)) > 0) {
|
||||
mVorbisState->ValidateVorbisPacketSamples(aPacket, samples);
|
||||
SoundDataValue* buffer = new SoundDataValue[samples * channels];
|
||||
nsAutoArrayPtr<SoundDataValue> buffer(new SoundDataValue[samples * channels]);
|
||||
for (PRUint32 j = 0; j < channels; ++j) {
|
||||
VorbisPCMValue* channel = pcm[j];
|
||||
for (PRUint32 i = 0; i < PRUint32(samples); ++i) {
|
||||
@ -379,13 +379,12 @@ nsresult nsOggReader::DecodeVorbis(ogg_packet* aPacket) {
|
||||
|
||||
PRInt64 duration = mVorbisState->Time((PRInt64)samples);
|
||||
PRInt64 startTime = mVorbisState->Time(endSample - samples);
|
||||
SoundData* s = new SoundData(mPageOffset,
|
||||
startTime,
|
||||
duration,
|
||||
samples,
|
||||
buffer,
|
||||
channels);
|
||||
mAudioQueue.Push(s);
|
||||
mAudioQueue.Push(new SoundData(mPageOffset,
|
||||
startTime,
|
||||
duration,
|
||||
samples,
|
||||
buffer.forget(),
|
||||
channels));
|
||||
endSample -= samples;
|
||||
if (vorbis_synthesis_read(&mVorbisState->mDsp, samples) != 0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -484,7 +484,7 @@ PRBool nsWebMReader::DecodeAudioPacket(nestegg_packet* aPacket, PRInt64 aOffset)
|
||||
VorbisPCMValue** pcm = 0;
|
||||
PRInt32 samples = 0;
|
||||
while ((samples = vorbis_synthesis_pcmout(&mVorbisDsp, &pcm)) > 0) {
|
||||
SoundDataValue* buffer = new SoundDataValue[samples * mChannels];
|
||||
nsAutoArrayPtr<SoundDataValue> buffer(new SoundDataValue[samples * mChannels]);
|
||||
for (PRUint32 j = 0; j < mChannels; ++j) {
|
||||
VorbisPCMValue* channel = pcm[j];
|
||||
for (PRUint32 i = 0; i < PRUint32(samples); ++i) {
|
||||
@ -505,13 +505,12 @@ PRBool nsWebMReader::DecodeAudioPacket(nestegg_packet* aPacket, PRInt64 aOffset)
|
||||
|
||||
PRInt64 time = tstamp_usecs + total_duration;
|
||||
total_samples += samples;
|
||||
SoundData* s = new SoundData(aOffset,
|
||||
time,
|
||||
duration,
|
||||
samples,
|
||||
buffer,
|
||||
mChannels);
|
||||
mAudioQueue.Push(s);
|
||||
mAudioQueue.Push(new SoundData(aOffset,
|
||||
time,
|
||||
duration,
|
||||
samples,
|
||||
buffer.forget(),
|
||||
mChannels));
|
||||
mAudioSamples += samples;
|
||||
if (vorbis_synthesis_read(&mVorbisDsp, samples) != 0) {
|
||||
return PR_FALSE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user