diff --git a/modules/audio_processing/aec3/filter_analyzer.cc b/modules/audio_processing/aec3/filter_analyzer.cc index 696a57c18d..be954d3a18 100644 --- a/modules/audio_processing/aec3/filter_analyzer.cc +++ b/modules/audio_processing/aec3/filter_analyzer.cc @@ -69,9 +69,7 @@ void FilterAnalyzer::Reset() { blocks_since_reset_ = 0; ResetRegion(); for (auto& state : filter_analysis_states_) { - state.peak_index = 0; - state.gain = default_gain_; - state.consistent_filter_detector.Reset(); + state.Reset(default_gain_); } std::fill(filter_delays_blocks_.begin(), filter_delays_blocks_.end(), 0); } @@ -204,7 +202,9 @@ FilterAnalyzer::ConsistentFilterDetector::ConsistentFilterDetector( const EchoCanceller3Config& config) : active_render_threshold_(config.render_levels.active_render_limit * config.render_levels.active_render_limit * - kFftLengthBy2) {} + kFftLengthBy2) { + Reset(); +} void FilterAnalyzer::ConsistentFilterDetector::Reset() { significant_peak_ = false; diff --git a/modules/audio_processing/aec3/filter_analyzer.h b/modules/audio_processing/aec3/filter_analyzer.h index 0be2a7bc30..b0b7070119 100644 --- a/modules/audio_processing/aec3/filter_analyzer.h +++ b/modules/audio_processing/aec3/filter_analyzer.h @@ -112,7 +112,16 @@ class FilterAnalyzer { struct FilterAnalysisState { explicit FilterAnalysisState(const EchoCanceller3Config& config) : filter_length_blocks(config.filter.refined_initial.length_blocks), - consistent_filter_detector(config) {} + consistent_filter_detector(config) { + Reset(config.ep_strength.default_gain); + } + + void Reset(float default_gain) { + peak_index = 0; + gain = default_gain; + consistent_filter_detector.Reset(); + } + float gain; size_t peak_index; int filter_length_blocks;