I am using Raspbmc (with Kodi 14) on my Raspberry Pi. Now I would like to set up pulseaudio
to be able to stream music from all my Linux computers easily to the Raspberry pi.
My problem is, that I am not able to get pulseaudio running on the Raspberry Pi. I tried the following steps:
1. Install pulseaudio
sudo apt-get install pulseaudio pulseaudio-module-zeroconf
2. Setting up pulseaudio
sudo nano /etc/pulse/default.pa
I added the following lines:
load-module module-native-protocol-unix auth-anonymous=1
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.1.0/24 auth-anonymous=1
load-module module-zeroconf-publish
3. Start pulseaudio
First I tried to start pulse as daemon:
pulseaudio -D
I also tried to start it system wide:
sudo pulseaudio --system
But pulse does not show up on my other machines at all (it is configured correctly there as they find each other).
What is wrong here?
Best Answer
You have to edit
system.pa
, notdefault.pa
. When you log in to your RPI and runps fax
you will notice this line:The
--system
is what makes pulseaudio readsystem.pa
instead ofdefault.pa
. Also notice, kodi already launches an instance of pulseaudio for you and you can't simply start another one. The first will bind to0.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):
module-zeroconf-discover
(pactl load-module module-zeroconf-discover
) andpaprefs
to enable remote sinks. You have to check the first checkbox on the first tabpaprefs
shows. (Simply loading the module wasn't enough for me.)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: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 runexport PULSE_SERVER=rpi02.local:4713; spotify
it works. The approach of settingPULSE_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.
sudo sed -i 's/^\(load-module module-udev-detect\)/\1 tsched=0/' /etc/pulse/system.pa
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 puttingtsched=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.