[pulseaudio-discuss] [PATCH 2/5] echo-cancel: Fix memory leak / deinitialization of Adrian AEC
Peter Meerwald
pmeerw at pmeerw.net
Fri Feb 8 06:57:02 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 ++++--
3 files changed, 17 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 813c304..ad41910 100644
--- a/src/modules/echo-cancel/adrian.c
+++ b/src/modules/echo-cancel/adrian.c
@@ -115,6 +115,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;
+ }
}
--
1.7.9.5
More information about the pulseaudio-discuss
mailing list