pof
Posts: 1
Joined: Fri Jul 13, 2012 8:23 pm

PulseAudio network sink

Fri Jul 13, 2012 8:46 pm

Hi,

Here's a quick guide to set up a RPI as a PulseAudio network sink. It's based on the Debian image.

1. Upgrade to the latest kernel version using rpi-update.
There are a couple of important fixes to the alsa driver. https://github.com/Hexxeh/rpi-update/

2. Load the sound driver on boot
#sudo nano /etc/modules

Add this line:

snd_bcm2835

3. Install PulseAudio and avahi
#sudo apt-get install pulseaudio pulseaudio-module-zeroconf avahi-daemon

4. Make PulseAudio start on boot
#sudo nano /etc/default/pulseaudio
Change PULSEAUDIO_SYSTEM_START to 1

5. Configure PulseAudio to work over network.
#sudo nano /etc/pulse/system.pa

Add these lines. Change to suite your network if needed.

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

6. Reboot you Pi.

Your Pi should now appear as an Output Device in the sound settings on your Linux Desktop. On my own system I only want the sound from Spotify to be routed to the Pi. To do this you can write a small script to set up PULSE_SINK and PULSE_SOURCE before starting Spotify. This will work with any application.

Code: Select all

#!/bin/bash

export PULSE_SINK=tunnel.raspberrypi.local.alsa_output.0.analog-stereo
export PULSE_SOURCE=tunnel.raspberrypi.local.alsa_output.0.analog-stereo.monitor
/usr/bin/spotify


s7mx1
Posts: 78
Joined: Fri Sep 30, 2011 9:28 am

Re: PulseAudio network sink

Tue Jul 17, 2012 2:23 pm

If you want to try pulseaudio 2.0 binary you can head over to this thread

http://forum.stmlabs.com/showthread.php?tid=1052


The one in debian squeeze is way outdated.

kabelgleichung
Posts: 1
Joined: Sat Nov 03, 2012 10:56 am

Re: PulseAudio network sink

Sat Nov 03, 2012 11:05 am

I am interested in setting up a pulseaudio-sink, too. How is performance of your setup? Did you stream to the pulseaudio sink using (USB-) WLAN?

pete-panic
Posts: 1
Joined: Sun Nov 25, 2012 1:35 pm

Re: PulseAudio network sink

Sun Nov 25, 2012 1:49 pm

Thanks! Works fine! If you have problems you can try this..

Check if daemon is running
#sudo /etc/init.d/pulseaudio status

Manually start pulseaudio in system mode
Using config in /etc/pulse/system.pa
#sudo pulseaudio -vvv --system

Manually start pulseaudio in session mode
Using config in /etc/pulse/default.pa
#pulseaudio -vvv

Zerwan_
Posts: 1
Joined: Sat Dec 15, 2012 8:40 pm

Re: PulseAudio network sink

Sat Dec 15, 2012 8:47 pm

Hello !

I applied the guide, and a pulseaudio server is indeed running on my raspberry pi :

Code: Select all

pi@raspberrypi ~ $ sudo /etc/init.d/pulseaudio status
[ ok ] system-wide PulseAudio is running.
However, it doesn't appear in the audio output devices list of the 2 desktop computers of the same local network. Both computers are running Fedora 17/18.

I've tried to apply what is explained here (using paprefs to enable local network pulseaudio) : http://www.unixmen.com/stream-music-wir ... e-chooser/

But it still doesn't appear in my output devices.

Did I forget something ?


Thanks for your guide btw ! :)

xfx
Posts: 24
Joined: Thu Dec 06, 2012 10:09 pm

Re: PulseAudio network sink

Mon Dec 31, 2012 4:34 am

I just got it working... and the problem wasn't the Raspberry Pi, but my linux distro.

Here's what I did:

- Install "paprefs"
(I'm using Linux Mint so I used the Synaptic Package Manager)

- You should now have a launcher to start "PulseAudio Preferences" (paprefs)
If you can't find the shortcut, run it manually from /usr/bin/paprefs

- Under "Network Access" enable "Make discoverable PulseAudio network sound devices available locally"

- Under "Network Server" enable "Enable network access to local sound devices" and tick both options
(This is probably not necessary, unless you also want to use your linux box as a server/sink)

- Under "Multicas/RTP" enable both options

- Check your available output devices; if your raspberry is still unavailable, try restarting your linux box

- The Raspberry Pi should now appear on your available output devices

UPDATE:
I can confirm that this also works with Ubuntu 12.xx
Additionally, in case anyone is interested, the paprefs package is also available for the Raspberry Pi.

runeks
Posts: 20
Joined: Mon Jul 23, 2012 11:34 am

Re: PulseAudio network sink

Sat Jan 12, 2013 6:33 pm

Thanks a lot for creating this guide! This is really a useful application for a Pi. If you buy a good USB DAC you can have a really good a flexible audio system for a low price.

I'm having a problem though. There are intermittent glitches in the sound when playing from my Chromebook over wifi. I checked the network traffic that is generated by this, and it's around 170 KB/s. Nothing that my wifi shouldn't be able to handle (I'm connected at 121 Mb/s).

So I'm thinking it's probably a buffer problem.

Is there a way to adjust the buffer size for this setup?

xfx
Posts: 24
Joined: Thu Dec 06, 2012 10:09 pm

Re: PulseAudio network sink

Sat Jan 12, 2013 8:37 pm

Lucky you it is at least working over Wifi -- my old Linksys crashes if I even dare to use PulseAudio!

There are tons of complains about PulseAudio utilizing too much bandwidth over Wifi:
https://www.google.com/search?q=pulseaudio+wifi

I'm not sure if there are any workarounds to make it work correctly.

runeks
Posts: 20
Joined: Mon Jul 23, 2012 11:34 am

Re: PulseAudio network sink

Sat Jan 12, 2013 10:45 pm

I don't think it's a bandwidth issue. nethogs says it's using around 170 KB/s, which it should for a 44.1 kHz 16 bit stereo stream. That's very little on a 100 mbit link. I think the issue is either related to intermittent fallouts in the network stream, which - when they are longer than the buffer size - will result in a drop-out. So it would be really handy to be able to set the buffer size on the server/daemon.

Another issue could be clock synchronization. Clocks aren't 100% accurate, so if the clock on the Pi is really playing, for example, 1% faster than 44.1 kHz, and my computer is sending audio 1% slower than 44.1 kHz, then that will result in a drop-out at some point.

xfx
Posts: 24
Joined: Thu Dec 06, 2012 10:09 pm

Re: PulseAudio network sink

Sat Jan 12, 2013 11:47 pm

That's an interesting and quite feasible explanation, unfortunately, I cannot test it myself because as soon as I try to play audio from my laptop (connected wirelessly), my Linksys freezes (something that has never happened before) and I need to power cycle it.

However, if I stream from a virtualized instance of Linux Mint to the Raspberry Pi, where the host is wire-connected to the router, everything works perfectly.

As for my particular problem, it could be that the Broadcom driver I'm using on my laptop (which is also running Linux Mint) is extremely unstable - so, perhaps, my problem is the driver and not the wireless connection itself.
I'll try connecting the laptop directly to the router and see what happens...

Have you tried streaming with a wired connection?
I'm curios to know if that solves your audio dropouts/glitches.

runeks
Posts: 20
Joined: Mon Jul 23, 2012 11:34 am

Re: PulseAudio network sink

Sun Jan 13, 2013 12:13 am

I wanted to try it with a wired connection, but my wired computer couldn't see the network sound card. I'll have to try again later, cause that's definitely relevant.

I've also experienced strange network problems when playing over a wireless connection though. Not sure if it's related to yours. I'm using a Samsung ARM Chromebook running Ubuntu, and when this computer has its output set to the network sound card on the Pi, sometimes the network connection will hang completely, and programs like ifconfig won't work (it just hangs the terminal). I can't even restart or shut down the computer. When I try, I get to a full screen console, and all I see is the following error message (repeating every few seconds):

Code: Select all

mwifiex_sdio mmc2:0001:1: 2274602 : Tx timeout, bss_type-num = 0-0
Sounds like an odd bug though. Audio packets (or zeroconf?) specifically causing trouble for network drivers/devices.

xfx
Posts: 24
Joined: Thu Dec 06, 2012 10:09 pm

Re: PulseAudio network sink

Sun Jan 13, 2013 12:27 am

Yes, those are the same symptoms although I haven't checked what (if anything) is reported on the console, as Mint keeps me in the graphic environment.

But, the next time I try it, I'll check the logs and see if there's anything relevant (after all, Mint is based on Debian/Ubuntu so we should both be getting similar error/warning messages).

xfx
Posts: 24
Joined: Thu Dec 06, 2012 10:09 pm

Re: PulseAudio network sink

Fri Jan 18, 2013 2:25 pm

Well, I can now confirm that there's no way to use Pulse Audio over WiFi.

My laptop (which is the "sender"), when connected via WiFi, does all sorts of weird things and sometimes, the Pulse Audio sink in the Raspberry Pi simply disappears from the available Audio Output channels.
But, if the sink stays available and I try to play audio, every thing starts to get slow: the Raspberry Pi's Pulse Audio service consumes ~80% of CPU, my laptop starts to get unresponsive and the whole WiFi slows down up to a point where it becomes unusable.
However, if I use a wired connection everything works beautifully.

One interesting thing though: I have an AirPlay (emulator?) installed on my Media Center PC and my laptop sees it and is able to stream to it, even on WiFi... so the problem is definitely related to the "Pulse Audio over WiFi" combination.

runeks
Posts: 20
Joined: Mon Jul 23, 2012 11:34 am

Re: PulseAudio network sink

Sat Jan 19, 2013 1:54 pm

I've attempted to go the Airplay route as well. I think the pulseaudio network sink is unusable over wifi as well. The good thing is that pulseaudio also has a module for streaming to an Airplay-capable device. And there is a script called shairport that functions as an airplay server that can run on Linux. I can't get shairport and the module-raop-discover pulseaudio module to work together though. I've reported a bug here: https://github.com/albertz/shairport/issues/178

Can you try to test if it works with your setup? Just make sure pulseaudio is running on the Pi, and then, running the following command should make Airplay-compatible playback devices visible:

Code: Select all

pactl load-module module-raop-discover
you might need to install the pulseaudio-module-raop package for that module to be available.

xfx
Posts: 24
Joined: Thu Dec 06, 2012 10:09 pm

Re: PulseAudio network sink

Thu Jan 24, 2013 2:55 pm

I have that exact same setup, unfortunately, the only way I can make the shairport4 to work is if I set it with a password, otherwise, my other devices won't be able to stream to it and iTunes reports a -15000 error.
But, if I set a password, everything appears to work just fine.

Unfortunately, it appears that PulseAudio does not support password over raop connections...

Quite frustrating.

olof
Posts: 1
Joined: Sun Apr 14, 2013 3:48 pm

Re: PulseAudio network sink

Mon Apr 15, 2013 12:55 am

I very much appreciate this, works for me (using paprefs) on both devices after installing pulseaudio as described in the above posts. thanks!

jacopo
Posts: 1
Joined: Fri May 31, 2013 1:20 pm

Re: PulseAudio network sink

Fri May 31, 2013 1:28 pm

Thanks a Lot for this guide.

I have a problem though: My xubuntu machine sees the Pulseaudio sink from Pi, connects to it and streams for about 30 sec/ 1 min then the stream dies.

xubuntu:

Code: Select all

 pulseaudio[2877]: [pulseaudio] module-tunnel.c: Stream died.
If I restart pulseaudio on the Pi the same happens again.

I've tried both wifi and ethernet. It doesn't seem that the problem depends on it.

Any Help is really appreciated.

Thanks

ralle
Posts: 1
Joined: Sun Jul 07, 2013 11:41 am

Re: PulseAudio network sink

Sun Jul 07, 2013 12:15 pm

Thank you for the guide. I have set it up, but I have the same problem as jacopo. Playback stops after 1 minute or so. Does anybody else have this issue or maybe soved it?

dvdr
Posts: 25
Joined: Mon Aug 26, 2013 12:58 pm

Re: PulseAudio network sink

Mon Aug 26, 2013 4:16 pm

Just stumbled over your post - do you think, that this would be possible:
Run MPD on the RPi, and in MPD's configuration, select to use PulseAudio as the "audio device". Then configure PulseAudio in a way, that it routes the audio to Airplay-capable devices such as Airplay-capable loudspeakers. In other words: "stream" audio wirelessly from the RPi to Airplay-Loudspeakers? If this indeed would be possible, how would I install and configure this?
runeks wrote:I've attempted to go the Airplay route as well. I think the pulseaudio network sink is unusable over wifi as well. The good thing is that pulseaudio also has a module for streaming to an Airplay-capable device. And there is a script called shairport that functions as an airplay server that can run on Linux. I can't get shairport and the module-raop-discover pulseaudio module to work together though. I've reported a bug here: https://github.com/albertz/shairport/issues/178

Can you try to test if it works with your setup? Just make sure pulseaudio is running on the Pi, and then, running the following command should make Airplay-compatible playback devices visible:

Code: Select all

pactl load-module module-raop-discover
you might need to install the pulseaudio-module-raop package for that module to be available.

mphlipp
Posts: 1
Joined: Thu Jan 30, 2014 8:11 pm

Re: PulseAudio network sink

Thu Jan 30, 2014 8:16 pm

I tried this, and as soon as I installed pulseaudio there was no sound going out while playing music on the pi. Can you tell me what's going wrong?

gearhead
Posts: 71
Joined: Tue Sep 11, 2012 1:45 pm

Re: PulseAudio network sink

Fri Feb 21, 2014 3:43 pm

When I try this, I get no sound output and a ton of these errors in the dmseg:
"retire_capture_urb: 1 callbacks suppressed"

It also kills Motion. The services all show as running, I just get no video stream and no sound.

Would like to get pulseaudio sink running, but these errors stop me from getting there. Same effect on a version 1 and version 2 Model B. Same effect with nfs root filesystem or local SD filesystem. Same with USB Logitech C310 camera and a no name camera. Running latest raspbian fully updated.

Any help appreciated

Gearhead

veen
Posts: 2
Joined: Sun Feb 23, 2014 5:32 pm

Re: PulseAudio network sink

Sun Feb 23, 2014 5:36 pm

My sink was working well until broken by FW udates. I am able to get sound in newer versions, but either I get a timeout or stuttering problem. To restore a working sink:

Code: Select all

 sudo rpi-update eeb2e51c3e08cd5efa4246aa8dc54a09b25ada12 

alsvartr
Posts: 2
Joined: Thu Mar 06, 2014 9:22 pm

Re: PulseAudio network sink

Thu Mar 06, 2014 9:26 pm

veen wrote:My sink was working well until broken by FW udates. I am able to get sound in newer versions, but either I get a timeout or stuttering problem. To restore a working sink:

Code: Select all

 sudo rpi-update eeb2e51c3e08cd5efa4246aa8dc54a09b25ada12 
Thanks! Downgrading to this version really helped me to solve issues with PA.

veen
Posts: 2
Joined: Sun Feb 23, 2014 5:32 pm

Re: PulseAudio network sink

Mon Jun 02, 2014 7:06 pm

Another input: After updating my Linux box I had problems using the sink over WLAN. Something like regular skips when streaming audio.

After setting a fixed value for the BSSID field of my WLAN connection the skips were gone. Fragile stuff this :p

yu210148
Posts: 2
Joined: Mon Oct 13, 2014 4:58 pm
Location: Davis, CA, USA

Re: PulseAudio network sink

Mon Oct 13, 2014 5:10 pm

Thanks for the guide. Got this working to pump my google play music playback to the Pi. I'm curious though: runeks posted that he/she was porting the audio to the Pi from a Chromebook. runeks, if you see this how'd you do this? I can't find a way to connect my Chromebook to the pulseaudio sink on the Pi.

Return to “Graphics, sound and multimedia”