summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <git@arunraghavan.net>2016-02-17 19:46:58 +0530
committerArun Raghavan <git@arunraghavan.net>2016-02-25 09:09:12 +0530
commit0c86543c5105c1e1d690af121ac60d2743e58055 (patch)
treeb1f04de5ce19d9d850d5703a091b882fc7c95082
parent23ef4911227e69fb0c289a991e2b5d61bb1b0dd6 (diff)
downloadpulseaudio-0c86543c5105c1e1d690af121ac60d2743e58055.tar.gz
echo-cancel: Add a modarg to use sink/source master format and spec
This allows us to inherit the sample spec parameters from the sink and source master (rather than forcing 32 kHz / mono). It is still possible to override some of the parameters for the source side with modargs. My original testing showed that these parameters provided a decent perf/quality trade-off on lower end hardware (which I no longer have access to). I figure it makes sense to continue with that for now, and in the future this can be relaxed (use_master_format=yes could be the default, and resource-constrained systems can disable it).
-rw-r--r--src/modules/echo-cancel/module-echo-cancel.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index c3a6a1c9a..484281f01 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -75,6 +75,7 @@ PA_MODULE_USAGE(
"save_aec=<save AEC data in /tmp> "
"autoloaded=<set if this module is being loaded automatically> "
"use_volume_sharing=<yes or no> "
+ "use_master_format=<yes or no> "
));
/* NOTE: Make sure the enum and ec_table are maintained in the correct order */
@@ -140,6 +141,7 @@ static const pa_echo_canceller ec_table[] = {
#define DEFAULT_ADJUST_TOLERANCE (5*PA_USEC_PER_MSEC)
#define DEFAULT_SAVE_AEC false
#define DEFAULT_AUTOLOADED false
+#define DEFAULT_USE_MASTER_FORMAT false
#define MEMBLOCKQ_MAXLENGTH (16*1024*1024)
@@ -275,6 +277,7 @@ static const char* const valid_modargs[] = {
"save_aec",
"autoloaded",
"use_volume_sharing",
+ "use_master_format",
NULL
};
@@ -1659,6 +1662,7 @@ int pa__init(pa_module*m) {
pa_memchunk silence;
uint32_t temp;
uint32_t nframes = 0;
+ bool use_master_format;
pa_assert(m);
@@ -1684,15 +1688,30 @@ int pa__init(pa_module*m) {
goto fail;
}
- source_ss = source_master->sample_spec;
- source_ss.rate = DEFAULT_RATE;
- source_ss.channels = DEFAULT_CHANNELS;
- pa_channel_map_init_auto(&source_map, source_ss.channels, PA_CHANNEL_MAP_DEFAULT);
+ /* Set to true if we just want to inherit sample spec and channel map from the sink and source master */
+ use_master_format = DEFAULT_USE_MASTER_FORMAT;
+ if (pa_modargs_get_value_boolean(ma, "use_master_format", &use_master_format) < 0) {
+ pa_log("use_master_format= expects a boolean argument");
+ goto fail;
+ }
+ source_ss = source_master->sample_spec;
sink_ss = sink_master->sample_spec;
- sink_ss.rate = DEFAULT_RATE;
- sink_ss.channels = DEFAULT_CHANNELS;
- pa_channel_map_init_auto(&sink_map, sink_ss.channels, PA_CHANNEL_MAP_DEFAULT);
+
+ if (use_master_format) {
+ source_map = source_master->channel_map;
+ sink_map = sink_master->channel_map;
+ } else {
+ source_ss = source_master->sample_spec;
+ source_ss.rate = DEFAULT_RATE;
+ source_ss.channels = DEFAULT_CHANNELS;
+ pa_channel_map_init_auto(&source_map, source_ss.channels, PA_CHANNEL_MAP_DEFAULT);
+
+ sink_ss = sink_master->sample_spec;
+ sink_ss.rate = DEFAULT_RATE;
+ sink_ss.channels = DEFAULT_CHANNELS;
+ pa_channel_map_init_auto(&sink_map, sink_ss.channels, PA_CHANNEL_MAP_DEFAULT);
+ }
u = pa_xnew0(struct userdata, 1);
if (!u) {