b=923301 skip delay processing when nothing is buffered and input is null r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 25 Oct 2013 12:12:13 +1300
changeset 165845 ecf3f03f869cb3ed3027399492de01bba351245a
parent 165844 5c1ebb917518c2a387f1abc1f13639f26f4a257a
child 165846 4690758bd1e704ec5d5d898c6f37f2feec19191e
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs923301
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=923301 skip delay processing when nothing is buffered and input is null r=roc
content/media/webaudio/DelayNode.cpp
--- a/content/media/webaudio/DelayNode.cpp
+++ b/content/media/webaudio/DelayNode.cpp
@@ -79,35 +79,37 @@ public:
   {
     MOZ_ASSERT(mSource == aStream, "Invalid source stream");
     MOZ_ASSERT(aStream->SampleRate() == mDestination->SampleRate());
 
     const uint32_t numChannels = aInput.IsNull() ?
                                  mProcessor.BufferChannelCount() :
                                  aInput.mChannelData.Length();
 
-    bool playedBackAllLeftOvers = false;
     if (!aInput.IsNull()) {
       if (mLeftOverData <= 0) {
         nsRefPtr<PlayingRefChanged> refchanged =
           new PlayingRefChanged(aStream, PlayingRefChanged::ADDREF);
         NS_DispatchToMainThread(refchanged);
       }
       mLeftOverData = mProcessor.MaxDelayFrames();
     } else if (mLeftOverData > 0) {
       mLeftOverData -= WEBAUDIO_BLOCK_SIZE;
     } else {
       if (mLeftOverData != INT32_MIN) {
         mLeftOverData = INT32_MIN;
-        playedBackAllLeftOvers = true;
+        // Delete our buffered data now we no longer need it
+        mProcessor.Reset();
 
         nsRefPtr<PlayingRefChanged> refchanged =
           new PlayingRefChanged(aStream, PlayingRefChanged::RELEASE);
         NS_DispatchToMainThread(refchanged);
       }
+      *aOutput = aInput;
+      return;
     }
 
     AllocateAudioBlock(numChannels, aOutput);
 
     AudioChunk input = aInput;
     if (!aInput.IsNull() && aInput.mVolume != 1.0f) {
       // Pre-multiply the input's volume
       AllocateAudioBlock(numChannels, &input);
@@ -144,22 +146,16 @@ public:
         float delayAtTick = mDelay.GetValueAtTime(tick, counter) * sampleRate;
         float delayAtTickClamped = inCycle ? std::max(static_cast<float>(WEBAUDIO_BLOCK_SIZE), delayAtTick) :
                                              delayAtTick;
         computedDelay[counter] = delayAtTickClamped;
       }
       mProcessor.Process(computedDelay, inputChannels, outputChannels,
                          numChannels, WEBAUDIO_BLOCK_SIZE);
     }
-
-
-    if (playedBackAllLeftOvers) {
-      // Delete our buffered data once we no longer need it
-      mProcessor.Reset();
-    }
   }
 
   AudioNodeStream* mSource;
   AudioNodeStream* mDestination;
   AudioParamTimeline mDelay;
   DelayProcessor mProcessor;
   // How much data we have in our buffer which needs to be flushed out when our inputs
   // finish.