diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2010-09-07 14:02:32 +0530 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2011-03-28 14:41:00 +0530 |
commit | 4a9fa8cc7ff0963fbf794a0018445604f69721e7 (patch) | |
tree | ba9dc3bd2443940ef401d7631fe48635584bd64d | |
parent | 47e4dd1ec43298f4d5b8165b772b07f95589966e (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.
-rw-r--r-- | src/modules/echo-cancel/module-echo-cancel.c | 35 |
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) { |