fix a call to pa_sink_suspend() from an incorrect thread
authorTanu Kaskinen <tanuk@iki.fi>
Mon, 19 Mar 2018 21:11:05 +0000 (23:11 +0200)
committerTanu Kaskinen <tanuk@iki.fi>
Tue, 20 Mar 2018 11:05:26 +0000 (13:05 +0200)
commitad15e6e50e737fb55a87bb7def22332f774abce9
tree20a7ef8ac5f58dfdef4013091245d28440be203f
parentad0616d4c91de52b7cb69e6222efe96961755482
fix a call to pa_sink_suspend() from an incorrect thread

The alsa sink calls pa_sink_suspend() from the set_port() callback.
pa_sink_suspend() can only be called from the main thread, but the
set_port() callback was often called from the IO thread. That caused an
assertion to be hit in pa_sink_suspend() when switching ports.

Another issue was that pa_sink_suspend() called the set_port() callback,
and if the callback calls pa_sink_suspend() again recursively, nothing
good can be expected from that, so the thread mismatch was not the only
problem.

This patch moves the mixer syncing logic out of pa_sink/source_suspend()
to be handled internally by the alsa sink/source. This removes the
recursive pa_sink_suspend() call. This also removes the need to have the
mixer_dirty flag in pa_sink/source, so the flag and the
pa_sink/source_set_mixer_dirty() functions can be removed.

This patch also changes the threading rules of set_port(). Previously it
was called sometimes from the main thread and sometimes from the IO
thread. Now it's always called from the main thread. When deferred
volumes are used, the alsa sink and source still have to update the
mixer from the IO thread when switching ports, but the thread
synchronization is now handled internally by the alsa sink and source.
The SET_PORT messages are not needed any more and can be removed.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=104761
src/modules/alsa/alsa-sink.c
src/modules/alsa/alsa-source.c
src/pulsecore/sink.c
src/pulsecore/sink.h
src/pulsecore/source.c
src/pulsecore/source.h