don't move streams to devices that are going away
authorTanu Kaskinen <tanuk@iki.fi>
Sun, 13 Mar 2016 12:06:02 +0000 (14:06 +0200)
committerTanu Kaskinen <tanuk@iki.fi>
Mon, 25 Apr 2016 10:47:13 +0000 (13:47 +0300)
commit13fc8333873b5cfd5f42abf0b6071bb028d9f096
treec033c5eda5cc106edcf7522ee2adbdcb54eb04d5
parent0b6e4694a5a421cfc9eff0c0d259e46dc007f6b0
don't move streams to devices that are going away

Before a device is unlinked, the unlink hook is fired, and it's
possible that a routing module tries to move streams to the unlinked
device in that hook, because it doesn't know that the device is being
unlinked. Of course, the unlinking is obvious when the code is in an
unlink hook callback, but it's possible that some other module does
something in the unlink hook that in turn triggers some other hook,
and it's this second hook where the routing module may get confused.
This patch adds an "unlink_requested" flag that is set before the
unlink hook is fired, and moving streams to a device with that flag
set is prevented.

This patch is motivated by seeing module-device-manager moving a
stream to a sink that was being unlinked. It was a complex case where
an alsa card was changing its profile, while an echo-cancel sink was
connected to the old alsa sink. module-always-sink loaded a null sink
in the middle of the profile change, and after a stream had been
rescued to the null sink, module-device-manager decided to move it
back to the old alsa sink that was being unlinked. That move made no
sense, so I came up with this patch.
src/pulsecore/sink-input.c
src/pulsecore/sink.c
src/pulsecore/sink.h
src/pulsecore/source-output.c
src/pulsecore/source.c
src/pulsecore/source.h