virtual sources and sinks: Don't double attach a sink input or source output on filte...
authorGeorg Chini <georg@chini.tk>
Thu, 18 May 2017 05:46:46 +0000 (07:46 +0200)
committerGeorg Chini <georg@chini.tk>
Thu, 18 May 2017 05:46:46 +0000 (07:46 +0200)
commitedc465da77874a1058cec0ab3714922e1ec0cc27
tree85c4cfe36c78b0f60e060bbde1df6ea10b786b5f
parent00aeedfe98e915593fc4336604bf3bb8c8a5c322
virtual sources and sinks: Don't double attach a sink input or source output on filter load

When a filter is loaded and module-switch-on-connect is present, switch-on-connect
will make the filter the default sink or source and move streams from the old
default to the filter. This is done from the sink/source put hook, therefore streams
are moved to the filter before the module init function of the filter calls
sink_input_put() or source_output_put(). The move succeeds because the asyncmsq
already points to the queue of the master sink or source. When the master sink or
source is attached to the sink input or source output, the attach callback will call
pa_{sink,source}_attach_within_thread(). These functions assume that all streams
are detached. Because streams were already moved to the filter by switch-on-connect,
this assumption leads to an assertion in pa_{sink_input,source_output}_attach().

This patch fixes the problem by reverting the order of the pa_{sink,source}_put()
calls and the pa_{sink_input,source_output}_put calls and creating the sink input
or source output corked. The initial rewind that is done for the master sink is
moved to the sink message handler. The order of the unlink calls is swapped as well
to prevent that the filter appears to be moving during module unload.

The patch also seems to improve user experience, the move of a stream to the filter
sink is now done without any audible interruption on my system.

The patch is only tested for module-echo-cancel.

Link: https://bugs.freedesktop.org/show_bug.cgi?id=100065
src/modules/echo-cancel/module-echo-cancel.c
src/modules/module-equalizer-sink.c
src/modules/module-ladspa-sink.c
src/modules/module-remap-sink.c
src/modules/module-remap-source.c
src/modules/module-virtual-sink.c
src/modules/module-virtual-source.c
src/modules/module-virtual-surround-sink.c