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).
This commit is contained in:
Arun Raghavan 2016-02-17 19:46:58 +05:30
parent 23ef491122
commit 0c86543c51

View file

@ -75,6 +75,7 @@ PA_MODULE_USAGE(
"save_aec=<save AEC data in /tmp> " "save_aec=<save AEC data in /tmp> "
"autoloaded=<set if this module is being loaded automatically> " "autoloaded=<set if this module is being loaded automatically> "
"use_volume_sharing=<yes or no> " "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 */ /* 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_ADJUST_TOLERANCE (5*PA_USEC_PER_MSEC)
#define DEFAULT_SAVE_AEC false #define DEFAULT_SAVE_AEC false
#define DEFAULT_AUTOLOADED false #define DEFAULT_AUTOLOADED false
#define DEFAULT_USE_MASTER_FORMAT false
#define MEMBLOCKQ_MAXLENGTH (16*1024*1024) #define MEMBLOCKQ_MAXLENGTH (16*1024*1024)
@ -275,6 +277,7 @@ static const char* const valid_modargs[] = {
"save_aec", "save_aec",
"autoloaded", "autoloaded",
"use_volume_sharing", "use_volume_sharing",
"use_master_format",
NULL NULL
}; };
@ -1659,6 +1662,7 @@ int pa__init(pa_module*m) {
pa_memchunk silence; pa_memchunk silence;
uint32_t temp; uint32_t temp;
uint32_t nframes = 0; uint32_t nframes = 0;
bool use_master_format;
pa_assert(m); pa_assert(m);
@ -1684,6 +1688,20 @@ int pa__init(pa_module*m) {
goto fail; goto fail;
} }
/* 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;
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 = source_master->sample_spec;
source_ss.rate = DEFAULT_RATE; source_ss.rate = DEFAULT_RATE;
source_ss.channels = DEFAULT_CHANNELS; source_ss.channels = DEFAULT_CHANNELS;
@ -1693,6 +1711,7 @@ int pa__init(pa_module*m) {
sink_ss.rate = DEFAULT_RATE; sink_ss.rate = DEFAULT_RATE;
sink_ss.channels = DEFAULT_CHANNELS; sink_ss.channels = DEFAULT_CHANNELS;
pa_channel_map_init_auto(&sink_map, sink_ss.channels, PA_CHANNEL_MAP_DEFAULT); pa_channel_map_init_auto(&sink_map, sink_ss.channels, PA_CHANNEL_MAP_DEFAULT);
}
u = pa_xnew0(struct userdata, 1); u = pa_xnew0(struct userdata, 1);
if (!u) { if (!u) {