[pulseaudio-commits] 3 commits - src/modules
Arun Raghavan
arun at kemper.freedesktop.org
Fri May 27 19:35:02 PDT 2011
src/modules/echo-cancel/echo-cancel.h | 2 +
src/modules/echo-cancel/module-echo-cancel.c | 44 +++++++++++++++++++++++----
src/modules/echo-cancel/speex.c | 3 +
3 files changed, 42 insertions(+), 7 deletions(-)
New commits:
commit b0f5b8d2fab347a062fa6ed34ff2908a1c29a41d
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date: Sat May 28 07:51:35 2011 +0530
echo-cancel: Fix a crash is speex cleanup
If module initialisation fails, the speex done() function might try to
free a value that's not been allocated yet. Adding protection for this
condition.
diff --git a/src/modules/echo-cancel/speex.c b/src/modules/echo-cancel/speex.c
index ce361fc..72c5268 100644
--- a/src/modules/echo-cancel/speex.c
+++ b/src/modules/echo-cancel/speex.c
@@ -109,6 +109,7 @@ void pa_speex_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *p
}
void pa_speex_ec_done(pa_echo_canceller *ec) {
- speex_echo_state_destroy(ec->params.priv.speex.state);
+ if (ec->params.priv.speex.state)
+ speex_echo_state_destroy(ec->params.priv.speex.state);
ec->params.priv.speex.state = NULL;
}
commit 9e78de2da27e882b8cd956ec859304629011a55b
Author: Bart Cerneels <bart.cerneels at kde.org>
Date: Sat May 28 07:57:22 2011 +0530
echo-cancel: Fix echo suppression, add some knobs
The echo suppress attenuation value was being incorrectly modified.
Fixed and added 2 arguments to change the attenuation of the residual
echo filter. Default values of the speex preprocessor will be used when
omitted.
diff --git a/src/modules/echo-cancel/echo-cancel.h b/src/modules/echo-cancel/echo-cancel.h
index 5f18053..aa40adc 100644
--- a/src/modules/echo-cancel/echo-cancel.h
+++ b/src/modules/echo-cancel/echo-cancel.h
@@ -68,6 +68,8 @@ struct pa_echo_canceller {
pa_bool_t agc;
pa_bool_t denoise;
pa_bool_t echo_suppress;
+ int32_t echo_suppress_attenuation;
+ int32_t echo_suppress_attenuation_active;
SpeexPreprocessState *pp_state;
};
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index 90577d4..cb30832 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -79,7 +79,9 @@ PA_MODULE_USAGE(
"aec_args=<parameters for the AEC engine> "
"agc=<perform automagic gain control?> "
"denoise=<apply denoising?> "
- "echo_suppress=<perform echo suppression? (only with the speex canceller)> "
+ "echo_suppress=<perform residual echo suppression? (only with the speex canceller)> "
+ "echo_suppress_attenuation=<dB value of residual echo attenuation> "
+ "echo_suppress_attenuation_active=<dB value of residual echo attenuation when near end is active> "
"save_aec=<save AEC data in /tmp> "
"autoloaded=<set if this module is being loaded automatically> "
));
@@ -112,6 +114,7 @@ static const pa_echo_canceller ec_table[] = {
#define DEFAULT_AGC_ENABLED FALSE
#define DEFAULT_DENOISE_ENABLED FALSE
#define DEFAULT_ECHO_SUPPRESS_ENABLED FALSE
+#define DEFAULT_ECHO_SUPPRESS_ATTENUATION 0
#define DEFAULT_SAVE_AEC 0
#define DEFAULT_AUTOLOADED FALSE
@@ -221,6 +224,8 @@ static const char* const valid_modargs[] = {
"agc",
"denoise",
"echo_suppress",
+ "echo_suppress_attenuation",
+ "echo_suppress_attenuation_active",
"save_aec",
"autoloaded",
NULL
@@ -1429,6 +1434,26 @@ int pa__init(pa_module*m) {
goto fail;
}
+ u->ec->echo_suppress_attenuation = DEFAULT_ECHO_SUPPRESS_ATTENUATION;
+ if (pa_modargs_get_value_s32(ma, "echo_suppress_attenuation", &u->ec->echo_suppress_attenuation) < 0) {
+ pa_log("Failed to parse echo_suppress_attenuation value");
+ goto fail;
+ }
+ if (u->ec->echo_suppress_attenuation > 0) {
+ pa_log("echo_suppress_attenuation should be a negative dB value");
+ goto fail;
+ }
+
+ u->ec->echo_suppress_attenuation_active = DEFAULT_ECHO_SUPPRESS_ATTENUATION;
+ if (pa_modargs_get_value_s32(ma, "echo_suppress_attenuation_active", &u->ec->echo_suppress_attenuation_active) < 0) {
+ pa_log("Failed to parse echo_supress_attenuation_active value");
+ goto fail;
+ }
+ if (u->ec->echo_suppress_attenuation_active > 0) {
+ pa_log("echo_suppress_attenuation_active should be a negative dB value");
+ goto fail;
+ }
+
u->save_aec = DEFAULT_SAVE_AEC;
if (pa_modargs_get_value_u32(ma, "save_aec", &u->save_aec) < 0) {
pa_log("Failed to parse save_aec value");
@@ -1460,9 +1485,15 @@ int pa__init(pa_module*m) {
speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_AGC, &u->ec->agc);
speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_DENOISE, &u->ec->denoise);
- speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS, &u->ec->echo_suppress);
- if (u->ec->echo_suppress)
+ if (u->ec->echo_suppress) {
+ if (u->ec->echo_suppress_attenuation)
+ speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS, &u->ec->echo_suppress_attenuation);
+ if (u->ec->echo_suppress_attenuation_active) {
+ speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE,
+ &u->ec->echo_suppress_attenuation_active);
+ }
speex_preprocess_ctl(u->ec->pp_state, SPEEX_PREPROCESS_SET_ECHO_STATE, u->ec->params.priv.speex.state);
+ }
}
/* Create source */
commit 4fd3efa46b33726d489af933e709289d20ed5ea0
Author: Bart Cerneels <bart.cerneels at kde.org>
Date: Sat May 28 07:56:00 2011 +0530
echo-cancel: Speex preprocessor has to run *after* the AEC.
This is how it is expected to be run.
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index e83839a..90577d4 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -726,12 +726,13 @@ static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk)
fwrite(pdata, 1, u->blocksize, u->played_file);
}
- if (u->ec->pp_state)
- speex_preprocess_run(u->ec->pp_state, (spx_int16_t *) rdata);
-
/* perform echo cancelation */
u->ec->run(u->ec, rdata, pdata, cdata);
+ /* preprecessor is run after AEC. This is not a mistake! */
+ if (u->ec->pp_state)
+ speex_preprocess_run(u->ec->pp_state, (spx_int16_t *) cdata);
+
if (u->save_aec) {
if (u->canceled_file)
fwrite(cdata, 1, u->blocksize, u->canceled_file);
More information about the pulseaudio-commits
mailing list