From 8131eb0667793312004f64fa5548b31c618360a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85hgren?= Date: Wed, 28 Mar 2018 18:13:41 +0200 Subject: [PATCH] Allow the headset mode to be entered after the call has started MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL adds a timeout for the detection of the headset mode that allows it to be entered also for the cases where a headset is inserted during the call. Bug: chromium:826720,webrtc:9083 Change-Id: Ic3cb4cc0258997a74eccd1bcdf65765e44016ad8 Reviewed-on: https://webrtc-review.googlesource.com/65240 Reviewed-by: Alessio Bazzica Commit-Queue: Per Ã…hgren Cr-Commit-Position: refs/heads/master@{#22658} --- modules/audio_processing/aec3/aec_state.cc | 13 +++++++++++++ modules/audio_processing/aec3/aec_state.h | 1 + 2 files changed, 14 insertions(+) diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc index db61c5a118..bc987c40e1 100644 --- a/modules/audio_processing/aec3/aec_state.cc +++ b/modules/audio_processing/aec3/aec_state.cc @@ -167,6 +167,12 @@ void AecState::Update( blocks_since_converged_filter_ = converged_filter ? 0 : blocks_since_converged_filter_ + 1; } + if (converged_filter) { + active_blocks_since_converged_filter_ = 0; + } else if (active_render_block) { + ++active_blocks_since_converged_filter_; + } + bool recently_converged_filter = blocks_since_converged_filter_ < 60 * kNumBlocksPerSecond; @@ -198,6 +204,13 @@ void AecState::Update( converged_filter_seen_ = converged_filter_seen_ || converged_filter; + // If no filter convergence is seen for a long time, reset the estimated + // properties of the echo path. + if (active_blocks_since_converged_filter_ > 60 * kNumBlocksPerSecond) { + converged_filter_seen_ = false; + finite_erl_ = false; + } + // After an amount of active render samples for which an echo should have been // detected in the capture signal if the ERL was not infinite, flag that a // transparent mode should be entered. diff --git a/modules/audio_processing/aec3/aec_state.h b/modules/audio_processing/aec3/aec_state.h index 9e7c7b2c1d..e1ff492c51 100644 --- a/modules/audio_processing/aec3/aec_state.h +++ b/modules/audio_processing/aec3/aec_state.h @@ -175,6 +175,7 @@ class AecState { bool external_delay_seen_ = false; size_t converged_filter_count_ = 0; bool finite_erl_ = false; + size_t active_blocks_since_converged_filter_ = 0; RTC_DISALLOW_COPY_AND_ASSIGN(AecState); };