From 90c08d0b2eafb0c3446e2c763e433760ede8e785 Mon Sep 17 00:00:00 2001 From: Alessio Bazzica Date: Wed, 9 Nov 2022 11:06:58 +0100 Subject: [PATCH] APM: mirror "unusued min startup volume param removed" CL in AGC2 See https://webrtc-review.googlesource.com/c/src/+/278787 Bug: webrtc:7494 Change-Id: Ie8ad8acc1d2e373d59d943282701e3483e980806 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282821 Reviewed-by: Hanna Silen Commit-Queue: Alessio Bazzica Cr-Commit-Position: refs/heads/main@{#38588} --- .../agc2/input_volume_controller.cc | 16 ++++------------ .../agc2/input_volume_controller.h | 6 +----- .../agc2/input_volume_controller_unittest.cc | 10 ---------- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/modules/audio_processing/agc2/input_volume_controller.cc b/modules/audio_processing/agc2/input_volume_controller.cc index db85db696a..aaaa09c464 100644 --- a/modules/audio_processing/agc2/input_volume_controller.cc +++ b/modules/audio_processing/agc2/input_volume_controller.cc @@ -86,10 +86,6 @@ absl::optional GetMinMicLevelOverride() { } } -int ClampLevel(int mic_level, int min_mic_level) { - return rtc::SafeClamp(mic_level, min_mic_level, kMaxMicLevel); -} - int LevelFromGainError(int gain_error, int level, int min_mic_level) { RTC_DCHECK_GE(level, 0); RTC_DCHECK_LE(level, kMaxMicLevel); @@ -178,12 +174,10 @@ int GetSpeechLevelErrorDb(float speech_level_dbfs, } // namespace -MonoInputVolumeController::MonoInputVolumeController(int startup_min_level, - int clipped_level_min, +MonoInputVolumeController::MonoInputVolumeController(int clipped_level_min, int min_mic_level) : min_mic_level_(min_mic_level), max_level_(kMaxMicLevel), - startup_min_level_(ClampLevel(startup_min_level, min_mic_level_)), clipped_level_min_(clipped_level_min) {} MonoInputVolumeController::~MonoInputVolumeController() = default; @@ -316,9 +310,8 @@ int MonoInputVolumeController::CheckVolumeAndReset() { } RTC_DLOG(LS_INFO) << "[agc] Initial GetMicVolume()=" << level; - int minLevel = startup_ ? startup_min_level_ : min_mic_level_; - if (level < minLevel) { - level = minLevel; + if (level < min_mic_level_) { + level = min_mic_level_; RTC_DLOG(LS_INFO) << "[agc] Initial volume too low, raising to " << level; recommended_input_volume_ = level; } @@ -379,11 +372,10 @@ InputVolumeController::InputVolumeController(int num_capture_channels, << " (overridden: " << (min_mic_level_override_.has_value() ? "yes" : "no") << ")"; - RTC_LOG(LS_INFO) << "[agc] Startup min volume: " << config.startup_min_volume; for (auto& controller : channel_controllers_) { controller = std::make_unique( - config.startup_min_volume, config.clipped_level_min, min_mic_level); + config.clipped_level_min, min_mic_level); } RTC_DCHECK(!channel_controllers_.empty()); diff --git a/modules/audio_processing/agc2/input_volume_controller.h b/modules/audio_processing/agc2/input_volume_controller.h index 73ded59e7a..c5f000b295 100644 --- a/modules/audio_processing/agc2/input_volume_controller.h +++ b/modules/audio_processing/agc2/input_volume_controller.h @@ -183,9 +183,7 @@ class InputVolumeController final { // convention. class MonoInputVolumeController { public: - MonoInputVolumeController(int startup_min_level, - int clipped_level_min, - int min_mic_level); + MonoInputVolumeController(int clipped_level_min, int min_mic_level); ~MonoInputVolumeController(); MonoInputVolumeController(const MonoInputVolumeController&) = delete; MonoInputVolumeController& operator=(const MonoInputVolumeController&) = @@ -214,7 +212,6 @@ class MonoInputVolumeController { // Only used for testing. int min_mic_level() const { return min_mic_level_; } - int startup_min_level() const { return startup_min_level_; } private: // Sets a new input volume, after first checking that it hasn't been updated @@ -240,7 +237,6 @@ class MonoInputVolumeController { bool capture_output_used_ = true; bool check_volume_on_next_process_ = true; bool startup_ = true; - int startup_min_level_; // TODO(bugs.webrtc.org/7494): Create a separate member for the applied // input volume. diff --git a/modules/audio_processing/agc2/input_volume_controller_unittest.cc b/modules/audio_processing/agc2/input_volume_controller_unittest.cc index b8280f0131..68544d62bb 100644 --- a/modules/audio_processing/agc2/input_volume_controller_unittest.cc +++ b/modules/audio_processing/agc2/input_volume_controller_unittest.cc @@ -947,8 +947,6 @@ TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentDefault) { CreateInputVolumeController(kInitialInputVolume, kClippedLevelStep, kClippedRatioThreshold, kClippedWaitFrames); EXPECT_EQ(manager->channel_controllers_[0]->min_mic_level(), kMinMicLevel); - EXPECT_EQ(manager->channel_controllers_[0]->startup_min_level(), - kInitialInputVolume); } TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentDisabled) { @@ -960,8 +958,6 @@ TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentDisabled) { kClippedRatioThreshold, kClippedWaitFrames); EXPECT_EQ(manager->channel_controllers_[0]->min_mic_level(), kMinMicLevel); - EXPECT_EQ(manager->channel_controllers_[0]->startup_min_level(), - kInitialInputVolume); } } @@ -974,8 +970,6 @@ TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentOutOfRangeAbove) { CreateInputVolumeController(kInitialInputVolume, kClippedLevelStep, kClippedRatioThreshold, kClippedWaitFrames); EXPECT_EQ(manager->channel_controllers_[0]->min_mic_level(), kMinMicLevel); - EXPECT_EQ(manager->channel_controllers_[0]->startup_min_level(), - kInitialInputVolume); } // Checks that a field-trial parameter outside of the valid range [0,255] is @@ -987,8 +981,6 @@ TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentOutOfRangeBelow) { CreateInputVolumeController(kInitialInputVolume, kClippedLevelStep, kClippedRatioThreshold, kClippedWaitFrames); EXPECT_EQ(manager->channel_controllers_[0]->min_mic_level(), kMinMicLevel); - EXPECT_EQ(manager->channel_controllers_[0]->startup_min_level(), - kInitialInputVolume); } // Verifies that a valid experiment changes the minimum microphone level. The @@ -1007,8 +999,6 @@ TEST(InputVolumeControllerTest, AgcMinMicLevelExperimentEnabled50) { EXPECT_EQ(manager->channel_controllers_[0]->min_mic_level(), kMinMicLevelOverride); - EXPECT_EQ(manager->channel_controllers_[0]->startup_min_level(), - kInitialInputVolume); } }