Disable Analog AGC based on the APM config

Fixing a bug due to which the analog controller could not be disabled.
AudioProcessing::Config::GainController1::AnalogGainController::enabled
was ignored and therefore `recommended_stream_analog_level_locked()` in
APM was returning the level recommended by `AgcManagerDirect`.

When the analog controller is disabled, `stream_analog_level()` now
returns the last value set via `set_stream_analog_level()`.
However, the analog controller code is still running and, in particular,
the existing metrics are reported as if the controller were enabled.
This choice was made to reduce the risks of adding bugs in the digital
compression gain selection part, which is tied to the analog
controller. The metric drawback will be solved in a follow-up CL.

Additional changes:
- log `WebRTC.Audio.GainController.Analog.Enabled` when
AGC1 is created or when its config changes
- first step to replace "analog level" with "input volume"

Bug: webrtc:7909, b/180019868
Change-Id: I28ce9556dd98f3dd9ad546799406c55478730435
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/270663
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38044}
This commit is contained in:
Alessio Bazzica
2022-09-05 16:04:31 +02:00
committed by WebRTC LUCI CQ
parent c1e7080e51
commit b190ca9e70
5 changed files with 365 additions and 156 deletions

View File

@ -1374,7 +1374,7 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
if (config_.capture_level_adjustment.analog_mic_gain_emulation.enabled) {
if (submodules_.agc_manager) {
submodules_.capture_levels_adjuster->SetAnalogMicGainLevel(
submodules_.agc_manager->stream_analog_level());
submodules_.agc_manager->recommended_analog_level());
} else if (submodules_.gain_control) {
submodules_.capture_levels_adjuster->SetAnalogMicGainLevel(
submodules_.gain_control->stream_analog_level());
@ -1641,7 +1641,7 @@ int AudioProcessingImpl::recommended_stream_analog_level_locked() const {
}
if (submodules_.agc_manager) {
return submodules_.agc_manager->stream_analog_level();
return submodules_.agc_manager->recommended_analog_level();
}
if (submodules_.gain_control) {
@ -1852,6 +1852,10 @@ void AudioProcessingImpl::InitializeGainController1() {
return;
}
RTC_HISTOGRAM_BOOLEAN(
"WebRTC.Audio.GainController.Analog.Enabled",
config_.gain_controller1.analog_gain_controller.enabled);
if (!submodules_.gain_control) {
submodules_.gain_control.reset(new GainControlImpl());
}
@ -1887,7 +1891,7 @@ void AudioProcessingImpl::InitializeGainController1() {
int stream_analog_level = -1;
const bool re_creation = !!submodules_.agc_manager;
if (re_creation) {
stream_analog_level = submodules_.agc_manager->stream_analog_level();
stream_analog_level = submodules_.agc_manager->recommended_analog_level();
}
submodules_.agc_manager.reset(new AgcManagerDirect(
num_proc_channels(), config_.gain_controller1.analog_gain_controller));