b=890528 delay buffer must be greater than max delay frames to avoid reading what has just been written r=ehsan a=webaudio
authorKarl Tomlinson <karlt+@karlt.net>
Mon, 02 Sep 2013 12:59:34 +1200
changeset 149229 917e9180f309615424cb31c892500c274596821c
parent 149228 9e9f4ff8bd5caa1240f21548197a1a8835630d38
child 149230 cffe4c4ccdf207245768ef432885385d5de5174e
push id4203
push userpaul@paul.cx
push dateMon, 02 Sep 2013 16:22:39 +0000
treeherdermozilla-aurora@aeac941ac517 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, webaudio
bugs890528
milestone25.0a2
b=890528 delay buffer must be greater than max delay frames to avoid reading what has just been written r=ehsan a=webaudio
content/media/webaudio/DelayProcessor.cpp
--- a/content/media/webaudio/DelayProcessor.cpp
+++ b/content/media/webaudio/DelayProcessor.cpp
@@ -104,17 +104,20 @@ DelayProcessor::EnsureBuffer(uint32_t aN
 {
   if (aNumberOfChannels == 0) {
     return false;
   }
   if (mBuffer.Length() == 0) {
     if (!mBuffer.SetLength(aNumberOfChannels)) {
       return false;
     }
-    const int numFrames = mMaxDelayFrames;
+    // The length of the buffer is one greater than the maximum delay so that
+    // writing an input frame does not overwrite the frame that would
+    // subsequently be read at maximum delay.
+    const int numFrames = mMaxDelayFrames + 1;
     for (uint32_t channel = 0; channel < aNumberOfChannels; ++channel) {
       if (!mBuffer[channel].SetLength(numFrames)) {
         return false;
       }
       PodZero(mBuffer[channel].Elements(), numFrames);
     }
   } else if (mBuffer.Length() != aNumberOfChannels) {
     // TODO: Handle changes in the channel count