Created attachment 7528 Experimental patch Currently pa-plugin allows the user to change the default output device so new streams will sink into it. Unfortunately this is not the case for existing streams, one must open pavucontrol to change each of them. This is very annoying, therefore I have prepped the attached patch to tackle this issue. It is straightforward, the only trouble is that when pa_context_move_sink_input_by_name is called, it spawns sink, source and sink source events that call pulseaudio_volume_sink_source_check which causes the device output change again to the previous selected. I have commented the handling of those events just to demonstrate that it works. I tried some hacks such as locks and counters, but they won't work due the asynchronicity of pulseaudio's API.
Created attachment 7529 Tweaked Patch I moved around some of the events and the issues previously described do not appear when switching between 4 audio outputs.
Unfortunately your patch doesn't fix the problem I had to workaround, two subsequent calls are made, e.g.: Moving Sink Input: Spotify Moving Sink Input: Spotify
Created attachment 7614 Tweaked Patch V2 Can you give it another shot? I've changed up my hardware config and still can't reproduce with my latest patch. Added back the missing debug output that I had stripped out before.
The patch works for me now, even though it's practically the same as before, guess it works now due recent commits.
Sean Davis referenced this bugreport in commit ef5822f7c71c8008223b670d399088dc7256e77a Move streams on default output device change (Bug #14157) https://git.xfce.org/panel-plugins/xfce4-pulseaudio-plugin/commit?id=ef5822f7c71c8008223b670d399088dc7256e77a
Resolved with the above commit.