summaryrefslogtreecommitdiffstats
path: root/src/modules/echo-cancel/module-echo-cancel.c
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2010-09-07 14:02:32 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2010-09-07 15:12:12 +0530
commit33a3bc34c89093b287eeff6a0b6d6134d1b313b7 (patch)
tree2d9206be3e9df8ad87cb1475bd6f126b528c038f /src/modules/echo-cancel/module-echo-cancel.c
parent526277c97c8c1e77252d3c67186914789ba55c33 (diff)
echo-cancel: Allow selection of AEC method using modargs
This adds an "aec_method" module argument to allow us to select the AEC implementation to use.
Diffstat (limited to 'src/modules/echo-cancel/module-echo-cancel.c')
-rw-r--r--src/modules/echo-cancel/module-echo-cancel.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index 75f74d34..57e60c56 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -75,17 +75,19 @@ PA_MODULE_USAGE(
"rate=<sample rate> "
"channels=<number of channels> "
"channel_map=<channel map> "
+ "aec_method=<implementation to use> "
"aec_args=<parameters for the AEC engine> "
"save_aec=<save AEC data in /tmp> "
));
/* NOTE: Make sure the enum and ec_table are maintained in the correct order */
-enum {
- PA_ECHO_CANCELLER_SPEEX,
+typedef enum {
+ PA_ECHO_CANCELLER_INVALID = -1,
+ PA_ECHO_CANCELLER_SPEEX = 0,
PA_ECHO_CANCELLER_ADRIAN,
-};
+} pa_echo_canceller_method_t;
-#define DEFAULT_ECHO_CANCELLER PA_ECHO_CANCELLER_SPEEX
+#define DEFAULT_ECHO_CANCELLER "speex"
static const pa_echo_canceller ec_table[] = {
{
@@ -205,6 +207,7 @@ static const char* const valid_modargs[] = {
"rate",
"channels",
"channel_map",
+ "aec_method",
"aec_args",
"save_aec",
NULL
@@ -1274,6 +1277,15 @@ static void sink_input_mute_changed_cb(pa_sink_input *i) {
pa_sink_mute_changed(u->sink, i->muted);
}
+static pa_echo_canceller_method_t get_ec_method_from_string(const char *method)
+{
+ if (strcmp(method, "speex") == 0)
+ return PA_ECHO_CANCELLER_SPEEX;
+ else if (strcmp(method, "adrian") == 0)
+ return PA_ECHO_CANCELLER_ADRIAN;
+ else
+ return PA_ECHO_CANCELLER_INVALID;
+}
int pa__init(pa_module*m) {
struct userdata *u;
@@ -1287,6 +1299,7 @@ int pa__init(pa_module*m) {
pa_source_new_data source_data;
pa_sink_new_data sink_data;
pa_memchunk silence;
+ pa_echo_canceller_method_t ec_method;
uint32_t adjust_time_sec;
pa_assert(m);
@@ -1332,10 +1345,16 @@ int pa__init(pa_module*m) {
pa_log("Failed to alloc echo canceller");
goto fail;
}
- u->ec->init = ec_table[DEFAULT_ECHO_CANCELLER].init;
- u->ec->run = ec_table[DEFAULT_ECHO_CANCELLER].run;
- u->ec->done = ec_table[DEFAULT_ECHO_CANCELLER].done;
- u->ec->get_block_size = ec_table[DEFAULT_ECHO_CANCELLER].get_block_size;
+
+ if ((ec_method = get_ec_method_from_string(pa_modargs_get_value(ma, "aec_method", DEFAULT_ECHO_CANCELLER))) < 0) {
+ pa_log("Invalid echo canceller implementation");
+ goto fail;
+ }
+
+ u->ec->init = ec_table[ec_method].init;
+ u->ec->run = ec_table[ec_method].run;
+ u->ec->done = ec_table[ec_method].done;
+ u->ec->get_block_size = ec_table[ec_method].get_block_size;
adjust_time_sec = DEFAULT_ADJUST_TIME_USEC / PA_USEC_PER_SEC;
if (pa_modargs_get_value_u32(ma, "adjust_time", &adjust_time_sec) < 0) {