Index: webrtc/media/engine/webrtcvoiceengine.cc |
diff --git a/webrtc/media/engine/webrtcvoiceengine.cc b/webrtc/media/engine/webrtcvoiceengine.cc |
index 2ddf67dd3a6d76d70236b8562cf2d5d8208bbd70..bec514eaf23f4929ef78bc11fe5ac6ed40a3d87f 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) { |
+ // 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) { |
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,15 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { |
new webrtc::Intelligibility(*intelligibility_enhancer_)); |
} |
+ if (options.level_control) { |
+ level_control_ = options.level_control; |
+ } |
+ |
+ if (level_control_) { |
+ LOG(LS_INFO) << "Level Control is enabled? " << *level_control_; |
tommi
2016/06/27 07:19:41
Should this be:
"Level control enabled, value=" <<
peah-webrtc
2016/06/27 08:22:12
That makes sense! I wrote it in this way to be con
|
+ 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(); |