b=890528 Record silence in the delay buffer when there is no input, to avoid echos r=ehsan a=webaudio
authorKarl Tomlinson <karlt+@karlt.net>
Mon, 02 Sep 2013 12:59:34 +1200
changeset 213357 cffe4c4ccdf207245768ef432885385d5de5174e
parent 213356 917e9180f309615424cb31c892500c274596821c
child 213358 3483bf5de40533dfbb299886dafba0ea4864a6c3
push id3
push usergszorc@mozilla.com
push dateWed, 29 Oct 2014 02:45:36 +0000
reviewersehsan, webaudio
bugs890528
milestone25.0a2
b=890528 Record silence in the delay buffer when there is no input, to avoid echos r=ehsan a=webaudio
content/media/webaudio/DelayProcessor.cpp
--- a/content/media/webaudio/DelayProcessor.cpp
+++ b/content/media/webaudio/DelayProcessor.cpp
@@ -33,19 +33,17 @@ DelayProcessor::Process(const double *aP
     const float* input = aInputChannels ? aInputChannels[channel] : nullptr;
     float* output = aOutputChannels[channel];
 
     for (int i = 0; i < aFramesToProcess; ++i) {
       currentDelayFrames = clamped(aPerFrameDelays[i],
                                    0.0, static_cast<double>(mMaxDelayFrames));
 
       // Write the input sample to the correct location in our buffer
-      if (input) {
-        buffer[writeIndex] = input[i];
-      }
+      buffer[writeIndex] = input ? input[i] : 0.0f;
 
       // Now, determine the correct read position.  We adjust the read position to be
       // from currentDelayFrames frames in the past.  We also interpolate the two input
       // frames in case the read position does not match an integer index.
       double readPosition = writeIndex + bufferLength - currentDelayFrames;
       if (readPosition >= bufferLength) {
         readPosition -= bufferLength;
       }