[pulseaudio-discuss] [PATCH] ladspa-sink, virtual-surround-sink: fix master sink argument handling
Georg Chini
georg at chini.tk
Fri Apr 14 16:00:41 UTC 2017
On 14.04.2017 17:20, Tanu Kaskinen wrote:
> The old code worked incorrectly in several situations. For example,
> trying to use the "master" argument wouldn't work, because if
> "sink_master" wasn't specified, pa_namereg_get() would pick the default
> sink as the master sink.
> ---
> src/modules/module-ladspa-sink.c | 19 +++++++++++++------
> src/modules/module-virtual-surround-sink.c | 19 +++++++++++++------
> 2 files changed, 26 insertions(+), 12 deletions(-)
>
> diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
> index 2409d610b..7b0c0d6d3 100644
> --- a/src/modules/module-ladspa-sink.c
> +++ b/src/modules/module-ladspa-sink.c
> @@ -967,6 +967,7 @@ int pa__init(pa_module*m) {
> pa_channel_map map;
> pa_modargs *ma;
> char *t;
> + const char *master_name;
> pa_sink *master;
> pa_sink_input_new_data sink_input_data;
> pa_sink_new_data sink_data;
> @@ -987,12 +988,18 @@ 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.");
> - goto fail;
> - } else
> - pa_log("Argument 'master' will be deprecated, please use 'sink_master' instead.");
> + master_name = pa_modargs_get_value(ma, "sink_master", NULL);
> + if (!master_name) {
> + master_name = pa_modargs_get_value(ma, "master", NULL);
> + if (master_name)
> + pa_log_warn("The 'master' module argument is deprecated and may be removed in the future, "
> + "please use the 'sink_master' argument instead.");
> + }
> +
> + master = pa_namereg_get(m->core, master_name, PA_NAMEREG_SINK);
> + if (!master) {
> + pa_log("Master sink not found.");
> + goto fail;
> }
>
> ss = master->sample_spec;
> diff --git a/src/modules/module-virtual-surround-sink.c b/src/modules/module-virtual-surround-sink.c
> index 47716da21..60093e693 100644
> --- a/src/modules/module-virtual-surround-sink.c
> +++ b/src/modules/module-virtual-surround-sink.c
> @@ -581,6 +581,7 @@ int pa__init(pa_module*m) {
> pa_sample_spec ss, sink_input_ss;
> pa_channel_map map, sink_input_map;
> pa_modargs *ma;
> + const char *master_name;
> pa_sink *master = NULL;
> pa_sink_input_new_data sink_input_data;
> pa_sink_new_data sink_data;
> @@ -611,12 +612,18 @@ 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.");
> - goto fail;
> - } else
> - pa_log("Argument 'master' will be deprecated, please use 'sink_master' instead.");
> + master_name = pa_modargs_get_value(ma, "sink_master", NULL);
> + if (!master_name) {
> + master_name = pa_modargs_get_value(ma, "master", NULL);
> + if (master_name)
> + pa_log_warn("The 'master' module argument is deprecated and may be removed in the future, "
> + "please use the 'sink_master' argument instead.");
> + }
> +
> + master = pa_namereg_get(m->core, master_name, PA_NAMEREG_SINK);
> + if (!master) {
> + pa_log("Master sink not found.");
> + goto fail;
> }
>
> pa_assert(master);
Looks good to me, sorry for not spotting that pa_namereg would pick the
default sink
if sink_master was not specified.
More information about the pulseaudio-discuss
mailing list