My ultimate guide to the Raspberry pi audio server I wanted — Pulseaudio TCP

Published: 2020-04-19

Part 2 — Pulseaudio TCP

# EDIT 2025: If you’re reading this in 2025 or later, you might be more interested in this article and part 10 about PipeWire which covers the same features with PipeWire instead of PulseAudio

Since Bluetooth and PulseAudio now works, we can get on making the latter available on network. And it’s actually pretty easy

$ sudo apt install pulseaudio-module-zeroconf

In /etc/pulseaudio/default.pa, all you need to do then is adding the following lines according to your own network

load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/24  
load-module module-zeroconf-publish

On my clients, I also install pulseaudio-zeroconf and Avahi for service discovery according to their system.

$ sudo pacman -S pulseaudio-zeroconf avahi nss-mdns #archlinux  
$ sudo dnf install pulseaudio-module-zeroconf avahi #fedora  
$ sudo apt install pulseaudio-module-zeroconf avahi #debian

Then, on your clients you can use paprefs to enable network discovering

Image

paprefs

On ArchLinux paprefs didn’t work and i just uncommented the following line in /etc/pulseaudio/default.pa

load-module module-zeroconf-discover

Of course for the change to be effective, on both clients and server you need either to restart Pulseaudio

$ systemctl --user restart pulseaudio

or load the appropriate module on the fly with

$ # server  
$ pactl load-modules module-zeroconf-publish  
$ pactl load-modules module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/24  
$ # clients  
$ pactl load-modules module-zeroconf-discover

You should now see your pulseaudio sink from all clients through avahi when typing

$ avahi-browse -a |grep Pulse  
 + enp2s0 IPv6 pi@Ampli-BT: Built-in Audio Stereo PulseAudio Sound Sink local  
 + enp2s0 IPv4 pi@Ampli-BT: Built-in Audio Stereo PulseAudio Sound Sink local  
 + enp2s0 IPv6 pi@Ampli-BT PulseAudio Sound Server local  
 + enp2s0 IPv4 pi@Ampli-BT PulseAudio Sound Server local

and through pulseaudio with

$ pactl list sinks  
 …  
 Destination #49  
 État : SUSPENDED  
 Nom : tunnel.Ampli-BT.local.alsa_output.platform-soc_sound.stereo-fallback  
 Description : Built-in Audio Stereo on pi@Ampli-BT  
 Pilote : module-tunnel.c  
 Spécification de l'échantillon : s16le 2ch 44100Hz  
 Plan des canaux : front-left,front-right  
 Module du propriétaire : 83  
 Sourdine : non  
 Volume : front-left: 65536 / 100%, front-right: 65536 / 100%  
 balance 0,00  
 Volume de base : 65536 / 100%  
 Source du moniteur : tunnel.Ampli-BT.local.alsa_output.platform-soc_sound.stereo-fallback.monitor  
 Latence : 0 usec, configuré 0 usec  
 Marqueurs : NETWORK HW_MUTE_CTRL HW_VOLUME_CTRL LATENCY   
 Propriétés :  
 device.description = "Built-in Audio Stereo on pi@Ampli-BT"  
 tunnel.remote.server = "[192.168.0.15]:4713"  
 tunnel.remote.sink = alsa_output.platform-soc_sound.stereo-fallback"  
 device.icon_name = "computer"  
 tunnel.remote_version = "32"  
 tunnel.remote.user = "pi"  
 tunnel.remote.fqdn = "Ampli-BT"  
 tunnel.remote.description = "Built-in Audio Stereo"  
 Formats :  
 pcm

And can now use Pavucontrol or your desktop sound manager to redirect your audio to the Pi

Image

From Gnome settings

As I told in the Introduction, I used to have audio-video sync problems when using this way to redirect audio through network, but it’s not the case anymore, so maybe having pulseaudio as the only alsa client made things better, or tech improved, I don’t really know, but I really like how easy and flawless it is now.

Part 3: MPD