diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index 3877a389d..905157562 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -8,23 +8,24 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "audio_processing_impl.h" +#include "webrtc/modules/audio_processing/audio_processing_impl.h" #include <assert.h> -#include "audio_buffer.h" -#include "critical_section_wrapper.h" -#include "echo_cancellation_impl.h" -#include "echo_control_mobile_impl.h" -#include "file_wrapper.h" -#include "high_pass_filter_impl.h" -#include "gain_control_impl.h" -#include "level_estimator_impl.h" -#include "module_common_types.h" -#include "noise_suppression_impl.h" -#include "processing_component.h" -#include "splitting_filter.h" -#include "voice_detection_impl.h" +#include "webrtc/modules/audio_processing/audio_buffer.h" +#include "webrtc/modules/audio_processing/echo_cancellation_impl.h" +#include "webrtc/modules/audio_processing/echo_control_mobile_impl.h" +#include "webrtc/modules/audio_processing/gain_control_impl.h" +#include "webrtc/modules/audio_processing/high_pass_filter_impl.h" +#include "webrtc/modules/audio_processing/level_estimator_impl.h" +#include "webrtc/modules/audio_processing/noise_suppression_impl.h" +#include "webrtc/modules/audio_processing/processing_component.h" +#include "webrtc/modules/audio_processing/splitting_filter.h" +#include "webrtc/modules/audio_processing/voice_detection_impl.h" +#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" +#include "webrtc/system_wrappers/interface/file_wrapper.h" +#include "webrtc/system_wrappers/interface/logging.h" #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP // Files generated at build-time by the protobuf compiler. @@ -37,7 +38,6 @@ namespace webrtc { AudioProcessing* AudioProcessing::Create(int id) { - AudioProcessingImpl* apm = new AudioProcessingImpl(id); if (apm->Initialize() != kNoError) { delete apm; @@ -76,7 +76,6 @@ AudioProcessingImpl::AudioProcessingImpl(int id) num_reverse_channels_(1), num_input_channels_(1), num_output_channels_(1) { - echo_cancellation_ = new EchoCancellationImpl(this); component_list_.push_back(echo_cancellation_); @@ -192,6 +191,10 @@ int AudioProcessingImpl::set_sample_rate_hz(int rate) { rate != kSampleRate32kHz) { return kBadParameterError; } + if (echo_control_mobile_->is_enabled() && rate > kSampleRate16kHz) { + LOG(LS_ERROR) << "AECM only supports 16 kHz or lower sample rates"; + return kUnsupportedComponentError; + } sample_rate_hz_ = rate; samples_per_channel_ = rate / 100; diff --git a/webrtc/modules/audio_processing/echo_control_mobile_impl.cc b/webrtc/modules/audio_processing/echo_control_mobile_impl.cc index 94277890b..5b88aa5fd 100644 --- a/webrtc/modules/audio_processing/echo_control_mobile_impl.cc +++ b/webrtc/modules/audio_processing/echo_control_mobile_impl.cc @@ -8,16 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "echo_control_mobile_impl.h" +#include "webrtc/modules/audio_processing/echo_control_mobile_impl.h" #include <cassert> #include <cstring> -#include "critical_section_wrapper.h" -#include "echo_control_mobile.h" - -#include "audio_processing_impl.h" -#include "audio_buffer.h" +#include "webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h" +#include "webrtc/modules/audio_processing/audio_processing_impl.h" +#include "webrtc/modules/audio_processing/audio_buffer.h" +#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" +#include "webrtc/system_wrappers/interface/logging.h" namespace webrtc { @@ -241,7 +241,7 @@ int EchoControlMobileImpl::Initialize() { } if (apm_->sample_rate_hz() == apm_->kSampleRate32kHz) { - // AECM doesn't support super-wideband. + LOG(LS_ERROR) << "AECM only supports 16 kHz or lower sample rates"; return apm_->kBadSampleRateError; } diff --git a/webrtc/modules/audio_processing/test/unit_test.cc b/webrtc/modules/audio_processing/test/unit_test.cc index 61d8cef3e..32dc8769b 100644 --- a/webrtc/modules/audio_processing/test/unit_test.cc +++ b/webrtc/modules/audio_processing/test/unit_test.cc @@ -885,6 +885,11 @@ TEST_F(ApmTest, EchoControlMobile) { EXPECT_EQ(apm_->kNoError, apm_->set_sample_rate_hz(32000)); EXPECT_EQ(apm_->kBadSampleRateError, apm_->echo_control_mobile()->Enable(true)); + EXPECT_EQ(apm_->kNoError, apm_->set_sample_rate_hz(16000)); + EXPECT_EQ(apm_->kNoError, + apm_->echo_control_mobile()->Enable(true)); + EXPECT_EQ(apm_->kUnsupportedComponentError, apm_->set_sample_rate_hz(32000)); + // Turn AECM on (and AEC off) Init(16000, 2, 2, 2, false); EXPECT_EQ(apm_->kNoError, apm_->echo_control_mobile()->Enable(true));