ladspa-sink: Add sink_master argument to enable filter-apply to load the module

Currently, module-filter-apply cannot load module-ladspa-sink because filter-apply
provides the argument "sink_master" but ladspa-sink expects "master" instead.

Therefore this patch adds the sink_master argument to module-ladspa-sink.

Additionally, the autoloaded argument was also added.
This commit is contained in:
KimjeongYeon 2017-04-13 20:58:14 +02:00 committed by Georg Chini
parent ba4de85b53
commit 145da09aca

View file

@ -55,6 +55,7 @@ PA_MODULE_USAGE(
_("sink_name=<name for the sink> "
"sink_properties=<properties for the sink> "
"master=<name of sink to filter> "
"sink_master=<name of sink to filter> "
"format=<sample format> "
"rate=<sample rate> "
"channels=<number of channels> "
@ -63,9 +64,11 @@ PA_MODULE_USAGE(
"label=<ladspa plugin label> "
"control=<comma separated list of input control values> "
"input_ladspaport_map=<comma separated list of input LADSPA port names> "
"output_ladspaport_map=<comma separated list of output LADSPA port names> "));
"output_ladspaport_map=<comma separated list of output LADSPA port names> "
"autoloaded=<set if this module is being loaded automatically> "));
#define MEMBLOCKQ_MAXLENGTH (16*1024*1024)
#define DEFAULT_AUTOLOADED false
/* PLEASE NOTICE: The PortAudio ports and the LADSPA ports are two different concepts.
They are not related and where possible the names of the LADSPA port variables contains "ladspa" to avoid confusion */
@ -99,12 +102,14 @@ struct userdata {
#endif
bool auto_desc;
bool autoloaded;
};
static const char* const valid_modargs[] = {
"sink_name",
"sink_properties",
"master",
"master", /* Will be deprecated. */
"sink_master",
"format",
"rate",
"channels",
@ -114,6 +119,7 @@ static const char* const valid_modargs[] = {
"control",
"input_ladspaport_map",
"output_ladspaport_map",
"autoloaded",
NULL
};
@ -639,6 +645,19 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
}
}
/* Called from main context */
static bool sink_input_may_move_to_cb(pa_sink_input *i, pa_sink *dest) {
struct userdata *u;
pa_sink_input_assert_ref(i);
pa_assert_se(u = i->userdata);
if (u->autoloaded)
return false;
return u->sink != dest;
}
/* Called from main context */
static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {
struct userdata *u;
@ -968,9 +987,12 @@ int pa__init(pa_module*m) {
goto fail;
}
if (!(master = pa_namereg_get(m->core, pa_modargs_get_value(ma, "sink_master", NULL), PA_NAMEREG_SINK))) {
if (!(master = pa_namereg_get(m->core, pa_modargs_get_value(ma, "master", NULL), PA_NAMEREG_SINK))) {
pa_log("Master sink not found");
pa_log("Master sink not found.");
goto fail;
} else
pa_log("Argument 'master' will be deprecated, please use 'sink_master' instead.");
}
ss = master->sample_spec;
@ -1231,6 +1253,12 @@ int pa__init(pa_module*m) {
goto fail;
}
u->autoloaded = DEFAULT_AUTOLOADED;
if (pa_modargs_get_value_boolean(ma, "autoloaded", &u->autoloaded) < 0) {
pa_log("Failed to parse autoloaded value");
goto fail;
}
if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) {
const char *z;
@ -1283,6 +1311,7 @@ int pa__init(pa_module*m) {
u->sink_input->attach = sink_input_attach_cb;
u->sink_input->detach = sink_input_detach_cb;
u->sink_input->state_change = sink_input_state_change_cb;
u->sink_input->may_move_to = sink_input_may_move_to_cb;
u->sink_input->moving = sink_input_moving_cb;
u->sink_input->mute_changed = sink_input_mute_changed_cb;
u->sink_input->userdata = u;