replace sink/source SET_STATE handlers with callbacks
authorTanu Kaskinen <tanuk@iki.fi>
Tue, 13 Mar 2018 17:40:38 +0000 (19:40 +0200)
committerTanu Kaskinen <tanuk@iki.fi>
Fri, 16 Mar 2018 18:05:38 +0000 (20:05 +0200)
commitb2537a8f38ad71e4dee57263310235abdf2b95a4
treeec877552e8aa38047f2db65775b2282c53800426
parent73b8a57078b94033edf84de2fc0cfbe344c10dcd
replace sink/source SET_STATE handlers with callbacks

There are no behaviour changes, the code from almost all the SET_STATE
handlers is moved with minimal changes to the newly introduced
set_state_in_io_thread() callback. The only exception is module-tunnel,
which has to call pa_sink_render() after pa_sink.thread_info.state has
been updated. The set_state_in_io_thread() callback is called before
updating that variable, so moving the SET_STATE handler code to the
callback isn't possible.

The purpose of this change is to make it easier to get state change
handling right in modules. Hooking to the SET_STATE messages in modules
required care in calling pa_sink/source_process_msg() at the right time
(or not calling it at all, as was the case on resume failures), and
there were a few bugs (fixed before this patch). Now the core takes care
of ordering things correctly.

Another motivation for this change is that there was some talk about
adding a suspend_cause variable to pa_sink/source.thread_info. The
variable would be updated in the core SET_STATE handler, but that would
not work with the old design, because in case of resume failures modules
didn't call the core message handler.
25 files changed:
src/modules/alsa/alsa-sink.c
src/modules/alsa/alsa-source.c
src/modules/bluetooth/module-bluez4-device.c
src/modules/bluetooth/module-bluez5-device.c
src/modules/echo-cancel/module-echo-cancel.c
src/modules/module-combine-sink.c
src/modules/module-equalizer-sink.c
src/modules/module-esound-sink.c
src/modules/module-ladspa-sink.c
src/modules/module-null-sink.c
src/modules/module-null-source.c
src/modules/module-pipe-sink.c
src/modules/module-remap-sink.c
src/modules/module-sine-source.c
src/modules/module-solaris.c
src/modules/module-tunnel-sink-new.c
src/modules/module-tunnel-source-new.c
src/modules/module-virtual-sink.c
src/modules/module-virtual-surround-sink.c
src/modules/oss/module-oss.c
src/modules/raop/raop-sink.c
src/pulsecore/sink.c
src/pulsecore/sink.h
src/pulsecore/source.c
src/pulsecore/source.h