Return an error when greater than 16 kHz is used with AECM.

BUG=chromium:178040

Review URL: https://webrtc-codereview.appspot.com/1146005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3587 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2013-03-01 16:36:19 +00:00
parent 6648093911
commit 78693fe37c
3 changed files with 31 additions and 23 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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));