[pulseaudio-discuss] [PATCH 1/3] virtual-surround-sink: filter-apply able to load this module.

KimJeongYeon see2002 at gmail.com
Mon Apr 10 08:11:05 UTC 2017


2017. 4. 9. 오후 6:43에 "Georg Chini" <georg at chini.tk>님이 작성:

On 07.04.2017 16:47, KimJeongYeon wrote:

> Currently, 'filter-apply' cannot load 'virtual-surround-sink' filter
> module.
> Because, it always fails due to argument mismatching between
> 'filter-apply' and 'virtual-surround-sink'.
> (e.g 'master' used instead of 'sink_master') To solve this issue, added
> 'sink_master' argument.
> Additionally, supports autoloaded feature too.
>
> Signed-off-by: KimJeongYeon <jeongyeon.kim at samsung.com>
> ---
>   src/modules/module-virtual-surround-sink.c | 41
> ++++++++++++++++++++++++++----
>   1 file changed, 36 insertions(+), 5 deletions(-)
>
> diff --git a/src/modules/module-virtual-surround-sink.c
> b/src/modules/module-virtual-surround-sink.c
> index 4a53623..63ab679 100644
> --- a/src/modules/module-virtual-surround-sink.c
> +++ b/src/modules/module-virtual-surround-sink.c
> @@ -51,6 +51,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> "
> @@ -58,9 +59,11 @@ PA_MODULE_USAGE(
>             "use_volume_sharing=<yes or no> "
>             "force_flat_volume=<yes or no> "
>             "hrir=/path/to/left_hrir.wav "
> +          "autoloaded=<set if this module is being loaded automatically> "
>           ));
>     #define MEMBLOCKQ_MAXLENGTH (16*1024*1024)
> +#define DEFAULT_AUTOLOADED false
>     struct userdata {
>       pa_module *module;
> @@ -87,12 +90,15 @@ struct userdata {
>         float *input_buffer;
>       int input_buffer_offset;
> +
> +    bool autoloaded;
>   };
>     static const char* const valid_modargs[] = {
>       "sink_name",
>       "sink_properties",
> -    "master",
> +    "master",  /* Will be deprecated. */
> +    "sink_master",
>       "format",
>       "rate",
>       "channels",
> @@ -100,6 +106,7 @@ static const char* const valid_modargs[] = {
>       "use_volume_sharing",
>       "force_flat_volume",
>       "hrir",
> +    "autoloaded",
>       NULL
>   };
>   @@ -428,6 +435,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;
>

Why can't the sink input move when the filter is auto-loaded? Isn't it
perfectly
normal to change the sink even in that situation? What if the original sink
goes
away, would you then prefer to kill the stream?


Currently, filter-apply loads filters using 'autoloaded=1' by default to
prevent move.
I think it is original idea of filter-apply.
echo-cancel, equalizer-sink are already adopt it.


+
> +    return u->sink != dest;
> +}
> +
> +/* Called from main context */
>   static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {
>       struct userdata *u;
>   @@ -561,7 +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;
> -    pa_sink *master=NULL;
> +    pa_sink *master = NULL;
>       pa_sink_input_new_data sink_input_data;
>       pa_sink_new_data sink_data;
>       bool use_volume_sharing = true;
> @@ -591,9 +611,13 @@ int pa__init(pa_module*m) {
>           goto fail;
>       }
>   -    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;
> +    if (!(master = pa_namereg_get(m->core, pa_modargs_get_value(ma,
> "sink_master", NULL), PA_NAMEREG_SINK))) {
> +        pa_log("Master sink not found at 'sink_master' argument.");
> +        if (!(master = pa_namereg_get(m->core, pa_modargs_get_value(ma,
> "master", NULL), PA_NAMEREG_SINK))) {
> +            pa_log("Master sink not found at 'master' argument.");
> +            goto fail;
> +        } else
> +            pa_log("Argument 'master' will be deprecated, please use
> 'sink_master' instead.");
>       }
>

I would remove the first log message and change the second simply to
"Master sink not found". The additional log message does not provide
any useful information since you already include a message that the
"master" argument is deprecated.


Ok, I got it. I'll submit patch soon.



        pa_assert(master);
> @@ -672,6 +696,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;
>   @@ -731,6 +761,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->volume_changed = use_volume_sharing ? NULL :
> sink_input_volume_changed_cb;
>       u->sink_input->mute_changed = sink_input_mute_changed_cb;
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20170410/ff683205/attachment.html>


More information about the pulseaudio-discuss mailing list