bug 1388656 re-initialize the Reverb only once when the ConvolverNode buffer changes draft
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 08 Aug 2017 16:01:57 +1200
changeset 643063 44541704ffa23ac2e7e1996a0c7309ea3225fe03
parent 643062 c5303d1b4788b0909752a69f1e83bafa82f3575d
child 643064 ca36766642d3b3063467f3eaf2201b119453a9ca
push id72973
push userktomlinson@mozilla.com
push dateWed, 09 Aug 2017 08:18:18 +0000
bugs1388656
milestone57.0a1
bug 1388656 re-initialize the Reverb only once when the ConvolverNode buffer changes MozReview-Commit-ID: IKMK5GYVRBB
dom/media/webaudio/ConvolverNode.cpp
--- a/dom/media/webaudio/ConvolverNode.cpp
+++ b/dom/media/webaudio/ConvolverNode.cpp
@@ -61,30 +61,27 @@ public:
       NS_ERROR("Bad ConvolverNodeEngine Int32Parameter");
     }
   }
   void SetDoubleParameter(uint32_t aIndex, double aParam) override
   {
     switch (aIndex) {
     case SAMPLE_RATE:
       mSampleRate = aParam;
-      AdjustReverb();
+      // The buffer is passed after the sample rate.
+      // mReverb will be set using this sample rate when the buffer is received.
       break;
     default:
       NS_ERROR("Bad ConvolverNodeEngine DoubleParameter");
     }
   }
   void SetBuffer(already_AddRefed<ThreadSharedFloatArrayBufferList> aBuffer) override
   {
     mBuffer = aBuffer;
-    AdjustReverb();
-  }
 
-  void AdjustReverb()
-  {
     // Note about empirical tuning (this is copied from Blink)
     // The maximum FFT size affects reverb performance and accuracy.
     // If the reverb is single-threaded and processes entirely in the real-time audio thread,
     // it's important not to make this too high.  In this case 8192 is a good value.
     // But, the Reverb object is multi-threaded, so we want this as high as possible without losing too much accuracy.
     // Very large FFTs will have worse phase errors. Given these constraints 32768 is a good compromise.
     const size_t MaxFFTSize = 32768;