Refactor audio_processing: Free functions return void
There is no point in returning an error when Free() fails. In fact it can only happen if we have a null pointer as object. There is further no place where the return value is used. Affected components are - aec - aecm - agc - ns BUG=441 R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/50579004 Cr-Commit-Position: refs/heads/master@{#8966}
This commit is contained in:
parent
0666a9b28b
commit
f6a99e63b6
@ -1471,10 +1471,10 @@ int WebRtcAec_CreateAec(AecCore** aecInst) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WebRtcAec_FreeAec(AecCore* aec) {
|
||||
void WebRtcAec_FreeAec(AecCore* aec) {
|
||||
int i;
|
||||
if (aec == NULL) {
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_FreeBuffer(aec->nearFrBuf);
|
||||
@ -1498,7 +1498,6 @@ int WebRtcAec_FreeAec(AecCore* aec) {
|
||||
WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend);
|
||||
|
||||
free(aec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WEBRTC_AEC_DEBUG_DUMP
|
||||
|
@ -52,7 +52,7 @@ typedef struct Stats {
|
||||
typedef struct AecCore AecCore;
|
||||
|
||||
int WebRtcAec_CreateAec(AecCore** aec);
|
||||
int WebRtcAec_FreeAec(AecCore* aec);
|
||||
void WebRtcAec_FreeAec(AecCore* aec);
|
||||
int WebRtcAec_InitAec(AecCore* aec, int sampFreq);
|
||||
void WebRtcAec_InitAec_SSE2(void);
|
||||
#if defined(MIPS_FPU_LE)
|
||||
|
@ -63,11 +63,9 @@ int WebRtcAec_InitResampler(void* resampInst, int deviceSampleRateHz) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WebRtcAec_FreeResampler(void* resampInst) {
|
||||
void WebRtcAec_FreeResampler(void* resampInst) {
|
||||
AecResampler* obj = (AecResampler*)resampInst;
|
||||
free(obj);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WebRtcAec_ResampleLinear(void* resampInst,
|
||||
|
@ -23,7 +23,7 @@ enum {
|
||||
// Unless otherwise specified, functions return 0 on success and -1 on error
|
||||
int WebRtcAec_CreateResampler(void** resampInst);
|
||||
int WebRtcAec_InitResampler(void* resampInst, int deviceSampleRateHz);
|
||||
int WebRtcAec_FreeResampler(void* resampInst);
|
||||
void WebRtcAec_FreeResampler(void* resampInst);
|
||||
|
||||
// Estimates skew from raw measurement.
|
||||
int WebRtcAec_GetSkew(void* resampInst, int rawSkew, float* skewEst);
|
||||
|
@ -171,11 +171,11 @@ int32_t WebRtcAec_Create(void** aecInst) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t WebRtcAec_Free(void* aecInst) {
|
||||
void WebRtcAec_Free(void* aecInst) {
|
||||
Aec* aecpc = aecInst;
|
||||
|
||||
if (aecpc == NULL) {
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_FreeBuffer(aecpc->far_pre_buf);
|
||||
@ -189,8 +189,6 @@ int32_t WebRtcAec_Free(void* aecInst) {
|
||||
WebRtcAec_FreeAec(aecpc->aec);
|
||||
WebRtcAec_FreeResampler(aecpc->resampler);
|
||||
free(aecpc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t WebRtcAec_Init(void* aecInst, int32_t sampFreq, int32_t scSampFreq) {
|
||||
|
@ -23,13 +23,13 @@ extern "C" {
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TEST(EchoCancellationTest, CreateAndFreeHandlesErrors) {
|
||||
TEST(EchoCancellationTest, CreateAndFreeHasExpectedBehavior) {
|
||||
EXPECT_EQ(-1, WebRtcAec_Create(NULL));
|
||||
void* handle = NULL;
|
||||
ASSERT_EQ(0, WebRtcAec_Create(&handle));
|
||||
EXPECT_TRUE(handle != NULL);
|
||||
EXPECT_EQ(-1, WebRtcAec_Free(NULL));
|
||||
EXPECT_EQ(0, WebRtcAec_Free(handle));
|
||||
WebRtcAec_Free(nullptr);
|
||||
WebRtcAec_Free(handle);
|
||||
}
|
||||
|
||||
TEST(EchoCancellationTest, ApplyAecCoreHandle) {
|
||||
@ -44,7 +44,7 @@ TEST(EchoCancellationTest, ApplyAecCoreHandle) {
|
||||
int delay = 111;
|
||||
WebRtcAec_SetSystemDelay(aec_core, delay);
|
||||
EXPECT_EQ(delay, WebRtcAec_system_delay(aec_core));
|
||||
EXPECT_EQ(0, WebRtcAec_Free(handle));
|
||||
WebRtcAec_Free(handle);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -84,13 +84,8 @@ int32_t WebRtcAec_Create(void** aecInst);
|
||||
* Inputs Description
|
||||
* -------------------------------------------------------------------
|
||||
* void* aecInst Pointer to the AEC instance
|
||||
*
|
||||
* Outputs Description
|
||||
* -------------------------------------------------------------------
|
||||
* int32_t return 0: OK
|
||||
* -1: error
|
||||
*/
|
||||
int32_t WebRtcAec_Free(void* aecInst);
|
||||
void WebRtcAec_Free(void* aecInst);
|
||||
|
||||
/*
|
||||
* Initializes an AEC instance.
|
||||
|
@ -73,7 +73,7 @@ void SystemDelayTest::SetUp() {
|
||||
|
||||
void SystemDelayTest::TearDown() {
|
||||
// Free AEC
|
||||
ASSERT_EQ(0, WebRtcAec_Free(handle_));
|
||||
WebRtcAec_Free(handle_);
|
||||
handle_ = NULL;
|
||||
}
|
||||
|
||||
|
@ -546,10 +546,9 @@ int WebRtcAecm_Control(AecmCore* aecm, int delay, int nlpFlag) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WebRtcAecm_FreeCore(AecmCore* aecm) {
|
||||
if (aecm == NULL)
|
||||
{
|
||||
return -1;
|
||||
void WebRtcAecm_FreeCore(AecmCore* aecm) {
|
||||
if (aecm == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_FreeBuffer(aecm->farFrameBuf);
|
||||
@ -562,8 +561,6 @@ int WebRtcAecm_FreeCore(AecmCore* aecm) {
|
||||
WebRtcSpl_FreeRealFFT(aecm->real_fft);
|
||||
|
||||
free(aecm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WebRtcAecm_ProcessFrame(AecmCore* aecm,
|
||||
|
@ -174,11 +174,7 @@ int WebRtcAecm_InitCore(AecmCore* const aecm, int samplingFreq);
|
||||
// Input:
|
||||
// - aecm : Pointer to the AECM instance
|
||||
//
|
||||
// Return value : 0 - Ok
|
||||
// -1 - Error
|
||||
// 11001-11016: Error
|
||||
//
|
||||
int WebRtcAecm_FreeCore(AecmCore* aecm);
|
||||
void WebRtcAecm_FreeCore(AecmCore* aecm);
|
||||
|
||||
int WebRtcAecm_Control(AecmCore* aecm, int delay, int nlpFlag);
|
||||
|
||||
|
@ -130,13 +130,11 @@ int32_t WebRtcAecm_Create(void **aecmInst)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t WebRtcAecm_Free(void *aecmInst)
|
||||
{
|
||||
void WebRtcAecm_Free(void* aecmInst) {
|
||||
AecMobile* aecm = aecmInst;
|
||||
|
||||
if (aecm == NULL)
|
||||
{
|
||||
return -1;
|
||||
if (aecm == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef AEC_DEBUG
|
||||
@ -153,8 +151,6 @@ int32_t WebRtcAecm_Free(void *aecmInst)
|
||||
WebRtcAecm_FreeCore(aecm->aecmCore);
|
||||
WebRtc_FreeBuffer(aecm->farendBuf);
|
||||
free(aecm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t WebRtcAecm_Init(void *aecmInst, int32_t sampFreq)
|
||||
|
@ -61,13 +61,8 @@ int32_t WebRtcAecm_Create(void **aecmInst);
|
||||
* Inputs Description
|
||||
* -------------------------------------------------------------------
|
||||
* void* aecmInst Pointer to the AECM instance
|
||||
*
|
||||
* Outputs Description
|
||||
* -------------------------------------------------------------------
|
||||
* int32_t return 0: OK
|
||||
* -1: error
|
||||
*/
|
||||
int32_t WebRtcAecm_Free(void *aecmInst);
|
||||
void WebRtcAecm_Free(void* aecmInst);
|
||||
|
||||
/*
|
||||
* Initializes an AECM instance.
|
||||
|
@ -1340,8 +1340,7 @@ int WebRtcAgc_Create(void **agcInst)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WebRtcAgc_Free(void *state)
|
||||
{
|
||||
void WebRtcAgc_Free(void *state) {
|
||||
LegacyAgc* stt;
|
||||
|
||||
stt = (LegacyAgc*)state;
|
||||
@ -1351,8 +1350,6 @@ int WebRtcAgc_Free(void *state)
|
||||
fclose(stt->digitalAgc.logFile);
|
||||
#endif
|
||||
free(stt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* minLevel - Minimum volume level
|
||||
|
@ -213,11 +213,8 @@ int WebRtcAgc_Create(void **agcInst);
|
||||
*
|
||||
* Input:
|
||||
* - agcInst : AGC instance.
|
||||
*
|
||||
* Return value : 0 - Ok
|
||||
* -1 - Error
|
||||
*/
|
||||
int WebRtcAgc_Free(void *agcInst);
|
||||
void WebRtcAgc_Free(void* agcInst);
|
||||
|
||||
/*
|
||||
* This function initializes an AGC instance.
|
||||
|
@ -41,12 +41,8 @@ int WebRtcNs_Create(NsHandle** NS_inst);
|
||||
*
|
||||
* Input:
|
||||
* - NS_inst : Pointer to NS instance that should be freed
|
||||
*
|
||||
* Return value : 0 - Ok
|
||||
* -1 - Error
|
||||
*/
|
||||
int WebRtcNs_Free(NsHandle* NS_inst);
|
||||
|
||||
void WebRtcNs_Free(NsHandle* NS_inst);
|
||||
|
||||
/*
|
||||
* This function initializes a NS instance and has to be called before any other
|
||||
|
@ -41,12 +41,8 @@ int WebRtcNsx_Create(NsxHandle** nsxInst);
|
||||
*
|
||||
* Input:
|
||||
* - nsxInst : Pointer to NS instance that should be freed
|
||||
*
|
||||
* Return value : 0 - Ok
|
||||
* -1 - Error
|
||||
*/
|
||||
int WebRtcNsx_Free(NsxHandle* nsxInst);
|
||||
|
||||
void WebRtcNsx_Free(NsxHandle* nsxInst);
|
||||
|
||||
/*
|
||||
* This function initializes a NS instance
|
||||
|
@ -28,12 +28,10 @@ int WebRtcNs_Create(NsHandle** NS_inst) {
|
||||
|
||||
}
|
||||
|
||||
int WebRtcNs_Free(NsHandle* NS_inst) {
|
||||
void WebRtcNs_Free(NsHandle* NS_inst) {
|
||||
free(NS_inst);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int WebRtcNs_Init(NsHandle* NS_inst, uint32_t fs) {
|
||||
return WebRtcNs_InitCore((NoiseSuppressionC*)NS_inst, fs);
|
||||
}
|
||||
|
@ -31,10 +31,9 @@ int WebRtcNsx_Create(NsxHandle** nsxInst) {
|
||||
|
||||
}
|
||||
|
||||
int WebRtcNsx_Free(NsxHandle* nsxInst) {
|
||||
void WebRtcNsx_Free(NsxHandle* nsxInst) {
|
||||
WebRtcSpl_FreeRealFFT(((NoiseSuppressionFixedC*)nsxInst)->real_fft);
|
||||
free(nsxInst);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WebRtcNsx_Init(NsxHandle* nsxInst, uint32_t fs) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user