b=924286 handle non-unit mVolume in BiquadFilterNode r=ehsan
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 09 Oct 2013 15:33:02 +1300
changeset 150142 d53c325059431883b454c739bcf53903ac34c621
parent 150141 020593d16a93de6e7e87b1f041cf0d0b920d7628
child 150143 a4599a83b87159d408f94c13913f509e96fccee5
push id25423
push usercbook@mozilla.com
push dateWed, 09 Oct 2013 08:10:49 +0000
treeherdermozilla-central@2a8a173a0ae1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs924286
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=924286 handle non-unit mVolume in BiquadFilterNode r=ehsan
content/media/webaudio/BiquadFilterNode.cpp
--- a/content/media/webaudio/BiquadFilterNode.cpp
+++ b/content/media/webaudio/BiquadFilterNode.cpp
@@ -20,23 +20,24 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED_4(Biq
                                      mFrequency, mDetune, mQ, mGain)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BiquadFilterNode)
 NS_INTERFACE_MAP_END_INHERITING(AudioNode)
 
 NS_IMPL_ADDREF_INHERITED(BiquadFilterNode, AudioNode)
 NS_IMPL_RELEASE_INHERITED(BiquadFilterNode, AudioNode)
 
-void SetParamsOnBiquad(WebCore::Biquad& aBiquad,
-                       float aSampleRate,
-                       BiquadFilterType aType,
-                       double aFrequency,
-                       double aQ,
-                       double aGain,
-                       double aDetune)
+static void
+SetParamsOnBiquad(WebCore::Biquad& aBiquad,
+                  float aSampleRate,
+                  BiquadFilterType aType,
+                  double aFrequency,
+                  double aQ,
+                  double aGain,
+                  double aDetune)
 {
   const double nyquist = aSampleRate * 0.5;
   double normalizedFrequency = aFrequency / nyquist;
 
   if (aDetune) {
     normalizedFrequency *= std::pow(2.0, aDetune / 1200);
   }
 
@@ -153,20 +154,26 @@ public:
 
     TrackTicks pos = aStream->GetCurrentPosition();
 
     double freq = mFrequency.GetValueAtTime(pos);
     double q = mQ.GetValueAtTime(pos);
     double gain = mGain.GetValueAtTime(pos);
     double detune = mDetune.GetValueAtTime(pos);
 
+    float inputBuffer[WEBAUDIO_BLOCK_SIZE];
     for (uint32_t i = 0; i < numberOfChannels; ++i) {
+      auto input = static_cast<const float*>(aInput.mChannelData[i]);
+      if (aInput.mVolume != 1.0) {
+        AudioBlockCopyChannelWithScale(input, aInput.mVolume, inputBuffer);
+        input = inputBuffer;
+      }
       SetParamsOnBiquad(mBiquads[i], aStream->SampleRate(), mType, freq, q, gain, detune);
 
-      mBiquads[i].process(static_cast<const float*>(aInput.mChannelData[i]),
+      mBiquads[i].process(input,
                           static_cast<float*>(const_cast<void*>(aOutput->mChannelData[i])),
                           aInput.GetDuration());
     }
   }
 
 private:
   AudioNodeStream* mSource;
   AudioNodeStream* mDestination;