Chromium Code Reviews| Index: webrtc/media/engine/webrtcvoiceengine.cc | 
| diff --git a/webrtc/media/engine/webrtcvoiceengine.cc b/webrtc/media/engine/webrtcvoiceengine.cc | 
| index 2ddf67dd3a6d76d70236b8562cf2d5d8208bbd70..0c72cb72b10b4713f662da9dc8e9344f83bf63cf 100644 | 
| --- a/webrtc/media/engine/webrtcvoiceengine.cc | 
| +++ b/webrtc/media/engine/webrtcvoiceengine.cc | 
| @@ -560,6 +560,7 @@ WebRtcVoiceEngine::WebRtcVoiceEngine( | 
| options.delay_agnostic_aec = rtc::Optional<bool>(false); | 
| options.experimental_ns = rtc::Optional<bool>(false); | 
| options.intelligibility_enhancer = rtc::Optional<bool>(false); | 
| + options.level_control = rtc::Optional<bool>(false); | 
| bool error = ApplyOptions(options); | 
| RTC_DCHECK(error); | 
| } | 
| @@ -683,9 +684,27 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { | 
| } | 
| } | 
| + // Use optional to avoid uneccessary calls to BuiltInAGCIsAvailable while | 
| + // complying with the unittest requirements of only 1 call per test. | 
| + rtc::Optional<bool> built_in_agc_avaliable; | 
| + if (options.level_control) { | 
| + if (!built_in_agc_avaliable) { | 
| + built_in_agc_avaliable = | 
| + rtc::Optional<bool>(adm()->BuiltInAGCIsAvailable()); | 
| + } | 
| + if (*built_in_agc_avaliable) { | 
| 
 
hlundin-webrtc
2016/06/27 11:44:27
I wouldn't mind adding a DCHECK(built_in_agc_avali
 
peah-webrtc
2016/06/27 23:00:05
Makes sense. Added that!
Done.
 
 | 
| + // Disable internal software level control if built-in AGC is enabled, | 
| + // i.e., replace the software AGC with the built-in AGC. | 
| + options.level_control = rtc::Optional<bool>(false); | 
| + } | 
| + } | 
| + | 
| if (options.auto_gain_control) { | 
| - const bool built_in_agc = adm()->BuiltInAGCIsAvailable(); | 
| - if (built_in_agc) { | 
| + if (!built_in_agc_avaliable) { | 
| + built_in_agc_avaliable = | 
| + rtc::Optional<bool>(adm()->BuiltInAGCIsAvailable()); | 
| + } | 
| + if (*built_in_agc_avaliable) { | 
| 
 
hlundin-webrtc
2016/06/27 11:44:27
DCHECK here too.
 
peah-webrtc
2016/06/27 23:00:05
Makes sense. Added that!
Done.
 
 | 
| if (adm()->EnableBuiltInAGC(*options.auto_gain_control) == 0 && | 
| *options.auto_gain_control) { | 
| // Disable internal software AGC if built-in AGC is enabled, | 
| @@ -842,6 +861,16 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { | 
| new webrtc::Intelligibility(*intelligibility_enhancer_)); | 
| } | 
| + if (options.level_control) { | 
| + level_control_ = options.level_control; | 
| + } | 
| + | 
| + LOG(LS_INFO) << "Level control: " | 
| + << (!!level_control_ ? *level_control_ : -1); | 
| + if (level_control_) { | 
| + config.Set<webrtc::LevelControl>(new webrtc::LevelControl(*level_control_)); | 
| + } | 
| + | 
| // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine | 
| // returns NULL on audio_processing(). | 
| webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); |