Commit 53493f59 authored by Sam Zackrisson's avatar Sam Zackrisson Committed by Commit Bot

Add AEC toggling logic for upstream config change

- Adds a second (currently no-op) toggling of AEC2 and AECM, to allow
  for upstream changes in WebRTC (removing the EchoControlMobile API).
- Localizes the creation of a webrtc::AudioProcessing::Config to
  avoid overwriting settings.

Shortly, this will be the only way to toggle AECs in APM.

Bug: webrtc:9535

Change-Id: I019408ec7e5b5e91afddfe854d607126ee065fdb
Reviewed-on: https://chromium-review.googlesource.com/1152914Reviewed-by: default avatarOskar Sundbom <ossu@chromium.org>
Reviewed-by: default avatarPer Kjellander <perkj@chromium.org>
Commit-Queue: Sam Zackrisson <saza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582577}
parent 92c38676
...@@ -612,8 +612,6 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule( ...@@ -612,8 +612,6 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
audio_processing_.reset(ap_builder.Create(config)); audio_processing_.reset(ap_builder.Create(config));
// Enable the audio processing components. // Enable the audio processing components.
webrtc::AudioProcessing::Config apm_config;
if (playout_data_source_) { if (playout_data_source_) {
playout_data_source_->AddPlayoutSink(this); playout_data_source_->AddPlayoutSink(this);
} }
...@@ -633,8 +631,6 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule( ...@@ -633,8 +631,6 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
if (properties.goog_noise_suppression) if (properties.goog_noise_suppression)
EnableNoiseSuppression(audio_processing_.get(), NoiseSuppression::kHigh); EnableNoiseSuppression(audio_processing_.get(), NoiseSuppression::kHigh);
apm_config.high_pass_filter.enabled = properties.goog_highpass_filter;
if (goog_typing_detection) { if (goog_typing_detection) {
// TODO(xians): Remove this |typing_detector_| after the typing suppression // TODO(xians): Remove this |typing_detector_| after the typing suppression
// is enabled by default. // is enabled by default.
...@@ -645,6 +641,8 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule( ...@@ -645,6 +641,8 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
if (properties.goog_auto_gain_control) if (properties.goog_auto_gain_control)
EnableAutomaticGainControl(audio_processing_.get()); EnableAutomaticGainControl(audio_processing_.get());
webrtc::AudioProcessing::Config apm_config = audio_processing_->GetConfig();
apm_config.high_pass_filter.enabled = properties.goog_highpass_filter;
audio_processing_->ApplyConfig(apm_config); audio_processing_->ApplyConfig(apm_config);
RecordProcessingState(AUDIO_PROCESSING_ENABLED); RecordProcessingState(AUDIO_PROCESSING_ENABLED);
......
...@@ -202,13 +202,17 @@ void EchoInformation::ReportAndResetAecDivergentFilterStats() { ...@@ -202,13 +202,17 @@ void EchoInformation::ReportAndResetAecDivergentFilterStats() {
} }
void EnableEchoCancellation(AudioProcessing* audio_processing) { void EnableEchoCancellation(AudioProcessing* audio_processing) {
// TODO(bugs.webrtc.org/9535): Remove double-booking AEC toggle when the
// config applies (from 2018-08-16).
webrtc::AudioProcessing::Config apm_config = audio_processing->GetConfig();
apm_config.echo_canceller.enabled = true;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Mobile devices are using AECM. // Mobile devices are using AECM.
CHECK_EQ(0, audio_processing->echo_control_mobile()->set_routing_mode( CHECK_EQ(0, audio_processing->echo_control_mobile()->set_routing_mode(
webrtc::EchoControlMobile::kSpeakerphone)); webrtc::EchoControlMobile::kSpeakerphone));
CHECK_EQ(0, audio_processing->echo_control_mobile()->Enable(true)); CHECK_EQ(0, audio_processing->echo_control_mobile()->Enable(true));
return; apm_config.echo_canceller.mobile_mode = true;
#endif #else
int err = audio_processing->echo_cancellation()->set_suppression_level( int err = audio_processing->echo_cancellation()->set_suppression_level(
webrtc::EchoCancellation::kHighSuppression); webrtc::EchoCancellation::kHighSuppression);
...@@ -217,6 +221,9 @@ void EnableEchoCancellation(AudioProcessing* audio_processing) { ...@@ -217,6 +221,9 @@ void EnableEchoCancellation(AudioProcessing* audio_processing) {
err |= audio_processing->echo_cancellation()->enable_delay_logging(true); err |= audio_processing->echo_cancellation()->enable_delay_logging(true);
err |= audio_processing->echo_cancellation()->Enable(true); err |= audio_processing->echo_cancellation()->Enable(true);
CHECK_EQ(err, 0); CHECK_EQ(err, 0);
apm_config.echo_canceller.mobile_mode = false;
#endif
audio_processing->ApplyConfig(apm_config);
} }
void EnableNoiseSuppression(AudioProcessing* audio_processing, void EnableNoiseSuppression(AudioProcessing* audio_processing,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment