Bug 1305826: P2. Ensure the buffer size is of the right size. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sat, 01 Oct 2016 18:56:21 +1000
changeset 419872 f4d27bc7e19995d330ed453cf5115880bec2d802
parent 419871 37de5be8219f7686966afa5dbaa59c96e018560d
child 419873 0df267cd57c51d3b438fe11fb774b9d9c634220f
push id31032
push userbmo:jyavenard@mozilla.com
push dateSat, 01 Oct 2016 09:38:22 +0000
reviewersgerald
bugs1305826
milestone52.0a1
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
dom/media/AudioCompactor.h
--- 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,