APM AgcManagerDirect: unusued min startup volume param removed

Tested: Chromium built with this change; verified that the
behavior at the beginning of the call has not changed with
both low (< 12) and high (> 12) input volumes.

Bug: webrtc:7494
Change-Id: Ie184c994d46bf6fd1cb209873383b911beb766e3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278787
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38420}
This commit is contained in:
Alessio Bazzica 2022-10-13 17:15:36 +02:00 committed by WebRTC LUCI CQ
parent b50599b7b5
commit 7afd698e0e
4 changed files with 6 additions and 41 deletions

View File

@ -87,10 +87,6 @@ absl::optional<int> 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);
@ -164,7 +160,6 @@ int GetSpeechLevelErrorDb(float speech_level_dbfs, float speech_probability) {
} // namespace
MonoAgc::MonoAgc(ApmDataDumper* data_dumper,
int startup_min_level,
int clipped_level_min,
bool disable_digital_adaptive,
int min_mic_level)
@ -176,7 +171,6 @@ MonoAgc::MonoAgc(ApmDataDumper* data_dumper,
target_compression_(kDefaultCompressionGain),
compression_(target_compression_),
compression_accumulator_(compression_),
startup_min_level_(ClampLevel(startup_min_level, min_mic_level_)),
clipped_level_min_(clipped_level_min) {}
MonoAgc::~MonoAgc() = default;
@ -347,9 +341,8 @@ int MonoAgc::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;
}
@ -504,15 +497,12 @@ AgcManagerDirect::AgcManagerDirect(int num_capture_channels,
<< " (overridden: "
<< (min_mic_level_override_.has_value() ? "yes" : "no")
<< ")";
RTC_LOG(LS_INFO) << "[agc] Startup min volume: "
<< analog_config.startup_min_volume;
for (size_t ch = 0; ch < channel_agcs_.size(); ++ch) {
ApmDataDumper* data_dumper_ch = ch == 0 ? data_dumper_.get() : nullptr;
channel_agcs_[ch] = std::make_unique<MonoAgc>(
data_dumper_ch, analog_config.startup_min_volume,
analog_config.clipped_level_min, disable_digital_adaptive_,
min_mic_level);
data_dumper_ch, analog_config.clipped_level_min,
disable_digital_adaptive_, min_mic_level);
}
RTC_DCHECK(!channel_agcs_.empty());
RTC_DCHECK_GT(clipped_level_step_, 0);

View File

@ -189,7 +189,6 @@ class AgcManagerDirect final {
class MonoAgc {
public:
MonoAgc(ApmDataDumper* data_dumper,
int startup_min_level,
int clipped_level_min,
bool disable_digital_adaptive,
int min_mic_level);
@ -228,7 +227,6 @@ class MonoAgc {
// Only used for testing.
void set_agc(Agc* agc) { agc_.reset(agc); }
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
@ -256,7 +254,6 @@ class MonoAgc {
bool capture_output_used_ = true;
bool check_volume_on_next_process_ = true;
bool startup_ = true;
int startup_min_level_;
int calls_since_last_gain_log_ = 0;
// TODO(bugs.webrtc.org/7494): Create a separate member for the applied

View File

@ -1443,8 +1443,6 @@ TEST(AgcManagerDirectTest, AgcMinMicLevelExperimentDefault) {
CreateAgcManagerDirect(kInitialInputVolume, kClippedLevelStep,
kClippedRatioThreshold, kClippedWaitFrames);
EXPECT_EQ(manager->channel_agcs_[0]->min_mic_level(), kMinMicLevel);
EXPECT_EQ(manager->channel_agcs_[0]->startup_min_level(),
kInitialInputVolume);
}
TEST(AgcManagerDirectTest, AgcMinMicLevelExperimentDisabled) {
@ -1455,8 +1453,6 @@ TEST(AgcManagerDirectTest, AgcMinMicLevelExperimentDisabled) {
CreateAgcManagerDirect(kInitialInputVolume, kClippedLevelStep,
kClippedRatioThreshold, kClippedWaitFrames);
EXPECT_EQ(manager->channel_agcs_[0]->min_mic_level(), kMinMicLevel);
EXPECT_EQ(manager->channel_agcs_[0]->startup_min_level(),
kInitialInputVolume);
}
}
@ -1469,8 +1465,6 @@ TEST(AgcManagerDirectTest, AgcMinMicLevelExperimentOutOfRangeAbove) {
CreateAgcManagerDirect(kInitialInputVolume, kClippedLevelStep,
kClippedRatioThreshold, kClippedWaitFrames);
EXPECT_EQ(manager->channel_agcs_[0]->min_mic_level(), kMinMicLevel);
EXPECT_EQ(manager->channel_agcs_[0]->startup_min_level(),
kInitialInputVolume);
}
// Checks that a field-trial parameter outside of the valid range [0,255] is
@ -1482,8 +1476,6 @@ TEST(AgcManagerDirectTest, AgcMinMicLevelExperimentOutOfRangeBelow) {
CreateAgcManagerDirect(kInitialInputVolume, kClippedLevelStep,
kClippedRatioThreshold, kClippedWaitFrames);
EXPECT_EQ(manager->channel_agcs_[0]->min_mic_level(), kMinMicLevel);
EXPECT_EQ(manager->channel_agcs_[0]->startup_min_level(),
kInitialInputVolume);
}
// Verifies that a valid experiment changes the minimum microphone level. The
@ -1500,8 +1492,6 @@ TEST(AgcManagerDirectTest, AgcMinMicLevelExperimentEnabled50) {
CreateAgcManagerDirect(kInitialInputVolume, kClippedLevelStep,
kClippedRatioThreshold, kClippedWaitFrames);
EXPECT_EQ(manager->channel_agcs_[0]->min_mic_level(), kMinMicLevelOverride);
EXPECT_EQ(manager->channel_agcs_[0]->startup_min_level(),
kInitialInputVolume);
}
}

View File

@ -51,18 +51,6 @@ class EchoDetector;
class CustomAudioAnalyzer;
class CustomProcessing;
// Use to enable experimental gain control (AGC). At startup the experimental
// AGC moves the microphone volume up to `startup_min_volume` if the current
// microphone volume is set too low. The value is clamped to its operating range
// [12, 255]. Here, 255 maps to 100%.
//
// Must be provided through AudioProcessingBuilder().Create(config).
#if defined(WEBRTC_CHROMIUM_BUILD)
static constexpr int kAgcStartupMinVolume = 85;
#else
static constexpr int kAgcStartupMinVolume = 0;
#endif // defined(WEBRTC_CHROMIUM_BUILD)
// The Audio Processing Module (APM) provides a collection of voice processing
// components designed for real-time communications software.
//
@ -286,8 +274,8 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
// Enables the analog gain controller functionality.
struct AnalogGainController {
bool enabled = true;
// TODO(bugs.webrtc.org/1275566): Describe `startup_min_volume`.
int startup_min_volume = kAgcStartupMinVolume;
// TODO(bugs.webrtc.org/7494): Deprecated. Stop using and remove.
int startup_min_volume = 0;
// Lowest analog microphone level that will be applied in response to
// clipping.
int clipped_level_min = 70;