Correcting the analog AGC re-initialization at device changes

This CL corrects the re-initialization behavior of the analog
AGC to work correctly when the AGC is reinitialized.

Bug: webrtc:11131
Change-Id: Ie455ba3db1aa3936cbcbb2fab023528124853284
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160650
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29924}
This commit is contained in:
Per Åhgren
2019-11-26 19:34:26 +01:00
committed by Commit Bot
parent 7a9a092708
commit 2a6b3b1f7f

View File

@ -482,12 +482,20 @@ int AudioProcessingImpl::InitializeLocked() {
static_cast<int>(num_proc_channels()) ||
submodules_.agc_manager->sample_rate_hz() !=
capture_nonlocked_.split_rate) {
int stream_analog_level = -1;
const bool re_creation = !!submodules_.agc_manager;
if (re_creation) {
stream_analog_level = submodules_.agc_manager->stream_analog_level();
}
submodules_.agc_manager.reset(new AgcManagerDirect(
num_proc_channels(), constants_.agc_startup_min_volume,
constants_.agc_clipped_level_min,
constants_.use_experimental_agc_agc2_level_estimation,
constants_.use_experimental_agc_agc2_digital_adaptive,
capture_nonlocked_.split_rate));
if (re_creation) {
submodules_.agc_manager->set_stream_analog_level(stream_analog_level);
}
}
submodules_.agc_manager->Initialize();
submodules_.agc_manager->SetupDigitalGainControl(