You have to edit system.pa
, not default.pa
. When you log in to your RPI and run ps fax
you will notice this line:
/usr/bin/pulseaudio --system --realtime --log-target=syslog --log-level=1 --disallow-exit --disable-shm --exit-idle-time=-1
The --system
is what makes pulseaudio read system.pa
instead of default.pa
. Also notice, kodi already launches an instance of pulseaudio for you and you can't simply start another one. The first will bind to 0.0.0.0:4713
, so the second instance won't be able to! My kodi won't let me restart pulseaudio, so a reboot is required after changing the configuration file.
To make the remote sink actually show up on clients you have to (on the client):
- load the module
module-zeroconf-discover
(pactl load-module module-zeroconf-discover
) and
- use
paprefs
to enable remote sinks. You have to check the first checkbox on the first tab paprefs
shows. (Simply loading the module wasn't enough for me.)
- restart avahi-daemon on the client.
You can use avahi-browse -a
on your client to see if it actually sees your pa service. The important line will look like this:
+ wlan0 IPv4 root@raspbmc PulseAudio Sound Server local
I just did this about 2h ago and it doesn't really work for me. Yes, the remote sink shows up in pavucontrol
and I can set it as default sink and control its volume, but spotify wouldn't work (Does not play music. Was my only test.). When I open a terminal and run export PULSE_SERVER=rpi02.local:4713; spotify
it works. The approach of setting PULSE_SERVER
works out of the box without any of this zeroconf shenanigans. (This maybe an Ubuntu spefic issue though.)
And if you intent to involve wifi there is another RPI specific issue:
There is the common problem of garbled audio playback when using the Pi's pulseaudio remotely over a network. Apparently using wifi frequently triggers this problem, but it's still a Pi-hardware specific problem with an available solution.
- On your RPi:
sudo sed -i 's/^\(load-module module-udev-detect\)/\1 tsched=0/' /etc/pulse/system.pa
- restart pulseaudio on the Pi
- connect remote clients to the pa server on the Pi
This is a known issue stated together with this solution on kodi.wiki. Reading up on tsched
, for example on ubunutu SE, we learn that it's a timing issue and arises from the sound hardware. By putting tsched=0
Linux uses a different timing model, which I believe is more CPU intense. With this solution, the pulseaudio service claims 17% CPU on my B+ when playing one remote stream.
Best Answer
A raw stream does not contain any meta-information about its format, so you have to tell sox about it: