From 21a2fc902d37fb9607698dc0770c477b149163fe Mon Sep 17 00:00:00 2001 From: "bjornv@webrtc.org" Date: Fri, 15 Feb 2013 17:01:03 +0000 Subject: [PATCH] This Cl includes * A getter for echo_state * Style changes, such as changes to int where appropriate TEST=audioproc_unittest, trybots BUG=None Review URL: https://webrtc-codereview.appspot.com/1093011 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3522 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../modules/audio_processing/aec/aec_core.c | 5 +++ .../modules/audio_processing/aec/aec_core.h | 2 ++ .../audio_processing/aec/echo_cancellation.c | 33 +++++++++---------- .../aec/include/echo_cancellation.h | 10 +++--- .../echo_cancellation_impl.cc | 14 ++++---- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/webrtc/modules/audio_processing/aec/aec_core.c b/webrtc/modules/audio_processing/aec/aec_core.c index a8763b3d4..2dbd067c5 100644 --- a/webrtc/modules/audio_processing/aec/aec_core.c +++ b/webrtc/modules/audio_processing/aec/aec_core.c @@ -716,6 +716,11 @@ int WebRtcAec_GetDelayMetricsCore(aec_t* self, int* median, int* std) { return 0; } +int WebRtcAec_echo_state(aec_t* self) { + assert(self != NULL); + return self->echoState; +} + static void ProcessBlock(aec_t* aec) { int i; float d[PART_LEN], y[PART_LEN], e[PART_LEN], dH[PART_LEN]; diff --git a/webrtc/modules/audio_processing/aec/aec_core.h b/webrtc/modules/audio_processing/aec/aec_core.h index bab4c9166..7474ec76c 100644 --- a/webrtc/modules/audio_processing/aec/aec_core.h +++ b/webrtc/modules/audio_processing/aec/aec_core.h @@ -185,5 +185,7 @@ int WebRtcAec_MoveFarReadPtr(aec_t* aec, int elements); // Calculates the median and standard deviation among the delay estimates // collected since the last call to this function. int WebRtcAec_GetDelayMetricsCore(aec_t* self, int* median, int* std); +// Returns the echo state (1: echo, 0: no echo). +int WebRtcAec_echo_state(aec_t* self); #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_MAIN_SOURCE_AEC_CORE_H_ diff --git a/webrtc/modules/audio_processing/aec/echo_cancellation.c b/webrtc/modules/audio_processing/aec/echo_cancellation.c index dc5c47979..c6aa45451 100644 --- a/webrtc/modules/audio_processing/aec/echo_cancellation.c +++ b/webrtc/modules/audio_processing/aec/echo_cancellation.c @@ -609,27 +609,24 @@ WebRtc_Word32 WebRtcAec_get_config(void *aecInst, AecConfig *config) return 0; } -WebRtc_Word32 WebRtcAec_get_echo_status(void *aecInst, WebRtc_Word16 *status) -{ - aecpc_t *aecpc = aecInst; +int WebRtcAec_get_echo_status(void* handle, int* status) { + aecpc_t* self = (aecpc_t*)handle; - if (aecpc == NULL) { - return -1; - } + if (handle == NULL ) { + return -1; + } + if (status == NULL ) { + self->lastError = AEC_NULL_POINTER_ERROR; + return -1; + } + if (self->initFlag != initCheck) { + self->lastError = AEC_UNINITIALIZED_ERROR; + return -1; + } - if (status == NULL) { - aecpc->lastError = AEC_NULL_POINTER_ERROR; - return -1; - } + *status = WebRtcAec_echo_state(self->aec); - if (aecpc->initFlag != initCheck) { - aecpc->lastError = AEC_UNINITIALIZED_ERROR; - return -1; - } - - *status = aecpc->aec->echoState; - - return 0; + return 0; } WebRtc_Word32 WebRtcAec_GetMetrics(void *aecInst, AecMetrics *metrics) diff --git a/webrtc/modules/audio_processing/aec/include/echo_cancellation.h b/webrtc/modules/audio_processing/aec/include/echo_cancellation.h index a266e84fa..82dc0d3b1 100644 --- a/webrtc/modules/audio_processing/aec/include/echo_cancellation.h +++ b/webrtc/modules/audio_processing/aec/include/echo_cancellation.h @@ -11,7 +11,7 @@ #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC_INCLUDE_ECHO_CANCELLATION_H_ #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_INCLUDE_ECHO_CANCELLATION_H_ -#include "typedefs.h" +#include "webrtc/typedefs.h" // Errors #define AEC_UNSPECIFIED_ERROR 12000 @@ -199,16 +199,16 @@ WebRtc_Word32 WebRtcAec_get_config(void *aecInst, AecConfig *config); * * Inputs Description * ------------------------------------------------------------------- - * void *aecInst Pointer to the AEC instance + * void *handle Pointer to the AEC instance * * Outputs Description * ------------------------------------------------------------------- - * WebRtc_Word16 *status 0: Almost certainly nearend single-talk + * int *status 0: Almost certainly nearend single-talk * 1: Might not be neared single-talk - * WebRtc_Word32 return 0: OK + * int return 0: OK * -1: error */ -WebRtc_Word32 WebRtcAec_get_echo_status(void *aecInst, WebRtc_Word16 *status); +int WebRtcAec_get_echo_status(void* handle, int* status); /* * Gets the current echo metrics for the session. diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.cc b/webrtc/modules/audio_processing/echo_cancellation_impl.cc index d4c5523da..b968deb5c 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.cc +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.cc @@ -8,16 +8,16 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "echo_cancellation_impl.h" +#include "webrtc/modules/audio_processing/echo_cancellation_impl.h" -#include +#include #include -#include "critical_section_wrapper.h" -#include "echo_cancellation.h" +#include "webrtc/modules/audio_processing/audio_buffer.h" +#include "webrtc/modules/audio_processing/audio_processing_impl.h" +#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "audio_processing_impl.h" -#include "audio_buffer.h" +#include "webrtc/modules/audio_processing/aec/include/echo_cancellation.h" namespace webrtc { @@ -141,7 +141,7 @@ int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio) { } } - WebRtc_Word16 status = 0; + int status = 0; err = WebRtcAec_get_echo_status(my_handle, &status); if (err != apm_->kNoError) { return GetHandleError(my_handle);