This CL adds functionality in the level controller to
receive a signal level to use initially, instead of the
default initial signal level.
The initial form of the CL
(https://codereview.webrtc.org/2254973003/) was reverted
due to down-stream dependencies. These have been resolved,
but the CL needed to be revised according to the new scheme
for passing parameters to the audio processing module.
Therefore, please review this CL as if it is new.
TBR=aleloi@webrtc.org
BUG=webrtc:6386
Review-Url: https://codereview.webrtc.org/2337083002
Cr-Commit-Position: refs/heads/master@{#14579}
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index 5e08b85..85f1597 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -298,6 +298,8 @@
new GainControlForExperimentalAgc(
public_submodules_->gain_control.get(), &crit_capture_));
+ // TODO(peah): Move this creation to happen only when the level controller
+ // is enabled.
private_submodules_->level_controller.reset(new LevelController());
}
@@ -543,30 +545,36 @@
}
void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
- AudioProcessing::Config config_to_use = config;
+ config_ = config;
- bool config_ok = LevelController::Validate(config_to_use.level_controller);
+ bool config_ok = LevelController::Validate(config_.level_controller);
if (!config_ok) {
LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl
<< "level_controller: "
- << LevelController::ToString(config_to_use.level_controller)
+ << LevelController::ToString(config_.level_controller)
<< std::endl
<< "Reverting to default parameter set";
- config_to_use.level_controller = AudioProcessing::Config::LevelController();
+ config_.level_controller = AudioProcessing::Config::LevelController();
}
// Run in a single-threaded manner when applying the settings.
rtc::CritScope cs_render(&crit_render_);
rtc::CritScope cs_capture(&crit_capture_);
- if (config.level_controller.enabled !=
- capture_nonlocked_.level_controller_enabled) {
- InitializeLevelController();
- LOG(LS_INFO) << "Level controller activated: "
- << capture_nonlocked_.level_controller_enabled;
+ // TODO(peah): Replace the use of capture_nonlocked_.level_controller_enabled
+ // with the value in config_ everywhere in the code.
+ if (capture_nonlocked_.level_controller_enabled !=
+ config_.level_controller.enabled) {
capture_nonlocked_.level_controller_enabled =
- config.level_controller.enabled;
+ config_.level_controller.enabled;
+ // TODO(peah): Remove the conditional initialization to always initialize
+ // the level controller regardless of whether it is enabled or not.
+ InitializeLevelController();
}
+ LOG(LS_INFO) << "Level controller activated: "
+ << capture_nonlocked_.level_controller_enabled;
+
+ private_submodules_->level_controller->ApplyConfig(config_.level_controller);
}
void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) {