Hi, I made a Node/JS script to switch between sound sources on Linux, and bound it to a keyboard shortcut. It has an issue that I haven’t been able to fix.
“pacmd list-sink-inputs” lists all programs currently outputting sound, and “pacmd move-sink-input” can then be used to switch them to the desired device. When you set a default device with “pacmd set-default-sink”, the default device changes, but all of the programs that were using the previous device, will remain using it unless they’ve been manually switched to the new default one.
Does anyone have a solution for this problem?
I may me bring about this but I think this is somewhat dependent on the program at hand, a lot of programs on windows even don’t support switching audio devices properly if at all. I know some games where audio just straight up dies when you switch devices, even switching back doesn’t fix it and you have to restart game. For chromium based browsers it’s always been an issue for me too, depending on chromium version I need to either do nothing, pause and resume, or restart it to make it work…
Though I could be completely wrong about this since Linux’ sound system obviously works very different to begin with
load-module module-stream-restore restore_device to
/etc/pulse/default.pa. Further reading here:
Not sure if this will cause the streams to switch in real-time, or if it will only take effect for new streams. If so, I guess you can just iterate through the current inputs and switch them all with move-sink-input.
Personal note:I really hate PA’s default behavior; I think it’s much better with this option changed. I’ve never wanted to output different programs to different sources, and when I unplug a external display from my laptop, I have to “unmute” programs one-by-one (since they “remember” the HDMI audio sink)…not fun.
Commenting the “load-module module-stream-restore” line did the trick. Thanks for your help.