Removed the AudioProcessing dependency in EchoCancellerImpl.
This CL removes the dependency of AudioProcessing in
EchoCancellerImpl. It is breaking the public APM API by
having a different error code behavior so please review it
carefully. I made a comment about the API breaking change
in the code section of this CL.
BUG=webrtc:5337
Review URL: https://codereview.webrtc.org/1770823002
Cr-Commit-Position: refs/heads/master@{#11998}
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index 3675869..267929a 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -168,7 +168,7 @@
rtc::CritScope cs_capture(&crit_capture_);
public_submodules_->echo_cancellation.reset(
- new EchoCancellationImpl(this, &crit_render_, &crit_capture_));
+ new EchoCancellationImpl(&crit_render_, &crit_capture_));
public_submodules_->echo_control_mobile.reset(
new EchoControlMobileImpl(&crit_render_, &crit_capture_));
public_submodules_->gain_control.reset(
@@ -658,6 +658,12 @@
}
int AudioProcessingImpl::ProcessStreamLocked() {
+ // Ensure that not both the AEC and AECM are active at the same time.
+ // TODO(peah): Simplify once the public API Enable functions for these
+ // are moved to APM.
+ RTC_DCHECK(!(public_submodules_->echo_cancellation->is_enabled() &&
+ public_submodules_->echo_control_mobile->is_enabled()));
+
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
if (debug_dump_.debug_file->Open()) {
audioproc::Stream* msg = debug_dump_.capture.event_msg->mutable_stream();
@@ -694,7 +700,16 @@
public_submodules_->high_pass_filter->ProcessCaptureAudio(ca);
RETURN_ON_ERR(public_submodules_->gain_control->AnalyzeCaptureAudio(ca));
public_submodules_->noise_suppression->AnalyzeCaptureAudio(ca);
- RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessCaptureAudio(ca));
+
+ // Ensure that the stream delay was set before the call to the
+ // AEC ProcessCaptureAudio function.
+ if (public_submodules_->echo_cancellation->is_enabled() &&
+ !was_stream_delay_set()) {
+ return AudioProcessing::kStreamParameterNotSetError;
+ }
+
+ RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessCaptureAudio(
+ ca, stream_delay_ms()));
if (public_submodules_->echo_control_mobile->is_enabled() &&
public_submodules_->noise_suppression->is_enabled()) {
@@ -1227,7 +1242,9 @@
}
void AudioProcessingImpl::InitializeEchoCanceller() {
- public_submodules_->echo_cancellation->Initialize();
+ public_submodules_->echo_cancellation->Initialize(
+ proc_sample_rate_hz(), num_reverse_channels(), num_output_channels(),
+ num_proc_channels());
}
void AudioProcessingImpl::InitializeGainController() {