diff options
Diffstat (limited to 'webrtc/modules/audio_processing/aecm')
-rw-r--r-- | webrtc/modules/audio_processing/aecm/aecm_core.c | 2 | ||||
-rw-r--r-- | webrtc/modules/audio_processing/aecm/aecm_core_c.c | 2 | ||||
-rw-r--r-- | webrtc/modules/audio_processing/aecm/aecm_core_mips.c | 2 | ||||
-rw-r--r-- | webrtc/modules/audio_processing/aecm/echo_control_mobile.c | 160 | ||||
-rw-r--r-- | webrtc/modules/audio_processing/aecm/echo_control_mobile.h (renamed from webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h) | 65 |
5 files changed, 83 insertions, 148 deletions
diff --git a/webrtc/modules/audio_processing/aecm/aecm_core.c b/webrtc/modules/audio_processing/aecm/aecm_core.c index f0d85d5328..6bf1cf7f3e 100644 --- a/webrtc/modules/audio_processing/aecm/aecm_core.c +++ b/webrtc/modules/audio_processing/aecm/aecm_core.c @@ -16,7 +16,7 @@ #include "webrtc/common_audio/ring_buffer.h" #include "webrtc/common_audio/signal_processing/include/real_fft.h" -#include "webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h" +#include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" #include "webrtc/system_wrappers/include/compile_assert_c.h" #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" diff --git a/webrtc/modules/audio_processing/aecm/aecm_core_c.c b/webrtc/modules/audio_processing/aecm/aecm_core_c.c index df95e8bedf..3a8fafa4ec 100644 --- a/webrtc/modules/audio_processing/aecm/aecm_core_c.c +++ b/webrtc/modules/audio_processing/aecm/aecm_core_c.c @@ -16,7 +16,7 @@ #include "webrtc/common_audio/ring_buffer.h" #include "webrtc/common_audio/signal_processing/include/real_fft.h" -#include "webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h" +#include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" #include "webrtc/system_wrappers/include/compile_assert_c.h" #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" diff --git a/webrtc/modules/audio_processing/aecm/aecm_core_mips.c b/webrtc/modules/audio_processing/aecm/aecm_core_mips.c index 3c2343a892..3ca9982ebf 100644 --- a/webrtc/modules/audio_processing/aecm/aecm_core_mips.c +++ b/webrtc/modules/audio_processing/aecm/aecm_core_mips.c @@ -12,7 +12,7 @@ #include <assert.h> -#include "webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h" +#include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" #include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h" static const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = { diff --git a/webrtc/modules/audio_processing/aecm/echo_control_mobile.c b/webrtc/modules/audio_processing/aecm/echo_control_mobile.c index 83781e97fe..91e6f0e80c 100644 --- a/webrtc/modules/audio_processing/aecm/echo_control_mobile.c +++ b/webrtc/modules/audio_processing/aecm/echo_control_mobile.c @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h" +#include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" #ifdef AEC_DEBUG #include <stdio.h> @@ -68,8 +68,6 @@ typedef struct // Structures RingBuffer *farendBuf; - int lastError; - AecmCore* aecmCore; } AecMobile; @@ -100,7 +98,6 @@ void* WebRtcAecm_Create() { } aecm->initFlag = 0; - aecm->lastError = 0; #ifdef AEC_DEBUG aecm->aecmCore->farFile = fopen("aecFar.pcm","wb"); @@ -151,16 +148,14 @@ int32_t WebRtcAecm_Init(void *aecmInst, int32_t sampFreq) if (sampFreq != 8000 && sampFreq != 16000) { - aecm->lastError = AECM_BAD_PARAMETER_ERROR; - return -1; + return AECM_BAD_PARAMETER_ERROR; } aecm->sampFreq = sampFreq; // Initialize AECM core if (WebRtcAecm_InitCore(aecm->aecmCore, aecm->sampFreq) == -1) { - aecm->lastError = AECM_UNSPECIFIED_ERROR; - return -1; + return AECM_UNSPECIFIED_ERROR; } // Initialize farend buffer @@ -191,51 +186,53 @@ int32_t WebRtcAecm_Init(void *aecmInst, int32_t sampFreq) if (WebRtcAecm_set_config(aecm, aecConfig) == -1) { - aecm->lastError = AECM_UNSPECIFIED_ERROR; - return -1; + return AECM_UNSPECIFIED_ERROR; } return 0; } -int32_t WebRtcAecm_BufferFarend(void *aecmInst, const int16_t *farend, - size_t nrOfSamples) -{ +// Returns any error that is caused when buffering the +// farend signal. +int32_t WebRtcAecm_GetBufferFarendError(void *aecmInst, const int16_t *farend, + size_t nrOfSamples) { AecMobile* aecm = aecmInst; - int32_t retVal = 0; - if (aecm == NULL) - { - return -1; - } + if (aecm == NULL) + return -1; - if (farend == NULL) - { - aecm->lastError = AECM_NULL_POINTER_ERROR; - return -1; - } + if (farend == NULL) + return AECM_NULL_POINTER_ERROR; - if (aecm->initFlag != kInitCheck) - { - aecm->lastError = AECM_UNINITIALIZED_ERROR; - return -1; - } + if (aecm->initFlag != kInitCheck) + return AECM_UNINITIALIZED_ERROR; - if (nrOfSamples != 80 && nrOfSamples != 160) - { - aecm->lastError = AECM_BAD_PARAMETER_ERROR; - return -1; - } + if (nrOfSamples != 80 && nrOfSamples != 160) + return AECM_BAD_PARAMETER_ERROR; - // TODO: Is this really a good idea? - if (!aecm->ECstartup) - { - WebRtcAecm_DelayComp(aecm); - } + return 0; +} - WebRtc_WriteBuffer(aecm->farendBuf, farend, nrOfSamples); - return retVal; +int32_t WebRtcAecm_BufferFarend(void *aecmInst, const int16_t *farend, + size_t nrOfSamples) { + AecMobile* aecm = aecmInst; + + const int32_t err = + WebRtcAecm_GetBufferFarendError(aecmInst, farend, nrOfSamples); + + if (err != 0) + return err; + + // TODO(unknown): Is this really a good idea? + if (!aecm->ECstartup) + { + WebRtcAecm_DelayComp(aecm); + } + + WebRtc_WriteBuffer(aecm->farendBuf, farend, nrOfSamples); + + return 0; } int32_t WebRtcAecm_Process(void *aecmInst, const int16_t *nearendNoisy, @@ -259,38 +256,32 @@ int32_t WebRtcAecm_Process(void *aecmInst, const int16_t *nearendNoisy, if (nearendNoisy == NULL) { - aecm->lastError = AECM_NULL_POINTER_ERROR; - return -1; + return AECM_NULL_POINTER_ERROR; } if (out == NULL) { - aecm->lastError = AECM_NULL_POINTER_ERROR; - return -1; + return AECM_NULL_POINTER_ERROR; } if (aecm->initFlag != kInitCheck) { - aecm->lastError = AECM_UNINITIALIZED_ERROR; - return -1; + return AECM_UNINITIALIZED_ERROR; } if (nrOfSamples != 80 && nrOfSamples != 160) { - aecm->lastError = AECM_BAD_PARAMETER_ERROR; - return -1; + return AECM_BAD_PARAMETER_ERROR; } if (msInSndCardBuf < 0) { msInSndCardBuf = 0; - aecm->lastError = AECM_BAD_PARAMETER_WARNING; - retVal = -1; + retVal = AECM_BAD_PARAMETER_WARNING; } else if (msInSndCardBuf > 500) { msInSndCardBuf = 500; - aecm->lastError = AECM_BAD_PARAMETER_WARNING; - retVal = -1; + retVal = AECM_BAD_PARAMETER_WARNING; } msInSndCardBuf += 10; aecm->msInSndCardBuf = msInSndCardBuf; @@ -453,21 +444,18 @@ int32_t WebRtcAecm_set_config(void *aecmInst, AecmConfig config) if (aecm->initFlag != kInitCheck) { - aecm->lastError = AECM_UNINITIALIZED_ERROR; - return -1; + return AECM_UNINITIALIZED_ERROR; } if (config.cngMode != AecmFalse && config.cngMode != AecmTrue) { - aecm->lastError = AECM_BAD_PARAMETER_ERROR; - return -1; + return AECM_BAD_PARAMETER_ERROR; } aecm->aecmCore->cngMode = config.cngMode; if (config.echoMode < 0 || config.echoMode > 4) { - aecm->lastError = AECM_BAD_PARAMETER_ERROR; - return -1; + return AECM_BAD_PARAMETER_ERROR; } aecm->echoMode = config.echoMode; @@ -524,33 +512,6 @@ int32_t WebRtcAecm_set_config(void *aecmInst, AecmConfig config) return 0; } -int32_t WebRtcAecm_get_config(void *aecmInst, AecmConfig *config) -{ - AecMobile* aecm = aecmInst; - - if (aecm == NULL) - { - return -1; - } - - if (config == NULL) - { - aecm->lastError = AECM_NULL_POINTER_ERROR; - return -1; - } - - if (aecm->initFlag != kInitCheck) - { - aecm->lastError = AECM_UNINITIALIZED_ERROR; - return -1; - } - - config->cngMode = aecm->aecmCore->cngMode; - config->echoMode = aecm->echoMode; - - return 0; -} - int32_t WebRtcAecm_InitEchoPath(void* aecmInst, const void* echo_path, size_t size_bytes) @@ -562,19 +523,16 @@ int32_t WebRtcAecm_InitEchoPath(void* aecmInst, return -1; } if (echo_path == NULL) { - aecm->lastError = AECM_NULL_POINTER_ERROR; - return -1; + return AECM_NULL_POINTER_ERROR; } if (size_bytes != WebRtcAecm_echo_path_size_bytes()) { // Input channel size does not match the size of AECM - aecm->lastError = AECM_BAD_PARAMETER_ERROR; - return -1; + return AECM_BAD_PARAMETER_ERROR; } if (aecm->initFlag != kInitCheck) { - aecm->lastError = AECM_UNINITIALIZED_ERROR; - return -1; + return AECM_UNINITIALIZED_ERROR; } WebRtcAecm_InitEchoPathCore(aecm->aecmCore, echo_path_ptr); @@ -593,19 +551,16 @@ int32_t WebRtcAecm_GetEchoPath(void* aecmInst, return -1; } if (echo_path == NULL) { - aecm->lastError = AECM_NULL_POINTER_ERROR; - return -1; + return AECM_NULL_POINTER_ERROR; } if (size_bytes != WebRtcAecm_echo_path_size_bytes()) { // Input channel size does not match the size of AECM - aecm->lastError = AECM_BAD_PARAMETER_ERROR; - return -1; + return AECM_BAD_PARAMETER_ERROR; } if (aecm->initFlag != kInitCheck) { - aecm->lastError = AECM_UNINITIALIZED_ERROR; - return -1; + return AECM_UNINITIALIZED_ERROR; } memcpy(echo_path_ptr, aecm->aecmCore->channelStored, size_bytes); @@ -617,17 +572,6 @@ size_t WebRtcAecm_echo_path_size_bytes() return (PART_LEN1 * sizeof(int16_t)); } -int32_t WebRtcAecm_get_error_code(void *aecmInst) -{ - AecMobile* aecm = aecmInst; - - if (aecm == NULL) - { - return -1; - } - - return aecm->lastError; -} static int WebRtcAecm_EstBufDelay(AecMobile* aecm, short msInSndCardBuf) { short delayNew, nSampSndCard; diff --git a/webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h b/webrtc/modules/audio_processing/aecm/echo_control_mobile.h index 7ae15c2a3d..b45ff59907 100644 --- a/webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h +++ b/webrtc/modules/audio_processing/aecm/echo_control_mobile.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AECM_INCLUDE_ECHO_CONTROL_MOBILE_H_ -#define WEBRTC_MODULES_AUDIO_PROCESSING_AECM_INCLUDE_ECHO_CONTROL_MOBILE_H_ +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AECM_ECHO_CONTROL_MOBILE_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_AECM_ECHO_CONTROL_MOBILE_H_ #include <stdlib.h> @@ -66,7 +66,7 @@ void WebRtcAecm_Free(void* aecmInst); * Outputs Description * ------------------------------------------------------------------- * int32_t return 0: OK - * -1: error + * 1200-12004,12100: error/warning */ int32_t WebRtcAecm_Init(void* aecmInst, int32_t sampFreq); @@ -83,13 +83,32 @@ int32_t WebRtcAecm_Init(void* aecmInst, int32_t sampFreq); * Outputs Description * ------------------------------------------------------------------- * int32_t return 0: OK - * -1: error + * 1200-12004,12100: error/warning */ int32_t WebRtcAecm_BufferFarend(void* aecmInst, const int16_t* farend, size_t nrOfSamples); /* + * Reports any errors that would arise when buffering a farend buffer. + * + * Inputs Description + * ------------------------------------------------------------------- + * void* aecmInst Pointer to the AECM instance + * int16_t* farend In buffer containing one frame of + * farend signal + * int16_t nrOfSamples Number of samples in farend buffer + * + * Outputs Description + * ------------------------------------------------------------------- + * int32_t return 0: OK + * 1200-12004,12100: error/warning + */ +int32_t WebRtcAecm_GetBufferFarendError(void* aecmInst, + const int16_t* farend, + size_t nrOfSamples); + +/* * Runs the AECM on an 80 or 160 sample blocks of data. * * Inputs Description @@ -112,7 +131,7 @@ int32_t WebRtcAecm_BufferFarend(void* aecmInst, * ------------------------------------------------------------------- * int16_t* out Out buffer, one frame of processed nearend * int32_t return 0: OK - * -1: error + * 1200-12004,12100: error/warning */ int32_t WebRtcAecm_Process(void* aecmInst, const int16_t* nearendNoisy, @@ -133,27 +152,11 @@ int32_t WebRtcAecm_Process(void* aecmInst, * Outputs Description * ------------------------------------------------------------------- * int32_t return 0: OK - * -1: error + * 1200-12004,12100: error/warning */ int32_t WebRtcAecm_set_config(void* aecmInst, AecmConfig config); /* - * This function enables the user to set certain parameters on-the-fly - * - * Inputs Description - * ------------------------------------------------------------------- - * void* aecmInst Pointer to the AECM instance - * - * Outputs Description - * ------------------------------------------------------------------- - * AecmConfig* config Pointer to the config instance that - * all properties will be written to - * int32_t return 0: OK - * -1: error - */ -int32_t WebRtcAecm_get_config(void *aecmInst, AecmConfig *config); - -/* * This function enables the user to set the echo path on-the-fly. * * Inputs Description @@ -165,7 +168,7 @@ int32_t WebRtcAecm_get_config(void *aecmInst, AecmConfig *config); * Outputs Description * ------------------------------------------------------------------- * int32_t return 0: OK - * -1: error + * 1200-12004,12100: error/warning */ int32_t WebRtcAecm_InitEchoPath(void* aecmInst, const void* echo_path, @@ -184,7 +187,7 @@ int32_t WebRtcAecm_InitEchoPath(void* aecmInst, * Outputs Description * ------------------------------------------------------------------- * int32_t return 0: OK - * -1: error + * 1200-12004,12100: error/warning */ int32_t WebRtcAecm_GetEchoPath(void* aecmInst, void* echo_path, @@ -199,20 +202,8 @@ int32_t WebRtcAecm_GetEchoPath(void* aecmInst, */ size_t WebRtcAecm_echo_path_size_bytes(); -/* - * Gets the last error code. - * - * Inputs Description - * ------------------------------------------------------------------- - * void* aecmInst Pointer to the AECM instance - * - * Outputs Description - * ------------------------------------------------------------------- - * int32_t return 11000-11100: error code - */ -int32_t WebRtcAecm_get_error_code(void *aecmInst); #ifdef __cplusplus } #endif -#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AECM_INCLUDE_ECHO_CONTROL_MOBILE_H_ +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AECM_ECHO_CONTROL_MOBILE_H_ |