diff --git a/webrtc/modules/audio_processing/aec/echo_cancellation.c b/webrtc/modules/audio_processing/aec/echo_cancellation.c index 0f5cd31ddb..175ef3d798 100644 --- a/webrtc/modules/audio_processing/aec/echo_cancellation.c +++ b/webrtc/modules/audio_processing/aec/echo_cancellation.c @@ -146,7 +146,6 @@ void* WebRtcAec_Create() { } aecpc->initFlag = 0; - aecpc->lastError = 0; #ifdef WEBRTC_AEC_DEBUG_DUMP { @@ -192,26 +191,22 @@ int32_t WebRtcAec_Init(void* aecInst, int32_t sampFreq, int32_t scSampFreq) { sampFreq != 16000 && sampFreq != 32000 && sampFreq != 48000) { - aecpc->lastError = AEC_BAD_PARAMETER_ERROR; - return -1; + return AEC_BAD_PARAMETER_ERROR; } aecpc->sampFreq = sampFreq; if (scSampFreq < 1 || scSampFreq > 96000) { - aecpc->lastError = AEC_BAD_PARAMETER_ERROR; - return -1; + return AEC_BAD_PARAMETER_ERROR; } aecpc->scSampFreq = scSampFreq; // Initialize echo canceller core if (WebRtcAec_InitAec(aecpc->aec, aecpc->sampFreq) == -1) { - aecpc->lastError = AEC_UNSPECIFIED_ERROR; - return -1; + return AEC_UNSPECIFIED_ERROR; } if (WebRtcAec_InitResampler(aecpc->resampler, aecpc->scSampFreq) == -1) { - aecpc->lastError = AEC_UNSPECIFIED_ERROR; - return -1; + return AEC_UNSPECIFIED_ERROR; } WebRtc_InitBuffer(aecpc->far_pre_buf); @@ -261,13 +256,32 @@ int32_t WebRtcAec_Init(void* aecInst, int32_t sampFreq, int32_t scSampFreq) { aecConfig.delay_logging = kAecFalse; if (WebRtcAec_set_config(aecpc, aecConfig) == -1) { - aecpc->lastError = AEC_UNSPECIFIED_ERROR; - return -1; + return AEC_UNSPECIFIED_ERROR; } return 0; } +// Returns any error that is caused when buffering the +// far-end signal. +int32_t WebRtcAec_GetBufferFarendError(void* aecInst, + const float* farend, + size_t nrOfSamples) { + Aec* aecpc = aecInst; + + if (!farend) + return AEC_NULL_POINTER_ERROR; + + if (aecpc->initFlag != initCheck) + return AEC_UNINITIALIZED_ERROR; + + // number of samples == 160 for SWB input + if (nrOfSamples != 80 && nrOfSamples != 160) + return AEC_BAD_PARAMETER_ERROR; + + return 0; +} + // only buffer L band for farend int32_t WebRtcAec_BufferFarend(void* aecInst, const float* farend, @@ -277,21 +291,13 @@ int32_t WebRtcAec_BufferFarend(void* aecInst, float new_farend[MAX_RESAMP_LEN]; const float* farend_ptr = farend; - if (farend == NULL) { - aecpc->lastError = AEC_NULL_POINTER_ERROR; - return -1; - } + // Get any error caused by buffering the farend signal. + int32_t error_code = WebRtcAec_GetBufferFarendError(aecInst, farend, + nrOfSamples); - if (aecpc->initFlag != initCheck) { - aecpc->lastError = AEC_UNINITIALIZED_ERROR; - return -1; - } + if (error_code != 0) + return error_code; - // number of samples == 160 for SWB input - if (nrOfSamples != 80 && nrOfSamples != 160) { - aecpc->lastError = AEC_BAD_PARAMETER_ERROR; - return -1; - } if (aecpc->skewMode == kAecTrue && aecpc->resample == kAecTrue) { // Resample and get a new number of samples @@ -343,29 +349,24 @@ int32_t WebRtcAec_Process(void* aecInst, int32_t retVal = 0; if (out == NULL) { - aecpc->lastError = AEC_NULL_POINTER_ERROR; - return -1; + return AEC_NULL_POINTER_ERROR; } if (aecpc->initFlag != initCheck) { - aecpc->lastError = AEC_UNINITIALIZED_ERROR; - return -1; + return AEC_UNINITIALIZED_ERROR; } // number of samples == 160 for SWB input if (nrOfSamples != 80 && nrOfSamples != 160) { - aecpc->lastError = AEC_BAD_PARAMETER_ERROR; - return -1; + return AEC_BAD_PARAMETER_ERROR; } if (msInSndCardBuf < 0) { msInSndCardBuf = 0; - aecpc->lastError = AEC_BAD_PARAMETER_WARNING; - retVal = -1; + retVal = AEC_BAD_PARAMETER_WARNING; } else if (msInSndCardBuf > kMaxTrustedDelayMs) { // The clamping is now done in ProcessExtended/Normal(). - aecpc->lastError = AEC_BAD_PARAMETER_WARNING; - retVal = -1; + retVal = AEC_BAD_PARAMETER_WARNING; } // This returns the value of aec->extended_filter_enabled. @@ -378,15 +379,13 @@ int32_t WebRtcAec_Process(void* aecInst, msInSndCardBuf, skew); } else { - if (ProcessNormal(aecpc, - nearend, - num_bands, - out, - nrOfSamples, - msInSndCardBuf, - skew) != 0) { - retVal = -1; - } + retVal = ProcessNormal(aecpc, + nearend, + num_bands, + out, + nrOfSamples, + msInSndCardBuf, + skew); } #ifdef WEBRTC_AEC_DEBUG_DUMP @@ -405,31 +404,26 @@ int32_t WebRtcAec_Process(void* aecInst, int WebRtcAec_set_config(void* handle, AecConfig config) { Aec* self = (Aec*)handle; if (self->initFlag != initCheck) { - self->lastError = AEC_UNINITIALIZED_ERROR; - return -1; + return AEC_UNINITIALIZED_ERROR; } if (config.skewMode != kAecFalse && config.skewMode != kAecTrue) { - self->lastError = AEC_BAD_PARAMETER_ERROR; - return -1; + return AEC_BAD_PARAMETER_ERROR; } self->skewMode = config.skewMode; if (config.nlpMode != kAecNlpConservative && config.nlpMode != kAecNlpModerate && config.nlpMode != kAecNlpAggressive) { - self->lastError = AEC_BAD_PARAMETER_ERROR; - return -1; + return AEC_BAD_PARAMETER_ERROR; } if (config.metricsMode != kAecFalse && config.metricsMode != kAecTrue) { - self->lastError = AEC_BAD_PARAMETER_ERROR; - return -1; + return AEC_BAD_PARAMETER_ERROR; } if (config.delay_logging != kAecFalse && config.delay_logging != kAecTrue) { - self->lastError = AEC_BAD_PARAMETER_ERROR; - return -1; + return AEC_BAD_PARAMETER_ERROR; } WebRtcAec_SetConfigCore( @@ -440,12 +434,10 @@ int WebRtcAec_set_config(void* handle, AecConfig config) { int WebRtcAec_get_echo_status(void* handle, int* status) { Aec* self = (Aec*)handle; if (status == NULL) { - self->lastError = AEC_NULL_POINTER_ERROR; - return -1; + return AEC_NULL_POINTER_ERROR; } if (self->initFlag != initCheck) { - self->lastError = AEC_UNINITIALIZED_ERROR; - return -1; + return AEC_UNINITIALIZED_ERROR; } *status = WebRtcAec_echo_state(self->aec); @@ -466,12 +458,10 @@ int WebRtcAec_GetMetrics(void* handle, AecMetrics* metrics) { return -1; } if (metrics == NULL) { - self->lastError = AEC_NULL_POINTER_ERROR; - return -1; + return AEC_NULL_POINTER_ERROR; } if (self->initFlag != initCheck) { - self->lastError = AEC_UNINITIALIZED_ERROR; - return -1; + return AEC_UNINITIALIZED_ERROR; } WebRtcAec_GetEchoStats(self->aec, &erl, &erle, &a_nlp); @@ -556,32 +546,24 @@ int WebRtcAec_GetDelayMetrics(void* handle, float* fraction_poor_delays) { Aec* self = handle; if (median == NULL) { - self->lastError = AEC_NULL_POINTER_ERROR; - return -1; + return AEC_NULL_POINTER_ERROR; } if (std == NULL) { - self->lastError = AEC_NULL_POINTER_ERROR; - return -1; + return AEC_NULL_POINTER_ERROR; } if (self->initFlag != initCheck) { - self->lastError = AEC_UNINITIALIZED_ERROR; - return -1; + return AEC_UNINITIALIZED_ERROR; } if (WebRtcAec_GetDelayMetricsCore(self->aec, median, std, fraction_poor_delays) == -1) { // Logging disabled. - self->lastError = AEC_UNSUPPORTED_FUNCTION_ERROR; - return -1; + return AEC_UNSUPPORTED_FUNCTION_ERROR; } return 0; } -int32_t WebRtcAec_get_error_code(void* aecInst) { - Aec* aecpc = aecInst; - return aecpc->lastError; -} AecCore* WebRtcAec_aec_core(void* handle) { if (!handle) { @@ -617,7 +599,7 @@ static int ProcessNormal(Aec* aecpc, retVal = WebRtcAec_GetSkew(aecpc->resampler, skew, &aecpc->skew); if (retVal == -1) { aecpc->skew = 0; - aecpc->lastError = AEC_BAD_PARAMETER_WARNING; + retVal = AEC_BAD_PARAMETER_WARNING; } aecpc->skew /= aecpc->sampFactor * nrOfSamples; diff --git a/webrtc/modules/audio_processing/aec/echo_cancellation_internal.h b/webrtc/modules/audio_processing/aec/echo_cancellation_internal.h index 95a6cf3324..e87219f33d 100644 --- a/webrtc/modules/audio_processing/aec/echo_cancellation_internal.h +++ b/webrtc/modules/audio_processing/aec/echo_cancellation_internal.h @@ -57,8 +57,6 @@ typedef struct { RingBuffer* far_pre_buf; // Time domain far-end pre-buffer. - int lastError; - int farend_started; AecCore* aec; diff --git a/webrtc/modules/audio_processing/aec/include/echo_cancellation.h b/webrtc/modules/audio_processing/aec/include/echo_cancellation.h index a340cf84d0..90a248f0b6 100644 --- a/webrtc/modules/audio_processing/aec/include/echo_cancellation.h +++ b/webrtc/modules/audio_processing/aec/include/echo_cancellation.h @@ -109,12 +109,31 @@ int32_t WebRtcAec_Init(void* aecInst, int32_t sampFreq, int32_t scSampFreq); * Outputs Description * ------------------------------------------------------------------- * int32_t return 0: OK - * -1: error + * 12000-12050: error code */ int32_t WebRtcAec_BufferFarend(void* aecInst, const float* farend, size_t nrOfSamples); +/* + * Reports any errors that would arise if buffering a farend buffer + * + * Inputs Description + * ------------------------------------------------------------------- + * void* aecInst Pointer to the AEC instance + * const float* farend In buffer containing one frame of + * farend signal for L band + * int16_t nrOfSamples Number of samples in farend buffer + * + * Outputs Description + * ------------------------------------------------------------------- + * int32_t return 0: OK + * 12000-12050: error code + */ +int32_t WebRtcAec_GetBufferFarendError(void* aecInst, + const float* farend, + size_t nrOfSamples); + /* * Runs the echo canceller on an 80 or 160 sample blocks of data. * @@ -136,7 +155,7 @@ int32_t WebRtcAec_BufferFarend(void* aecInst, * float* const* out Out buffer, one frame of processed nearend * for each band * int32_t return 0: OK - * -1: error + * 12000-12050: error code */ int32_t WebRtcAec_Process(void* aecInst, const float* const* nearend, @@ -157,8 +176,8 @@ int32_t WebRtcAec_Process(void* aecInst, * * Outputs Description * ------------------------------------------------------------------- - * int return 0: OK - * -1: error + * int return 0: OK + * 12000-12050: error code */ int WebRtcAec_set_config(void* handle, AecConfig config); @@ -173,8 +192,8 @@ int WebRtcAec_set_config(void* handle, AecConfig config); * ------------------------------------------------------------------- * int* status 0: Almost certainly nearend single-talk * 1: Might not be neared single-talk - * int return 0: OK - * -1: error + * int return 0: OK + * 12000-12050: error code */ int WebRtcAec_get_echo_status(void* handle, int* status); @@ -189,8 +208,8 @@ int WebRtcAec_get_echo_status(void* handle, int* status); * ------------------------------------------------------------------- * AecMetrics* metrics Struct which will be filled out with the * current echo metrics. - * int return 0: OK - * -1: error + * int return 0: OK + * 12000-12050: error code */ int WebRtcAec_GetMetrics(void* handle, AecMetrics* metrics); @@ -208,27 +227,14 @@ int WebRtcAec_GetMetrics(void* handle, AecMetrics* metrics); * float* fraction_poor_delays Fraction of the delay estimates that may * cause the AEC to perform poorly. * - * int return 0: OK - * -1: error + * int return 0: OK + * 12000-12050: error code */ int WebRtcAec_GetDelayMetrics(void* handle, int* median, int* std, float* fraction_poor_delays); -/* - * Gets the last error code. - * - * Inputs Description - * ------------------------------------------------------------------- - * void* aecInst Pointer to the AEC instance - * - * Outputs Description - * ------------------------------------------------------------------- - * int32_t return 11000-11100: error code - */ -int32_t WebRtcAec_get_error_code(void* aecInst); - // Returns a pointer to the low level AEC handle. // // Input: diff --git a/webrtc/modules/audio_processing/aecm/echo_control_mobile.c b/webrtc/modules/audio_processing/aecm/echo_control_mobile.c index 83781e97fe..f59cd125f2 100644 --- a/webrtc/modules/audio_processing/aecm/echo_control_mobile.c +++ b/webrtc/modules/audio_processing/aecm/echo_control_mobile.c @@ -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/include/echo_control_mobile.h index 7ae15c2a3d..b29f078bf7 100644 --- a/webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h +++ b/webrtc/modules/audio_processing/aecm/include/echo_control_mobile.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,12 +83,31 @@ 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. * @@ -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,26 +152,10 @@ 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. * @@ -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,18 +202,6 @@ 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 } diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.cc b/webrtc/modules/audio_processing/echo_cancellation_impl.cc index 56ee9e0fff..0de5e620ce 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.cc +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.cc @@ -94,7 +94,7 @@ int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) { audio->num_frames_per_band()); if (err != apm_->kNoError) { - return GetHandleError(my_handle); // TODO(ajm): warning possible? + return MapError(err); // TODO(ajm): warning possible? } handle_index++; @@ -138,7 +138,7 @@ int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio) { stream_drift_samples_); if (err != apm_->kNoError) { - err = GetHandleError(my_handle); + err = MapError(err); // TODO(ajm): Figure out how to return warnings properly. if (err != apm_->kBadStreamParameterWarning) { return err; @@ -148,7 +148,7 @@ int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio) { int status = 0; err = WebRtcAec_get_echo_status(my_handle, &status); if (err != apm_->kNoError) { - return GetHandleError(my_handle); + return MapError(err); } if (status == 1) { @@ -240,7 +240,7 @@ int EchoCancellationImpl::GetMetrics(Metrics* metrics) { Handle* my_handle = static_cast(handle(0)); int err = WebRtcAec_GetMetrics(my_handle, &my_metrics); if (err != apm_->kNoError) { - return GetHandleError(my_handle); + return MapError(err); } metrics->residual_echo_return_loss.instant = my_metrics.rerl.instant; @@ -309,9 +309,10 @@ int EchoCancellationImpl::GetDelayMetrics(int* median, int* std, } Handle* my_handle = static_cast(handle(0)); - if (WebRtcAec_GetDelayMetrics(my_handle, median, std, fraction_poor_delays) != - apm_->kNoError) { - return GetHandleError(my_handle); + const int err = + WebRtcAec_GetDelayMetrics(my_handle, median, std, fraction_poor_delays); + if (err != apm_->kNoError) { + return MapError(err); } return apm_->kNoError; @@ -384,6 +385,6 @@ int EchoCancellationImpl::num_handles_required() const { int EchoCancellationImpl::GetHandleError(void* handle) const { assert(handle != NULL); - return MapError(WebRtcAec_get_error_code(static_cast(handle))); + return AudioProcessing::kUnspecifiedError; } } // namespace webrtc diff --git a/webrtc/modules/audio_processing/echo_control_mobile_impl.cc b/webrtc/modules/audio_processing/echo_control_mobile_impl.cc index 954aac7d4a..7466d006d8 100644 --- a/webrtc/modules/audio_processing/echo_control_mobile_impl.cc +++ b/webrtc/modules/audio_processing/echo_control_mobile_impl.cc @@ -40,22 +40,6 @@ int16_t MapSetting(EchoControlMobile::RoutingMode mode) { return -1; } -AudioProcessing::Error MapError(int err) { - switch (err) { - case AECM_UNSUPPORTED_FUNCTION_ERROR: - return AudioProcessing::kUnsupportedFunctionError; - case AECM_NULL_POINTER_ERROR: - return AudioProcessing::kNullPointerError; - case AECM_BAD_PARAMETER_ERROR: - return AudioProcessing::kBadParameterError; - case AECM_BAD_PARAMETER_WARNING: - return AudioProcessing::kBadStreamParameterWarning; - default: - // AECM_UNSPECIFIED_ERROR - // AECM_UNINITIALIZED_ERROR - return AudioProcessing::kUnspecifiedError; - } -} } // namespace size_t EchoControlMobile::echo_path_size_bytes() { @@ -289,6 +273,6 @@ int EchoControlMobileImpl::num_handles_required() const { int EchoControlMobileImpl::GetHandleError(void* handle) const { assert(handle != NULL); - return MapError(WebRtcAecm_get_error_code(static_cast(handle))); + return AudioProcessing::kUnspecifiedError; } } // namespace webrtc