From 92d66be163d1b7f8b321163f10a8954336f26ecb Mon Sep 17 00:00:00 2001 From: Hanna Silen Date: Thu, 3 Nov 2022 19:44:42 +0100 Subject: [PATCH] MonoInputVolumeController: Refactor Process() Bug: webrtc:7494 Change-Id: I609b5875ba3dbbee84aa3d481f3f359c964e6373 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280480 Reviewed-by: Alessio Bazzica Commit-Queue: Hanna Silen Cr-Commit-Position: refs/heads/main@{#38549} --- .../agc2/input_volume_controller.cc | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/modules/audio_processing/agc2/input_volume_controller.cc b/modules/audio_processing/agc2/input_volume_controller.cc index 116136e923..8df5ba36f2 100644 --- a/modules/audio_processing/agc2/input_volume_controller.cc +++ b/modules/audio_processing/agc2/input_volume_controller.cc @@ -197,19 +197,9 @@ void MonoInputVolumeController::Process( CheckVolumeAndReset(); } - int rms_error = 0; - bool update_gain = false; - if (rms_error_override.has_value()) { - if (is_first_frame_ || frames_since_update_gain_ < kOverrideWaitFrames) { - update_gain = false; - } else { - rms_error = *rms_error_override; - update_gain = true; - } - } - - if (update_gain) { - UpdateGain(rms_error); + if (rms_error_override.has_value() && !is_first_frame_ && + frames_since_update_gain_ >= kOverrideWaitFrames) { + UpdateGain(*rms_error_override); } is_first_frame_ = false;