Automatically switch pulseaudio sink to remote server when available

0

1

I would like to configure my pulseaudio so that it will always play on a remote server if that is available, but will seamlessly switch to the local sound system if the remote is not available. Also if the remote becomes avaiale again, it should switch back.

Is that possible at all? Tunnels look promising, but I have not gotten it to work.

I can see the local and remote sinks:

isaac@auko:~$ pactl list short sinks
0       alsa_output.pci-0000_00_1b.0.analog-stereo      module-alsa-card.c      s16le 2ch 44100Hz       SUSPENDED
1       tunnel.gaysboard.local.alsa_output.pci-0000_00_1b.0.analog-stereo       module-tunnel.c s16le 2ch 44100Hz        SUSPENDED
2       tunnel.gaysboard.local.alsa_output.pci-0000_00_1b.0.analog-stereo.2     module-tunnel.c s16le 2ch 44100Hz        SUSPENDED

They also show up in pavucontrol. Also, I can not select the output device in pavucontrol - I was under the impression that this should be possible. Am I correct?

So how can I set up automatic switching? And how can I choose the device with pavucontrol? (I can choose it with pax11publish)

Isaac

Posted 2015-09-08T20:32:01.943

Reputation: 944

Answers

0

I fiddled around with the solution suggested by rwx, and finally decided that I want to do something which is a bit different from my original question. I put together a little pseudo gui using zenity, which uses pax11publish to modify the settings on demand. I also added a .desktop file so that it can be called directly from a desktop environment. Here is the link. I think for gnome there is already an integrated solution, but not for xfce, which is why I asked in the first place.

Isaac

Posted 2015-09-08T20:32:01.943

Reputation: 944

1

Remote Playback with zeroconf and tunnels are still buggy. Stuttering will appear after some time.

To fix this you can define your default server e.g. in your personal config (/home/xy/.config/pulse/client.conf) by Setting default-server = IP.

If you want so check if your remote device is available you could run a bash script that checks if is pingable and if its available then copy a predefined_config_file to your pulse-config-folder:

if ping -c 1 YOUR_IP &> /dev/null; then notify-send "Changing to remote system" && cp predefined_remote_config_file /home/xy/.config/pulse/client.conf; else notify-send "Changing to local system" && cp predefined_local_config_file /home/xy/.config/pulse/client.conf; fi

Maybe you Need to restart pulseaudio, whats also could be done by the bash script

rwx

Posted 2015-09-08T20:32:01.943

Reputation: 219

After fiddling around with this for a bit, it occured to me that I should also address wake up after sleep, and that there could be more then one user logged in when waking up. It appeared more and more complicated, which is why I took a different approach, see my answer. – Isaac – 2015-09-11T18:17:11.507