Bug 1265794: P1. Ensure we can always fit a complete audio frame in an audio buffer. r?rillian draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 20 Apr 2016 19:56:59 +1000
changeset 354214 0a9252cb89cddae623464b69c8e7ec583dd3c159
parent 354132 34f5a7144be34c3f48ebfeb4cbe3bd38419c0c7c
child 518934 8eba4986a32b0a9d36dcc993861dd6a45dfa029e
push id16001
push userbmo:jyavenard@mozilla.com
push dateWed, 20 Apr 2016 11:04:45 +0000
reviewersrillian
bugs1265794
milestone48.0a1
Bug 1265794: P1. Ensure we can always fit a complete audio frame in an audio buffer. r?rillian MozReview-Commit-ID: 7oF2Yp1ZQIG
dom/media/AudioCompactor.h
--- a/dom/media/AudioCompactor.h
+++ b/dom/media/AudioCompactor.h
@@ -44,17 +44,17 @@ public:
             uint32_t aFrames, uint32_t aChannels, CopyFunc aCopyFunc)
   {
     // If we are losing more than a reasonable amount to padding, try to chunk
     // the data.
     size_t maxSlop = AudioDataSize(aFrames, aChannels) / MAX_SLOP_DIVISOR;
 
     while (aFrames > 0) {
       uint32_t samples = GetChunkSamples(aFrames, aChannels, maxSlop);
-      if (aFrames * aChannels > mSamplesPadding) {
+      if (samples / aChannels > mSamplesPadding / aChannels + 1) {
         samples -= mSamplesPadding;
       }
       AlignedAudioBuffer buffer(samples);
       if (!buffer) {
         return false;
       }
 
       // Copy audio data to buffer using caller-provided functor.