-Removed the indirect error message reporting in aec and aecm.

-Made the component error messages generic to be an unspecified error message.

BUG=webrtc:5099

Review URL: https://codereview.webrtc.org/1404743003

Cr-Commit-Position: refs/heads/master@{#10570}
This commit is contained in:
peah
2015-11-09 23:53:50 -08:00
committed by Commit bot
parent 952892a28a
commit c12be3984f
7 changed files with 171 additions and 265 deletions

View File

@ -146,7 +146,6 @@ void* WebRtcAec_Create() {
} }
aecpc->initFlag = 0; aecpc->initFlag = 0;
aecpc->lastError = 0;
#ifdef WEBRTC_AEC_DEBUG_DUMP #ifdef WEBRTC_AEC_DEBUG_DUMP
{ {
@ -192,26 +191,22 @@ int32_t WebRtcAec_Init(void* aecInst, int32_t sampFreq, int32_t scSampFreq) {
sampFreq != 16000 && sampFreq != 16000 &&
sampFreq != 32000 && sampFreq != 32000 &&
sampFreq != 48000) { sampFreq != 48000) {
aecpc->lastError = AEC_BAD_PARAMETER_ERROR; return AEC_BAD_PARAMETER_ERROR;
return -1;
} }
aecpc->sampFreq = sampFreq; aecpc->sampFreq = sampFreq;
if (scSampFreq < 1 || scSampFreq > 96000) { if (scSampFreq < 1 || scSampFreq > 96000) {
aecpc->lastError = AEC_BAD_PARAMETER_ERROR; return AEC_BAD_PARAMETER_ERROR;
return -1;
} }
aecpc->scSampFreq = scSampFreq; aecpc->scSampFreq = scSampFreq;
// Initialize echo canceller core // Initialize echo canceller core
if (WebRtcAec_InitAec(aecpc->aec, aecpc->sampFreq) == -1) { if (WebRtcAec_InitAec(aecpc->aec, aecpc->sampFreq) == -1) {
aecpc->lastError = AEC_UNSPECIFIED_ERROR; return AEC_UNSPECIFIED_ERROR;
return -1;
} }
if (WebRtcAec_InitResampler(aecpc->resampler, aecpc->scSampFreq) == -1) { if (WebRtcAec_InitResampler(aecpc->resampler, aecpc->scSampFreq) == -1) {
aecpc->lastError = AEC_UNSPECIFIED_ERROR; return AEC_UNSPECIFIED_ERROR;
return -1;
} }
WebRtc_InitBuffer(aecpc->far_pre_buf); 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; aecConfig.delay_logging = kAecFalse;
if (WebRtcAec_set_config(aecpc, aecConfig) == -1) { if (WebRtcAec_set_config(aecpc, aecConfig) == -1) {
aecpc->lastError = AEC_UNSPECIFIED_ERROR; return AEC_UNSPECIFIED_ERROR;
return -1;
} }
return 0; 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 // only buffer L band for farend
int32_t WebRtcAec_BufferFarend(void* aecInst, int32_t WebRtcAec_BufferFarend(void* aecInst,
const float* farend, const float* farend,
@ -277,21 +291,13 @@ int32_t WebRtcAec_BufferFarend(void* aecInst,
float new_farend[MAX_RESAMP_LEN]; float new_farend[MAX_RESAMP_LEN];
const float* farend_ptr = farend; const float* farend_ptr = farend;
if (farend == NULL) { // Get any error caused by buffering the farend signal.
aecpc->lastError = AEC_NULL_POINTER_ERROR; int32_t error_code = WebRtcAec_GetBufferFarendError(aecInst, farend,
return -1; nrOfSamples);
}
if (aecpc->initFlag != initCheck) { if (error_code != 0)
aecpc->lastError = AEC_UNINITIALIZED_ERROR; return error_code;
return -1;
}
// 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) { if (aecpc->skewMode == kAecTrue && aecpc->resample == kAecTrue) {
// Resample and get a new number of samples // Resample and get a new number of samples
@ -343,29 +349,24 @@ int32_t WebRtcAec_Process(void* aecInst,
int32_t retVal = 0; int32_t retVal = 0;
if (out == NULL) { if (out == NULL) {
aecpc->lastError = AEC_NULL_POINTER_ERROR; return AEC_NULL_POINTER_ERROR;
return -1;
} }
if (aecpc->initFlag != initCheck) { if (aecpc->initFlag != initCheck) {
aecpc->lastError = AEC_UNINITIALIZED_ERROR; return AEC_UNINITIALIZED_ERROR;
return -1;
} }
// number of samples == 160 for SWB input // number of samples == 160 for SWB input
if (nrOfSamples != 80 && nrOfSamples != 160) { if (nrOfSamples != 80 && nrOfSamples != 160) {
aecpc->lastError = AEC_BAD_PARAMETER_ERROR; return AEC_BAD_PARAMETER_ERROR;
return -1;
} }
if (msInSndCardBuf < 0) { if (msInSndCardBuf < 0) {
msInSndCardBuf = 0; msInSndCardBuf = 0;
aecpc->lastError = AEC_BAD_PARAMETER_WARNING; retVal = AEC_BAD_PARAMETER_WARNING;
retVal = -1;
} else if (msInSndCardBuf > kMaxTrustedDelayMs) { } else if (msInSndCardBuf > kMaxTrustedDelayMs) {
// The clamping is now done in ProcessExtended/Normal(). // The clamping is now done in ProcessExtended/Normal().
aecpc->lastError = AEC_BAD_PARAMETER_WARNING; retVal = AEC_BAD_PARAMETER_WARNING;
retVal = -1;
} }
// This returns the value of aec->extended_filter_enabled. // This returns the value of aec->extended_filter_enabled.
@ -378,15 +379,13 @@ int32_t WebRtcAec_Process(void* aecInst,
msInSndCardBuf, msInSndCardBuf,
skew); skew);
} else { } else {
if (ProcessNormal(aecpc, retVal = ProcessNormal(aecpc,
nearend, nearend,
num_bands, num_bands,
out, out,
nrOfSamples, nrOfSamples,
msInSndCardBuf, msInSndCardBuf,
skew) != 0) { skew);
retVal = -1;
}
} }
#ifdef WEBRTC_AEC_DEBUG_DUMP #ifdef WEBRTC_AEC_DEBUG_DUMP
@ -405,31 +404,26 @@ int32_t WebRtcAec_Process(void* aecInst,
int WebRtcAec_set_config(void* handle, AecConfig config) { int WebRtcAec_set_config(void* handle, AecConfig config) {
Aec* self = (Aec*)handle; Aec* self = (Aec*)handle;
if (self->initFlag != initCheck) { if (self->initFlag != initCheck) {
self->lastError = AEC_UNINITIALIZED_ERROR; return AEC_UNINITIALIZED_ERROR;
return -1;
} }
if (config.skewMode != kAecFalse && config.skewMode != kAecTrue) { if (config.skewMode != kAecFalse && config.skewMode != kAecTrue) {
self->lastError = AEC_BAD_PARAMETER_ERROR; return AEC_BAD_PARAMETER_ERROR;
return -1;
} }
self->skewMode = config.skewMode; self->skewMode = config.skewMode;
if (config.nlpMode != kAecNlpConservative && if (config.nlpMode != kAecNlpConservative &&
config.nlpMode != kAecNlpModerate && config.nlpMode != kAecNlpModerate &&
config.nlpMode != kAecNlpAggressive) { config.nlpMode != kAecNlpAggressive) {
self->lastError = AEC_BAD_PARAMETER_ERROR; return AEC_BAD_PARAMETER_ERROR;
return -1;
} }
if (config.metricsMode != kAecFalse && config.metricsMode != kAecTrue) { if (config.metricsMode != kAecFalse && config.metricsMode != kAecTrue) {
self->lastError = AEC_BAD_PARAMETER_ERROR; return AEC_BAD_PARAMETER_ERROR;
return -1;
} }
if (config.delay_logging != kAecFalse && config.delay_logging != kAecTrue) { if (config.delay_logging != kAecFalse && config.delay_logging != kAecTrue) {
self->lastError = AEC_BAD_PARAMETER_ERROR; return AEC_BAD_PARAMETER_ERROR;
return -1;
} }
WebRtcAec_SetConfigCore( WebRtcAec_SetConfigCore(
@ -440,12 +434,10 @@ int WebRtcAec_set_config(void* handle, AecConfig config) {
int WebRtcAec_get_echo_status(void* handle, int* status) { int WebRtcAec_get_echo_status(void* handle, int* status) {
Aec* self = (Aec*)handle; Aec* self = (Aec*)handle;
if (status == NULL) { if (status == NULL) {
self->lastError = AEC_NULL_POINTER_ERROR; return AEC_NULL_POINTER_ERROR;
return -1;
} }
if (self->initFlag != initCheck) { if (self->initFlag != initCheck) {
self->lastError = AEC_UNINITIALIZED_ERROR; return AEC_UNINITIALIZED_ERROR;
return -1;
} }
*status = WebRtcAec_echo_state(self->aec); *status = WebRtcAec_echo_state(self->aec);
@ -466,12 +458,10 @@ int WebRtcAec_GetMetrics(void* handle, AecMetrics* metrics) {
return -1; return -1;
} }
if (metrics == NULL) { if (metrics == NULL) {
self->lastError = AEC_NULL_POINTER_ERROR; return AEC_NULL_POINTER_ERROR;
return -1;
} }
if (self->initFlag != initCheck) { if (self->initFlag != initCheck) {
self->lastError = AEC_UNINITIALIZED_ERROR; return AEC_UNINITIALIZED_ERROR;
return -1;
} }
WebRtcAec_GetEchoStats(self->aec, &erl, &erle, &a_nlp); WebRtcAec_GetEchoStats(self->aec, &erl, &erle, &a_nlp);
@ -556,32 +546,24 @@ int WebRtcAec_GetDelayMetrics(void* handle,
float* fraction_poor_delays) { float* fraction_poor_delays) {
Aec* self = handle; Aec* self = handle;
if (median == NULL) { if (median == NULL) {
self->lastError = AEC_NULL_POINTER_ERROR; return AEC_NULL_POINTER_ERROR;
return -1;
} }
if (std == NULL) { if (std == NULL) {
self->lastError = AEC_NULL_POINTER_ERROR; return AEC_NULL_POINTER_ERROR;
return -1;
} }
if (self->initFlag != initCheck) { if (self->initFlag != initCheck) {
self->lastError = AEC_UNINITIALIZED_ERROR; return AEC_UNINITIALIZED_ERROR;
return -1;
} }
if (WebRtcAec_GetDelayMetricsCore(self->aec, median, std, if (WebRtcAec_GetDelayMetricsCore(self->aec, median, std,
fraction_poor_delays) == fraction_poor_delays) ==
-1) { -1) {
// Logging disabled. // Logging disabled.
self->lastError = AEC_UNSUPPORTED_FUNCTION_ERROR; return AEC_UNSUPPORTED_FUNCTION_ERROR;
return -1;
} }
return 0; return 0;
} }
int32_t WebRtcAec_get_error_code(void* aecInst) {
Aec* aecpc = aecInst;
return aecpc->lastError;
}
AecCore* WebRtcAec_aec_core(void* handle) { AecCore* WebRtcAec_aec_core(void* handle) {
if (!handle) { if (!handle) {
@ -617,7 +599,7 @@ static int ProcessNormal(Aec* aecpc,
retVal = WebRtcAec_GetSkew(aecpc->resampler, skew, &aecpc->skew); retVal = WebRtcAec_GetSkew(aecpc->resampler, skew, &aecpc->skew);
if (retVal == -1) { if (retVal == -1) {
aecpc->skew = 0; aecpc->skew = 0;
aecpc->lastError = AEC_BAD_PARAMETER_WARNING; retVal = AEC_BAD_PARAMETER_WARNING;
} }
aecpc->skew /= aecpc->sampFactor * nrOfSamples; aecpc->skew /= aecpc->sampFactor * nrOfSamples;

View File

@ -57,8 +57,6 @@ typedef struct {
RingBuffer* far_pre_buf; // Time domain far-end pre-buffer. RingBuffer* far_pre_buf; // Time domain far-end pre-buffer.
int lastError;
int farend_started; int farend_started;
AecCore* aec; AecCore* aec;

View File

@ -109,12 +109,31 @@ int32_t WebRtcAec_Init(void* aecInst, int32_t sampFreq, int32_t scSampFreq);
* Outputs Description * Outputs Description
* ------------------------------------------------------------------- * -------------------------------------------------------------------
* int32_t return 0: OK * int32_t return 0: OK
* -1: error * 12000-12050: error code
*/ */
int32_t WebRtcAec_BufferFarend(void* aecInst, int32_t WebRtcAec_BufferFarend(void* aecInst,
const float* farend, const float* farend,
size_t nrOfSamples); 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. * 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 * float* const* out Out buffer, one frame of processed nearend
* for each band * for each band
* int32_t return 0: OK * int32_t return 0: OK
* -1: error * 12000-12050: error code
*/ */
int32_t WebRtcAec_Process(void* aecInst, int32_t WebRtcAec_Process(void* aecInst,
const float* const* nearend, const float* const* nearend,
@ -158,7 +177,7 @@ int32_t WebRtcAec_Process(void* aecInst,
* Outputs Description * Outputs Description
* ------------------------------------------------------------------- * -------------------------------------------------------------------
* int return 0: OK * int return 0: OK
* -1: error * 12000-12050: error code
*/ */
int WebRtcAec_set_config(void* handle, AecConfig config); int WebRtcAec_set_config(void* handle, AecConfig config);
@ -174,7 +193,7 @@ int WebRtcAec_set_config(void* handle, AecConfig config);
* int* status 0: Almost certainly nearend single-talk * int* status 0: Almost certainly nearend single-talk
* 1: Might not be neared single-talk * 1: Might not be neared single-talk
* int return 0: OK * int return 0: OK
* -1: error * 12000-12050: error code
*/ */
int WebRtcAec_get_echo_status(void* handle, int* status); int WebRtcAec_get_echo_status(void* handle, int* status);
@ -190,7 +209,7 @@ int WebRtcAec_get_echo_status(void* handle, int* status);
* AecMetrics* metrics Struct which will be filled out with the * AecMetrics* metrics Struct which will be filled out with the
* current echo metrics. * current echo metrics.
* int return 0: OK * int return 0: OK
* -1: error * 12000-12050: error code
*/ */
int WebRtcAec_GetMetrics(void* handle, AecMetrics* metrics); int WebRtcAec_GetMetrics(void* handle, AecMetrics* metrics);
@ -209,26 +228,13 @@ int WebRtcAec_GetMetrics(void* handle, AecMetrics* metrics);
* cause the AEC to perform poorly. * cause the AEC to perform poorly.
* *
* int return 0: OK * int return 0: OK
* -1: error * 12000-12050: error code
*/ */
int WebRtcAec_GetDelayMetrics(void* handle, int WebRtcAec_GetDelayMetrics(void* handle,
int* median, int* median,
int* std, int* std,
float* fraction_poor_delays); 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. // Returns a pointer to the low level AEC handle.
// //
// Input: // Input:

View File

@ -68,8 +68,6 @@ typedef struct
// Structures // Structures
RingBuffer *farendBuf; RingBuffer *farendBuf;
int lastError;
AecmCore* aecmCore; AecmCore* aecmCore;
} AecMobile; } AecMobile;
@ -100,7 +98,6 @@ void* WebRtcAecm_Create() {
} }
aecm->initFlag = 0; aecm->initFlag = 0;
aecm->lastError = 0;
#ifdef AEC_DEBUG #ifdef AEC_DEBUG
aecm->aecmCore->farFile = fopen("aecFar.pcm","wb"); 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) if (sampFreq != 8000 && sampFreq != 16000)
{ {
aecm->lastError = AECM_BAD_PARAMETER_ERROR; return AECM_BAD_PARAMETER_ERROR;
return -1;
} }
aecm->sampFreq = sampFreq; aecm->sampFreq = sampFreq;
// Initialize AECM core // Initialize AECM core
if (WebRtcAecm_InitCore(aecm->aecmCore, aecm->sampFreq) == -1) if (WebRtcAecm_InitCore(aecm->aecmCore, aecm->sampFreq) == -1)
{ {
aecm->lastError = AECM_UNSPECIFIED_ERROR; return AECM_UNSPECIFIED_ERROR;
return -1;
} }
// Initialize farend buffer // Initialize farend buffer
@ -191,43 +186,45 @@ int32_t WebRtcAecm_Init(void *aecmInst, int32_t sampFreq)
if (WebRtcAecm_set_config(aecm, aecConfig) == -1) if (WebRtcAecm_set_config(aecm, aecConfig) == -1)
{ {
aecm->lastError = AECM_UNSPECIFIED_ERROR; return AECM_UNSPECIFIED_ERROR;
return -1;
} }
return 0; return 0;
} }
int32_t WebRtcAecm_BufferFarend(void *aecmInst, const int16_t *farend, // Returns any error that is caused when buffering the
size_t nrOfSamples) // farend signal.
{ int32_t WebRtcAecm_GetBufferFarendError(void *aecmInst, const int16_t *farend,
size_t nrOfSamples) {
AecMobile* aecm = aecmInst; AecMobile* aecm = aecmInst;
int32_t retVal = 0;
if (aecm == NULL) if (aecm == NULL)
{
return -1; return -1;
}
if (farend == NULL) if (farend == NULL)
{ return AECM_NULL_POINTER_ERROR;
aecm->lastError = AECM_NULL_POINTER_ERROR;
return -1;
}
if (aecm->initFlag != kInitCheck) if (aecm->initFlag != kInitCheck)
{ return AECM_UNINITIALIZED_ERROR;
aecm->lastError = AECM_UNINITIALIZED_ERROR;
return -1;
}
if (nrOfSamples != 80 && nrOfSamples != 160) if (nrOfSamples != 80 && nrOfSamples != 160)
{ return AECM_BAD_PARAMETER_ERROR;
aecm->lastError = AECM_BAD_PARAMETER_ERROR;
return -1; return 0;
} }
// TODO: Is this really a good idea?
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) if (!aecm->ECstartup)
{ {
WebRtcAecm_DelayComp(aecm); WebRtcAecm_DelayComp(aecm);
@ -235,7 +232,7 @@ int32_t WebRtcAecm_BufferFarend(void *aecmInst, const int16_t *farend,
WebRtc_WriteBuffer(aecm->farendBuf, farend, nrOfSamples); WebRtc_WriteBuffer(aecm->farendBuf, farend, nrOfSamples);
return retVal; return 0;
} }
int32_t WebRtcAecm_Process(void *aecmInst, const int16_t *nearendNoisy, 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) if (nearendNoisy == NULL)
{ {
aecm->lastError = AECM_NULL_POINTER_ERROR; return AECM_NULL_POINTER_ERROR;
return -1;
} }
if (out == NULL) if (out == NULL)
{ {
aecm->lastError = AECM_NULL_POINTER_ERROR; return AECM_NULL_POINTER_ERROR;
return -1;
} }
if (aecm->initFlag != kInitCheck) if (aecm->initFlag != kInitCheck)
{ {
aecm->lastError = AECM_UNINITIALIZED_ERROR; return AECM_UNINITIALIZED_ERROR;
return -1;
} }
if (nrOfSamples != 80 && nrOfSamples != 160) if (nrOfSamples != 80 && nrOfSamples != 160)
{ {
aecm->lastError = AECM_BAD_PARAMETER_ERROR; return AECM_BAD_PARAMETER_ERROR;
return -1;
} }
if (msInSndCardBuf < 0) if (msInSndCardBuf < 0)
{ {
msInSndCardBuf = 0; msInSndCardBuf = 0;
aecm->lastError = AECM_BAD_PARAMETER_WARNING; retVal = AECM_BAD_PARAMETER_WARNING;
retVal = -1;
} else if (msInSndCardBuf > 500) } else if (msInSndCardBuf > 500)
{ {
msInSndCardBuf = 500; msInSndCardBuf = 500;
aecm->lastError = AECM_BAD_PARAMETER_WARNING; retVal = AECM_BAD_PARAMETER_WARNING;
retVal = -1;
} }
msInSndCardBuf += 10; msInSndCardBuf += 10;
aecm->msInSndCardBuf = msInSndCardBuf; aecm->msInSndCardBuf = msInSndCardBuf;
@ -453,21 +444,18 @@ int32_t WebRtcAecm_set_config(void *aecmInst, AecmConfig config)
if (aecm->initFlag != kInitCheck) if (aecm->initFlag != kInitCheck)
{ {
aecm->lastError = AECM_UNINITIALIZED_ERROR; return AECM_UNINITIALIZED_ERROR;
return -1;
} }
if (config.cngMode != AecmFalse && config.cngMode != AecmTrue) if (config.cngMode != AecmFalse && config.cngMode != AecmTrue)
{ {
aecm->lastError = AECM_BAD_PARAMETER_ERROR; return AECM_BAD_PARAMETER_ERROR;
return -1;
} }
aecm->aecmCore->cngMode = config.cngMode; aecm->aecmCore->cngMode = config.cngMode;
if (config.echoMode < 0 || config.echoMode > 4) if (config.echoMode < 0 || config.echoMode > 4)
{ {
aecm->lastError = AECM_BAD_PARAMETER_ERROR; return AECM_BAD_PARAMETER_ERROR;
return -1;
} }
aecm->echoMode = config.echoMode; aecm->echoMode = config.echoMode;
@ -524,33 +512,6 @@ int32_t WebRtcAecm_set_config(void *aecmInst, AecmConfig config)
return 0; 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, int32_t WebRtcAecm_InitEchoPath(void* aecmInst,
const void* echo_path, const void* echo_path,
size_t size_bytes) size_t size_bytes)
@ -562,19 +523,16 @@ int32_t WebRtcAecm_InitEchoPath(void* aecmInst,
return -1; return -1;
} }
if (echo_path == NULL) { if (echo_path == NULL) {
aecm->lastError = AECM_NULL_POINTER_ERROR; return AECM_NULL_POINTER_ERROR;
return -1;
} }
if (size_bytes != WebRtcAecm_echo_path_size_bytes()) if (size_bytes != WebRtcAecm_echo_path_size_bytes())
{ {
// Input channel size does not match the size of AECM // Input channel size does not match the size of AECM
aecm->lastError = AECM_BAD_PARAMETER_ERROR; return AECM_BAD_PARAMETER_ERROR;
return -1;
} }
if (aecm->initFlag != kInitCheck) if (aecm->initFlag != kInitCheck)
{ {
aecm->lastError = AECM_UNINITIALIZED_ERROR; return AECM_UNINITIALIZED_ERROR;
return -1;
} }
WebRtcAecm_InitEchoPathCore(aecm->aecmCore, echo_path_ptr); WebRtcAecm_InitEchoPathCore(aecm->aecmCore, echo_path_ptr);
@ -593,19 +551,16 @@ int32_t WebRtcAecm_GetEchoPath(void* aecmInst,
return -1; return -1;
} }
if (echo_path == NULL) { if (echo_path == NULL) {
aecm->lastError = AECM_NULL_POINTER_ERROR; return AECM_NULL_POINTER_ERROR;
return -1;
} }
if (size_bytes != WebRtcAecm_echo_path_size_bytes()) if (size_bytes != WebRtcAecm_echo_path_size_bytes())
{ {
// Input channel size does not match the size of AECM // Input channel size does not match the size of AECM
aecm->lastError = AECM_BAD_PARAMETER_ERROR; return AECM_BAD_PARAMETER_ERROR;
return -1;
} }
if (aecm->initFlag != kInitCheck) if (aecm->initFlag != kInitCheck)
{ {
aecm->lastError = AECM_UNINITIALIZED_ERROR; return AECM_UNINITIALIZED_ERROR;
return -1;
} }
memcpy(echo_path_ptr, aecm->aecmCore->channelStored, size_bytes); 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)); 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) { static int WebRtcAecm_EstBufDelay(AecMobile* aecm, short msInSndCardBuf) {
short delayNew, nSampSndCard; short delayNew, nSampSndCard;

View File

@ -66,7 +66,7 @@ void WebRtcAecm_Free(void* aecmInst);
* Outputs Description * Outputs Description
* ------------------------------------------------------------------- * -------------------------------------------------------------------
* int32_t return 0: OK * int32_t return 0: OK
* -1: error * 1200-12004,12100: error/warning
*/ */
int32_t WebRtcAecm_Init(void* aecmInst, int32_t sampFreq); int32_t WebRtcAecm_Init(void* aecmInst, int32_t sampFreq);
@ -83,12 +83,31 @@ int32_t WebRtcAecm_Init(void* aecmInst, int32_t sampFreq);
* Outputs Description * Outputs Description
* ------------------------------------------------------------------- * -------------------------------------------------------------------
* int32_t return 0: OK * int32_t return 0: OK
* -1: error * 1200-12004,12100: error/warning
*/ */
int32_t WebRtcAecm_BufferFarend(void* aecmInst, int32_t WebRtcAecm_BufferFarend(void* aecmInst,
const int16_t* farend, const int16_t* farend,
size_t nrOfSamples); 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. * 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 * int16_t* out Out buffer, one frame of processed nearend
* int32_t return 0: OK * int32_t return 0: OK
* -1: error * 1200-12004,12100: error/warning
*/ */
int32_t WebRtcAecm_Process(void* aecmInst, int32_t WebRtcAecm_Process(void* aecmInst,
const int16_t* nearendNoisy, const int16_t* nearendNoisy,
@ -133,26 +152,10 @@ int32_t WebRtcAecm_Process(void* aecmInst,
* Outputs Description * Outputs Description
* ------------------------------------------------------------------- * -------------------------------------------------------------------
* int32_t return 0: OK * int32_t return 0: OK
* -1: error * 1200-12004,12100: error/warning
*/ */
int32_t WebRtcAecm_set_config(void* aecmInst, AecmConfig config); 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. * 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 * Outputs Description
* ------------------------------------------------------------------- * -------------------------------------------------------------------
* int32_t return 0: OK * int32_t return 0: OK
* -1: error * 1200-12004,12100: error/warning
*/ */
int32_t WebRtcAecm_InitEchoPath(void* aecmInst, int32_t WebRtcAecm_InitEchoPath(void* aecmInst,
const void* echo_path, const void* echo_path,
@ -184,7 +187,7 @@ int32_t WebRtcAecm_InitEchoPath(void* aecmInst,
* Outputs Description * Outputs Description
* ------------------------------------------------------------------- * -------------------------------------------------------------------
* int32_t return 0: OK * int32_t return 0: OK
* -1: error * 1200-12004,12100: error/warning
*/ */
int32_t WebRtcAecm_GetEchoPath(void* aecmInst, int32_t WebRtcAecm_GetEchoPath(void* aecmInst,
void* echo_path, void* echo_path,
@ -199,18 +202,6 @@ int32_t WebRtcAecm_GetEchoPath(void* aecmInst,
*/ */
size_t WebRtcAecm_echo_path_size_bytes(); 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 #ifdef __cplusplus
} }

View File

@ -94,7 +94,7 @@ int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) {
audio->num_frames_per_band()); audio->num_frames_per_band());
if (err != apm_->kNoError) { if (err != apm_->kNoError) {
return GetHandleError(my_handle); // TODO(ajm): warning possible? return MapError(err); // TODO(ajm): warning possible?
} }
handle_index++; handle_index++;
@ -138,7 +138,7 @@ int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio) {
stream_drift_samples_); stream_drift_samples_);
if (err != apm_->kNoError) { if (err != apm_->kNoError) {
err = GetHandleError(my_handle); err = MapError(err);
// TODO(ajm): Figure out how to return warnings properly. // TODO(ajm): Figure out how to return warnings properly.
if (err != apm_->kBadStreamParameterWarning) { if (err != apm_->kBadStreamParameterWarning) {
return err; return err;
@ -148,7 +148,7 @@ int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio) {
int status = 0; int status = 0;
err = WebRtcAec_get_echo_status(my_handle, &status); err = WebRtcAec_get_echo_status(my_handle, &status);
if (err != apm_->kNoError) { if (err != apm_->kNoError) {
return GetHandleError(my_handle); return MapError(err);
} }
if (status == 1) { if (status == 1) {
@ -240,7 +240,7 @@ int EchoCancellationImpl::GetMetrics(Metrics* metrics) {
Handle* my_handle = static_cast<Handle*>(handle(0)); Handle* my_handle = static_cast<Handle*>(handle(0));
int err = WebRtcAec_GetMetrics(my_handle, &my_metrics); int err = WebRtcAec_GetMetrics(my_handle, &my_metrics);
if (err != apm_->kNoError) { if (err != apm_->kNoError) {
return GetHandleError(my_handle); return MapError(err);
} }
metrics->residual_echo_return_loss.instant = my_metrics.rerl.instant; 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*>(handle(0)); Handle* my_handle = static_cast<Handle*>(handle(0));
if (WebRtcAec_GetDelayMetrics(my_handle, median, std, fraction_poor_delays) != const int err =
apm_->kNoError) { WebRtcAec_GetDelayMetrics(my_handle, median, std, fraction_poor_delays);
return GetHandleError(my_handle); if (err != apm_->kNoError) {
return MapError(err);
} }
return apm_->kNoError; return apm_->kNoError;
@ -384,6 +385,6 @@ int EchoCancellationImpl::num_handles_required() const {
int EchoCancellationImpl::GetHandleError(void* handle) const { int EchoCancellationImpl::GetHandleError(void* handle) const {
assert(handle != NULL); assert(handle != NULL);
return MapError(WebRtcAec_get_error_code(static_cast<Handle*>(handle))); return AudioProcessing::kUnspecifiedError;
} }
} // namespace webrtc } // namespace webrtc

View File

@ -40,22 +40,6 @@ int16_t MapSetting(EchoControlMobile::RoutingMode mode) {
return -1; 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 } // namespace
size_t EchoControlMobile::echo_path_size_bytes() { size_t EchoControlMobile::echo_path_size_bytes() {
@ -289,6 +273,6 @@ int EchoControlMobileImpl::num_handles_required() const {
int EchoControlMobileImpl::GetHandleError(void* handle) const { int EchoControlMobileImpl::GetHandleError(void* handle) const {
assert(handle != NULL); assert(handle != NULL);
return MapError(WebRtcAecm_get_error_code(static_cast<Handle*>(handle))); return AudioProcessing::kUnspecifiedError;
} }
} // namespace webrtc } // namespace webrtc