diff --git a/webrtc/modules/audio_processing/aec3/aec_state.cc b/webrtc/modules/audio_processing/aec3/aec_state.cc index 1a9f66ffcb..01c3c440fa 100644 --- a/webrtc/modules/audio_processing/aec3/aec_state.cc +++ b/webrtc/modules/audio_processing/aec3/aec_state.cc @@ -72,7 +72,7 @@ rtc::Optional EstimateFilterDelay( } constexpr int kEchoPathChangeCounterInitial = kNumBlocksPerSecond / 5; -constexpr int kEchoPathChangeCounterMax = 3 * kNumBlocksPerSecond; +constexpr int kEchoPathChangeCounterMax = 2 * kNumBlocksPerSecond; } // namespace @@ -90,17 +90,19 @@ void AecState::HandleEchoPathChange( if (echo_path_variability.AudioPathChanged()) { blocks_since_last_saturation_ = 0; active_render_blocks_ = 0; - echo_path_change_counter_ = kEchoPathChangeCounterMax; usable_linear_estimate_ = false; echo_leakage_detected_ = false; capture_signal_saturation_ = false; echo_saturation_ = false; - headset_detected_ = false; previous_max_sample_ = 0.f; if (echo_path_variability.delay_change) { force_zero_gain_counter_ = 0; force_zero_gain_ = true; + echo_path_change_counter_ = kEchoPathChangeCounterMax; + } + if (echo_path_variability.gain_change) { + echo_path_change_counter_ = kEchoPathChangeCounterInitial; } } } diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index af5e94b602..816210f34f 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -10,6 +10,7 @@ #include "webrtc/modules/audio_processing/audio_processing_impl.h" +#include #include #include "webrtc/base/checks.h" @@ -1147,7 +1148,7 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() { if (private_submodules_->echo_canceller3) { const int new_agc_level = gain_control()->stream_analog_level(); capture_.echo_path_gain_change = - (capture_.previous_agc_level != new_agc_level); + abs(capture_.previous_agc_level - new_agc_level) > 5; capture_.previous_agc_level = new_agc_level; private_submodules_->echo_canceller3->AnalyzeCapture(capture_buffer); }