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}
diff --git a/webrtc/modules/audio_processing/aec/aec_core.c b/webrtc/modules/audio_processing/aec/aec_core.c
index fc523bf..f540f94 100644
--- a/webrtc/modules/audio_processing/aec/aec_core.c
+++ b/webrtc/modules/audio_processing/aec/aec_core.c
@@ -1471,10 +1471,10 @@
   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 @@
   WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend);
 
   free(aec);
-  return 0;
 }
 
 #ifdef WEBRTC_AEC_DEBUG_DUMP
diff --git a/webrtc/modules/audio_processing/aec/aec_core.h b/webrtc/modules/audio_processing/aec/aec_core.h
index 2b614dd..cc9e81b 100644
--- a/webrtc/modules/audio_processing/aec/aec_core.h
+++ b/webrtc/modules/audio_processing/aec/aec_core.h
@@ -52,7 +52,7 @@
 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)
diff --git a/webrtc/modules/audio_processing/aec/aec_resampler.c b/webrtc/modules/audio_processing/aec/aec_resampler.c
index 28aa832..8b07e16 100644
--- a/webrtc/modules/audio_processing/aec/aec_resampler.c
+++ b/webrtc/modules/audio_processing/aec/aec_resampler.c
@@ -63,11 +63,9 @@
   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,
diff --git a/webrtc/modules/audio_processing/aec/aec_resampler.h b/webrtc/modules/audio_processing/aec/aec_resampler.h
index 73e2821..debe069 100644
--- a/webrtc/modules/audio_processing/aec/aec_resampler.h
+++ b/webrtc/modules/audio_processing/aec/aec_resampler.h
@@ -23,7 +23,7 @@
 // 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);
diff --git a/webrtc/modules/audio_processing/aec/echo_cancellation.c b/webrtc/modules/audio_processing/aec/echo_cancellation.c
index 016c455..33361be 100644
--- a/webrtc/modules/audio_processing/aec/echo_cancellation.c
+++ b/webrtc/modules/audio_processing/aec/echo_cancellation.c
@@ -171,11 +171,11 @@
   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 @@
   WebRtcAec_FreeAec(aecpc->aec);
   WebRtcAec_FreeResampler(aecpc->resampler);
   free(aecpc);
-
-  return 0;
 }
 
 int32_t WebRtcAec_Init(void* aecInst, int32_t sampFreq, int32_t scSampFreq) {
diff --git a/webrtc/modules/audio_processing/aec/echo_cancellation_unittest.cc b/webrtc/modules/audio_processing/aec/echo_cancellation_unittest.cc
index 469efd3..6c325e0 100644
--- a/webrtc/modules/audio_processing/aec/echo_cancellation_unittest.cc
+++ b/webrtc/modules/audio_processing/aec/echo_cancellation_unittest.cc
@@ -23,13 +23,13 @@
 
 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 @@
   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
diff --git a/webrtc/modules/audio_processing/aec/include/echo_cancellation.h b/webrtc/modules/audio_processing/aec/include/echo_cancellation.h
index df9b2a9..6914ed1 100644
--- a/webrtc/modules/audio_processing/aec/include/echo_cancellation.h
+++ b/webrtc/modules/audio_processing/aec/include/echo_cancellation.h
@@ -84,13 +84,8 @@
  * 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.
diff --git a/webrtc/modules/audio_processing/aec/system_delay_unittest.cc b/webrtc/modules/audio_processing/aec/system_delay_unittest.cc
index 654ae54..da28752 100644
--- a/webrtc/modules/audio_processing/aec/system_delay_unittest.cc
+++ b/webrtc/modules/audio_processing/aec/system_delay_unittest.cc
@@ -73,7 +73,7 @@
 
 void SystemDelayTest::TearDown() {
   // Free AEC
-  ASSERT_EQ(0, WebRtcAec_Free(handle_));
+  WebRtcAec_Free(handle_);
   handle_ = NULL;
 }
 
diff --git a/webrtc/modules/audio_processing/aecm/aecm_core.c b/webrtc/modules/audio_processing/aecm/aecm_core.c
index c95c1f2..6741acb 100644
--- a/webrtc/modules/audio_processing/aecm/aecm_core.c
+++ b/webrtc/modules/audio_processing/aecm/aecm_core.c
@@ -546,10 +546,9 @@
     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 @@
     WebRtcSpl_FreeRealFFT(aecm->real_fft);
 
     free(aecm);
-
-    return 0;
 }
 
 int WebRtcAecm_ProcessFrame(AecmCore* aecm,
diff --git a/webrtc/modules/audio_processing/aecm/aecm_core.h b/webrtc/modules/audio_processing/aecm/aecm_core.h
index 03655b9..15614d6 100644
--- a/webrtc/modules/audio_processing/aecm/aecm_core.h
+++ b/webrtc/modules/audio_processing/aecm/aecm_core.h
@@ -174,11 +174,7 @@
 // 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);
 
diff --git a/webrtc/modules/audio_processing/aecm/echo_control_mobile.c b/webrtc/modules/audio_processing/aecm/echo_control_mobile.c
index 389433b..2424839 100644
--- a/webrtc/modules/audio_processing/aecm/echo_control_mobile.c
+++ b/webrtc/modules/audio_processing/aecm/echo_control_mobile.c
@@ -130,13 +130,11 @@
     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 @@
     WebRtcAecm_FreeCore(aecm->aecmCore);
     WebRtc_FreeBuffer(aecm->farendBuf);
     free(aecm);
-
-    return 0;
 }
 
 int32_t WebRtcAecm_Init(void *aecmInst, int32_t sampFreq)
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 ac43576..617c9602 100644
--- a/webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h
+++ b/webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h
@@ -61,13 +61,8 @@
  * 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.
diff --git a/webrtc/modules/audio_processing/agc/legacy/analog_agc.c b/webrtc/modules/audio_processing/agc/legacy/analog_agc.c
index 17e06fe..bb56cfe 100644
--- a/webrtc/modules/audio_processing/agc/legacy/analog_agc.c
+++ b/webrtc/modules/audio_processing/agc/legacy/analog_agc.c
@@ -1340,19 +1340,16 @@
     return 0;
 }
 
-int WebRtcAgc_Free(void *state)
-{
+void WebRtcAgc_Free(void *state) {
   LegacyAgc* stt;
 
   stt = (LegacyAgc*)state;
 #ifdef WEBRTC_AGC_DEBUG_DUMP
-    fclose(stt->fpt);
-    fclose(stt->agcLog);
-    fclose(stt->digitalAgc.logFile);
+  fclose(stt->fpt);
+  fclose(stt->agcLog);
+  fclose(stt->digitalAgc.logFile);
 #endif
-    free(stt);
-
-    return 0;
+  free(stt);
 }
 
 /* minLevel     - Minimum volume level
diff --git a/webrtc/modules/audio_processing/agc/legacy/gain_control.h b/webrtc/modules/audio_processing/agc/legacy/gain_control.h
index cf1e4f1..3994f55 100644
--- a/webrtc/modules/audio_processing/agc/legacy/gain_control.h
+++ b/webrtc/modules/audio_processing/agc/legacy/gain_control.h
@@ -213,11 +213,8 @@
  *
  * 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.
diff --git a/webrtc/modules/audio_processing/ns/include/noise_suppression.h b/webrtc/modules/audio_processing/ns/include/noise_suppression.h
index d912f71..14e686a 100644
--- a/webrtc/modules/audio_processing/ns/include/noise_suppression.h
+++ b/webrtc/modules/audio_processing/ns/include/noise_suppression.h
@@ -41,12 +41,8 @@
  *
  * 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
diff --git a/webrtc/modules/audio_processing/ns/include/noise_suppression_x.h b/webrtc/modules/audio_processing/ns/include/noise_suppression_x.h
index e1671a6..736cb23 100644
--- a/webrtc/modules/audio_processing/ns/include/noise_suppression_x.h
+++ b/webrtc/modules/audio_processing/ns/include/noise_suppression_x.h
@@ -41,12 +41,8 @@
  *
  * 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
diff --git a/webrtc/modules/audio_processing/ns/noise_suppression.c b/webrtc/modules/audio_processing/ns/noise_suppression.c
index bae0f2e..0efbebc 100644
--- a/webrtc/modules/audio_processing/ns/noise_suppression.c
+++ b/webrtc/modules/audio_processing/ns/noise_suppression.c
@@ -28,12 +28,10 @@
 
 }
 
-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);
 }
diff --git a/webrtc/modules/audio_processing/ns/noise_suppression_x.c b/webrtc/modules/audio_processing/ns/noise_suppression_x.c
index 920b501..a3b6d0f 100644
--- a/webrtc/modules/audio_processing/ns/noise_suppression_x.c
+++ b/webrtc/modules/audio_processing/ns/noise_suppression_x.c
@@ -31,10 +31,9 @@
 
 }
 
-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) {