Bug 930603: Ensure AEC known delay doesn't go negative (rev 4886 at webrtc.org) r=jib
authorRandell Jesup <rjesup@jesup.org>
Fri, 25 Oct 2013 18:21:33 -0400
changeset 166125 0e3e9ddedf98168ccc63de8e833541525f393ae3
parent 166124 0288124b22dd527171b4b13415511bcf4bcae677
child 166126 cbbbadec7f55c2e4479723e9449df87de417da38
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)
reviewersjib
bugs930603
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
Bug 930603: Ensure AEC known delay doesn't go negative (rev 4886 at webrtc.org) r=jib
media/webrtc/trunk/webrtc/modules/audio_processing/aec/echo_cancellation.c
--- a/media/webrtc/trunk/webrtc/modules/audio_processing/aec/echo_cancellation.c
+++ b/media/webrtc/trunk/webrtc/modules/audio_processing/aec/echo_cancellation.c
@@ -809,23 +809,28 @@ static void ProcessExtended(aecpc_t* sel
     int overhead_elements = (WebRtcAec_system_delay(self->aec) -
         startup_size_ms / 2 * self->rate_factor * 8) / PART_LEN;
     WebRtcAec_MoveFarReadPtr(self->aec, overhead_elements);
     self->startup_phase = 0;
   }
 
   EstBufDelayExtended(self);
 
-  for (i = 0; i < num_frames; ++i) {
+  {
     // |delay_diff_offset| gives us the option to manually rewind the delay on
     // very low delay platforms which can't be expressed purely through
     // |reported_delay_ms|.
-    WebRtcAec_ProcessFrame(self->aec, &near[FRAME_LEN * i],
-        &near_high[FRAME_LEN * i], self->knownDelay + delay_diff_offset,
-        &out[FRAME_LEN * i], &out_high[FRAME_LEN * i]);
+    const int adjusted_known_delay =
+        WEBRTC_SPL_MAX(0, self->knownDelay + delay_diff_offset);
+
+    for (i = 0; i < num_frames; ++i) {
+      WebRtcAec_ProcessFrame(self->aec, &near[FRAME_LEN * i],
+          &near_high[FRAME_LEN * i], adjusted_known_delay,
+          &out[FRAME_LEN * i], &out_high[FRAME_LEN * i]);
+    }
   }
 }
 
 static void EstBufDelayNormal(aecpc_t* aecpc) {
   int nSampSndCard = aecpc->msInSndCardBuf * sampMsNb * aecpc->rate_factor;
   int current_delay = nSampSndCard - WebRtcAec_system_delay(aecpc->aec);
   int delay_difference = 0;