Bug 1305826: P2. Ensure the buffer size is of the right size. r?gerald
The AudioSink uses the size of the buffer to determine the number of frames present. We must ensure that the size of the buffer matches the mFrames member.
MozReview-Commit-ID: 3oblyOCnGEB
--- a/dom/media/AudioCompactor.h
+++ b/dom/media/AudioCompactor.h
@@ -56,16 +56,17 @@ public:
if (!buffer) {
return false;
}
// Copy audio data to buffer using caller-provided functor.
uint32_t framesCopied = aCopyFunc(buffer.get(), samples);
NS_ASSERTION(framesCopied <= aFrames, "functor copied too many frames");
+ buffer.SetLength(size_t(framesCopied) * aChannels);
CheckedInt64 duration = FramesToUsecs(framesCopied, aSampleRate);
if (!duration.isValid()) {
return false;
}
mQueue.Push(new AudioData(aOffset,
aTime,