diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc index 5f36e6518e..2222b18452 100644 --- a/modules/audio_processing/aec3/aec_state.cc +++ b/modules/audio_processing/aec3/aec_state.cc @@ -19,10 +19,15 @@ #include "modules/audio_processing/logging/apm_data_dumper.h" #include "rtc_base/atomicops.h" #include "rtc_base/checks.h" +#include "system_wrappers/include/field_trial.h" namespace webrtc { namespace { +bool EnableTransparentMode() { + return !field_trial::IsEnabled("WebRTC-Aec3TransparentModeKillSwitch"); +} + float ComputeGainRampupIncrease(const EchoCanceller3Config& config) { const auto& c = config.echo_removal_control.gain_rampup; return powf(1.f / c.first_non_zero_gain, 1.f / c.non_zero_gain_blocks); @@ -38,6 +43,7 @@ int AecState::instance_count_ = 0; AecState::AecState(const EchoCanceller3Config& config) : data_dumper_( new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))), + allow_transparent_mode_(EnableTransparentMode()), erle_estimator_(config.erle.min, config.erle.max_l, config.erle.max_h), config_(config), max_render_(config_.filter.main.length_blocks, 0.f), @@ -223,10 +229,8 @@ void AecState::Update( transparent_mode_ = transparent_mode_ && (consistent_filter_estimate_not_seen || !converged_filter_seen_); - transparent_mode_ = transparent_mode_ && - (filter_should_have_converged_ || - (!external_delay_seen_ && - capture_block_counter_ > 10 * kNumBlocksPerSecond)); + transparent_mode_ = transparent_mode_ && filter_should_have_converged_; + transparent_mode_ = transparent_mode_ && allow_transparent_mode_; usable_linear_estimate_ = !echo_saturation_; usable_linear_estimate_ = diff --git a/modules/audio_processing/aec3/aec_state.h b/modules/audio_processing/aec3/aec_state.h index 4f5c8717b1..7d5fe43338 100644 --- a/modules/audio_processing/aec3/aec_state.h +++ b/modules/audio_processing/aec3/aec_state.h @@ -142,6 +142,7 @@ class AecState { static int instance_count_; std::unique_ptr data_dumper_; + const bool allow_transparent_mode_; ErlEstimator erl_estimator_; ErleEstimator erle_estimator_; size_t capture_block_counter_ = 0; diff --git a/modules/audio_processing/aec3/subtractor.cc b/modules/audio_processing/aec3/subtractor.cc index a72a667312..7ea616741c 100644 --- a/modules/audio_processing/aec3/subtractor.cc +++ b/modules/audio_processing/aec3/subtractor.cc @@ -162,7 +162,7 @@ void Subtractor::Process(const RenderBuffer& render_buffer, std::accumulate(e_shadow.begin(), e_shadow.end(), 0.f, sum_of_squares); constexpr float kConvergenceThreshold = 50 * 50 * kBlockSize; - main_filter_converged_ = e2_main < 0.2 * y2 && y2 > kConvergenceThreshold; + main_filter_converged_ = e2_main < 0.5f * y2 && y2 > kConvergenceThreshold; shadow_filter_converged_ = e2_shadow < 0.05 * y2 && y2 > kConvergenceThreshold; main_filter_once_converged_ =