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:
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user