[pulseaudio-discuss] [PATCH 06/23] echo-cancel: Fix memory leak / deinitialization of Adrian AEC

Peter Meerwald pmeerw at pmeerw.net
Wed Feb 13 08:26:53 PST 2013


From: Peter Meerwald <p.meerwald at bct-electronic.com>

was simply absent

Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>
---
 src/modules/echo-cancel/adrian-aec.c |   11 +++++++++++
 src/modules/echo-cancel/adrian-aec.h |    3 ++-
 src/modules/echo-cancel/adrian.c     |    6 ++++--
 src/modules/echo-cancel/adrian.h     |    1 +
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/modules/echo-cancel/adrian-aec.c b/src/modules/echo-cancel/adrian-aec.c
index 1476ee4..9134212 100644
--- a/src/modules/echo-cancel/adrian-aec.c
+++ b/src/modules/echo-cancel/adrian-aec.c
@@ -106,6 +106,17 @@ AEC* AEC_init(int RATE, int have_vector)
   return a;
 }
 
+void AEC_done(AEC *a) {
+    if (a) {
+        pa_xfree(a->Fx);
+        pa_xfree(a->Fe);
+        pa_xfree(a->acMic);
+        pa_xfree(a->acSpk);
+        pa_xfree(a->cutoff);
+        pa_xfree(a);
+    }
+}
+
 // Adrian soft decision DTD
 // (Dual Average Near-End to Far-End signal Ratio DTD)
 // This algorithm uses exponential smoothing with differnt
diff --git a/src/modules/echo-cancel/adrian-aec.h b/src/modules/echo-cancel/adrian-aec.h
index e733f83..6271774 100644
--- a/src/modules/echo-cancel/adrian-aec.h
+++ b/src/modules/echo-cancel/adrian-aec.h
@@ -351,7 +351,8 @@ static  void AEC_leaky(AEC *a);
  */
 static  REAL AEC_nlms_pw(AEC *a, REAL d, REAL x_, float stepsize);
 
-  AEC* AEC_init(int RATE, int have_vector);
+AEC* AEC_init(int RATE, int have_vector);
+void AEC_done(AEC *a);
 
 /* Acoustic Echo Cancellation and Suppression of one sample
  * in   d:  microphone signal with echo
diff --git a/src/modules/echo-cancel/adrian.c b/src/modules/echo-cancel/adrian.c
index 91e3b35..40e9654 100644
--- a/src/modules/echo-cancel/adrian.c
+++ b/src/modules/echo-cancel/adrian.c
@@ -111,6 +111,8 @@ void pa_adrian_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *
 }
 
 void pa_adrian_ec_done(pa_echo_canceller *ec) {
-    pa_xfree(ec->params.priv.adrian.aec);
-    ec->params.priv.adrian.aec = NULL;
+    if (ec->params.priv.adrian.aec) {
+        AEC_done(ec->params.priv.adrian.aec);
+        ec->params.priv.adrian.aec = NULL;
+    }
 }
diff --git a/src/modules/echo-cancel/adrian.h b/src/modules/echo-cancel/adrian.h
index 639fa9e..4ace392 100644
--- a/src/modules/echo-cancel/adrian.h
+++ b/src/modules/echo-cancel/adrian.h
@@ -28,4 +28,5 @@
 typedef struct AEC AEC;
 
 AEC* AEC_init(int RATE, int have_vector);
+void AEC_done(AEC *a);
 int AEC_doAEC(AEC *a, int d_, int x_);
-- 
1.7.9.5



More information about the pulseaudio-discuss mailing list