Bug 1305826: P3. Only process the number of frames, do not rely on allocated size. r?gerald
This is only for safeguarding, in case an audio buffer was over allocated. There should be none. But better be safe than sorry
MozReview-Commit-ID: JszA8CqycTr
--- a/dom/media/mediasink/DecodedAudioDataSink.cpp
+++ b/dom/media/mediasink/DecodedAudioDataSink.cpp
@@ -462,18 +462,23 @@ DecodedAudioDataSink::NotifyAudioNeeded(
PushProcessedAudio(silence);
}
}
mLastEndTime = data->GetEndTime();
mFramesParsed += data->mFrames;
if (mConverter->InputConfig() != mConverter->OutputConfig()) {
+ // We must ensure that the size in the buffer contains exactly the number
+ // of frames, in case one of the audio producer over allocated the buffer.
+ AlignedAudioBuffer buffer(Move(data->mAudioData));
+ buffer.SetLength(size_t(data->mFrames) * data->mChannels);
+
AlignedAudioBuffer convertedData =
- mConverter->Process(AudioSampleBuffer(Move(data->mAudioData))).Forget();
+ mConverter->Process(AudioSampleBuffer(Move(buffer))).Forget();
data = CreateAudioFromBuffer(Move(convertedData), data);
}
if (PushProcessedAudio(data)) {
mLastProcessedPacket = Some(data);
}
}
if (AudioQueue().IsFinished()) {