From 8e2f9bce710befcbd0ac3608fc0f983db01203db Mon Sep 17 00:00:00 2001 From: "andrew@webrtc.org" Date: Tue, 1 Oct 2013 01:12:25 +0000 Subject: [PATCH] Ensure adjusted "known delay" doesn't drop below zero. The untrusted delay mode provides an option to reduce the "known delay" parameter passed down to the core AEC. This is necessary to handle the very low latencies observed with the Chromium audio backend on Mac. Prior to this change, it was possible to pass a negative value. The AEC produced good output in practice, but it turned out this tripped a heretofore unnoticed assert in ProcessBlock(). This change avoids the assert, and maintains the good output across a set of Mac recordings. Bit-exact in some cases, and in the remaining, quickly converging to identical output. The assert was hit on the last webrtc roll in Chromium in content_browsertests on Mac. Corresponds to: https://chromereviews.googleplex.com/9960013 TBR=bjornv TESTED=Verified locally that "content_browsertests --gtest_filter=WebrtcBrowserTest.*"" passes. Review URL: https://webrtc-codereview.appspot.com/2328005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4886 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../audio_processing/aec/echo_cancellation.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/webrtc/modules/audio_processing/aec/echo_cancellation.c b/webrtc/modules/audio_processing/aec/echo_cancellation.c index 07bca559af..27da67de51 100644 --- a/webrtc/modules/audio_processing/aec/echo_cancellation.c +++ b/webrtc/modules/audio_processing/aec/echo_cancellation.c @@ -814,13 +814,18 @@ static void ProcessExtended(aecpc_t* self, const int16_t* near, 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]); + } } }