In the V3, I addressed all Tanu's and Georg's comments: 0002-xxx.patch: remove the pa_subscription_post() in the pa_sink_input_set_preferred_sink() 0003-xxx.patch: Add the check of sink_input->sink->card in the subscribe_callback() 0004-xxx.patch: Initialize the varible old_sink_is_unavailable Add the check of core->default_sink == NULL || core->default_sink->unlink_requested in the pa_sink_move_streams_to_default_sink() 0007-xxx.patch: Move the calling of pa_sink_move_streams_to_default_sink() after the pa_core_update_default_sink() in the pa_sink_unlink() Add shutdown check in the pa_sink_move_streams_to_default_sink() Change the logging message in the pa_sink_move_streams_to_default_sink() Remove the sink and sink_input parts in the module-rescue-streams.c ============================================================ This is based on Tanu's design: https://lists.freedesktop.org/archives/pulseaudio-discuss/2018-October/030531.html And this is only for sink-input and sink, not for source-output and source. In the V2, I addressed all comments of V1 and split the big patch into small patches as suggested by Tanu. It will be easy to review in the future. Hui Wang (8): sink-input: change bool save_sink to char *preferred_sink sink-input: add a new API pa_sink_input_set_preferred_sink sink-input: clear the preferred_sink if it is default_sink core: move sink-inputs conditionally when update default_sink sink: move streams to new appeared sinks if they prefer these sinks device-port: moving streams due to changing the status of active_port sink: move the streams to the default_sink when the sink is unlinked stream-restore: skip entries setting action from gnome-control-center src/modules/dbus/iface-core.c | 2 +- src/modules/module-default-device-restore.c | 2 +- src/modules/module-device-manager.c | 8 +- src/modules/module-intended-roles.c | 2 +- src/modules/module-rescue-streams.c | 134 +---------------- src/modules/module-stream-restore.c | 151 +++++--------------- src/modules/module-switch-on-connect.c | 27 +--- src/pulsecore/cli-command.c | 2 +- src/pulsecore/core.c | 38 ++++- src/pulsecore/core.h | 6 +- src/pulsecore/device-port.c | 32 ++++- src/pulsecore/device-port.h | 2 + src/pulsecore/protocol-native.c | 2 +- src/pulsecore/sink-input.c | 41 +++++- src/pulsecore/sink-input.h | 19 ++- src/pulsecore/sink.c | 46 +++++- src/pulsecore/sink.h | 6 + 17 files changed, 215 insertions(+), 305 deletions(-) -- 2.17.1 _______________________________________________ pulseaudio-discuss mailing list pulseaudio-discuss@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss