[pulseaudio-discuss] [PATCH] filter-apply: Ignore monitor source of filter in find_paired_master()

Tanu Kaskinen tanuk at iki.fi
Wed Feb 7 12:21:51 UTC 2018

On Tue, 2018-02-06 at 20:26 +0100, Georg Chini wrote:
> When module-filter-apply tries to find a matching source-output for
> a given sink-input and a stream with the same role

Shouldn't this be "with the same group", not "with the same role"?

> exists on the
> monitor source of the filter, module-filter apply falsely assumes
> that the source belongs to another instance of the filter and tries
> to access source->output_from_master->source, which leads to a
> segmentation fault.
> This patch fixes the issue by ignoring the stream if the source is
> the monitor source of the filter.

Is ignoring the stream really the right solution? Previously any source
output in the same group as the sink input would be accepted, no matter
how it was routed. If the source output was already routed to the
correct filter, then we'd pick the master source through
"output_from_master", and if the source output was not correctly routed
yet, we'd pick the current source as the master.

In this case the source output is wrongly determined as "already
correctly routed", so shouldn't we fix the issue by setting the current
source as the master source, like in all other cases where the source
output is not yet correctly routed? No, because we can't make the
filter source use the filter sink's monitor as the master source. It
seems that the correct solution would be to find the filter source that
corresponds to the filter sink, and then use "output_from_master" to
set the master source. In case you don't follow, I'll put some code

> Bug link: https://bugs.freedesktop.org/show_bug.cgi?id=104958
> ---
>  src/modules/module-filter-apply.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c
> index 783d85ed..163d52a2 100644
> --- a/src/modules/module-filter-apply.c
> +++ b/src/modules/module-filter-apply.c
> @@ -259,6 +259,12 @@ static bool find_paired_master(struct userdata *u, struct filter *filter, pa_obj
>                  if (pa_streq(g, group)) {
>                      if (pa_streq(module_name, so->source->module->name)) {
> +                        /* Make sure we are not routing to the monitor source
> +                         * of the same filter */
> +                        if (so->source->monitor_of) {
> +                            pa_xfree(g);
> +                            continue;
> +                        }

So I'd do this instead:

/* The source output is currently routed to the monitor
 * source of the filter. We can't use the monitor source
 * of the same filter as the master source. Let's find
 * the real source of the filter, and then use its master
 * source. */
if (so->source->monitor_of) {
    pa_source *source;
    PA_IDXSET_FOREACH(source, u->core->sources, idx) {
        if (source->module == so->source->monitor_of->module && source->output_from_master) {
            filter->source_master = source->output_from_master->source;



More information about the pulseaudio-discuss mailing list