diff --git a/api/audio/echo_canceller3_config.h b/api/audio/echo_canceller3_config.h index c19226e9e9..d8e6f24668 100644 --- a/api/audio/echo_canceller3_config.h +++ b/api/audio/echo_canceller3_config.h @@ -76,6 +76,7 @@ struct RTC_EXPORT EchoCanceller3Config { float initial_state_seconds = 2.5f; bool conservative_initial_phase = false; bool enable_shadow_filter_output_usage = true; + bool use_linear_filter = true; } filter; struct Erle { diff --git a/api/audio/echo_canceller3_config_json.cc b/api/audio/echo_canceller3_config_json.cc index 07c4e52447..9c4824c94d 100644 --- a/api/audio/echo_canceller3_config_json.cc +++ b/api/audio/echo_canceller3_config_json.cc @@ -167,6 +167,9 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, ReadParam(subsection, "converged", &cfg.delay.delay_selection_thresholds.converged); } + + ReadParam(section, "use_external_delay_estimator", + &cfg.delay.use_external_delay_estimator); } if (rtc::GetValueFromJsonObject(aec3_root, "filter", §ion)) { @@ -182,6 +185,7 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, &cfg.filter.conservative_initial_phase); ReadParam(section, "enable_shadow_filter_output_usage", &cfg.filter.enable_shadow_filter_output_usage); + ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter); } if (rtc::GetValueFromJsonObject(aec3_root, "erle", §ion)) { diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc index 99791a7302..6a5b6e5266 100644 --- a/modules/audio_processing/aec3/aec_state.cc +++ b/modules/audio_processing/aec3/aec_state.cc @@ -118,7 +118,9 @@ void AecState::Update( // Estimate the direct path delay of the filter. delay_state_.Update(filter_analyzer_, external_delay, - strong_not_saturated_render_blocks_); + config_.filter.use_linear_filter + ? strong_not_saturated_render_blocks_ + : 0); const std::vector& aligned_render_block = render_buffer.Block(-delay_state_.DirectPathFilterDelay())[0]; diff --git a/modules/audio_processing/aec3/aec_state.h b/modules/audio_processing/aec3/aec_state.h index e323b2c6b1..1887492f8a 100644 --- a/modules/audio_processing/aec3/aec_state.h +++ b/modules/audio_processing/aec3/aec_state.h @@ -45,12 +45,14 @@ class AecState { // Returns whether the echo subtractor can be used to determine the residual // echo. bool UsableLinearEstimate() const { - return filter_quality_state_.LinearFilterUsable(); + return filter_quality_state_.LinearFilterUsable() && + config_.filter.use_linear_filter; } // Returns whether the echo subtractor output should be used as output. bool UseLinearFilterOutput() const { - return filter_quality_state_.LinearFilterUsable(); + return filter_quality_state_.LinearFilterUsable() && + config_.filter.use_linear_filter; } // Returns the estimated echo path gain.