Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I would like to use my Raspberry Pi as an PulseAudio sink that can play audio via the network.

For starters I want to get Pulseaudio running locally and have run into various errors. I am using the recommended Debian image.

What is the best procedure for getting PulseAudio up and running?


This is what I have tried so far:

Procedure

My procedure so far looked something like the following:

Install Pulseaudio, and VLC:

sudo apt-get install pulseaudio

Configure GStreamer to use the pulseaudio sink:

gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosink pulsesink

Load the kernel module for the audio device

sudo modprobe snd_bcm2835

Run VLC with an mp3

vlc 

Problems

VLC cracks repeatedly, printing this error:

[0x7503d0] alsa audio output error: cannot write: Broken pipe
share|improve this question
    
Can you show the errors you are getting? –  darryn.ten Jun 26 '12 at 8:36

2 Answers 2

I have got it working on my Raspberry Pi using the ALSA sink, with procedure as follows:

To install the necessary files:

sudo apt-get install pulseaudio pulseaudio-module-zeroconf alsa-utils avahi-daemon

To enable ALSA:

sudo modprobe snd-bcm2835                      # load module for single boot
echo "snd-bcm2835" | sudo tee -a /etc/modules  # load module for persistance

To set up networking:

sudo nano /etc/pulse/default.pa

and uncomment the lines:

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

To start the pulseaudio server, use:

pulseaudio -D

You should be able to test that it works by playing a wav file with paplay (sudo apt-get install pulseaudio-utils), and also over the network by selecting the sink in your system's sound control panel.

You might be also be able to set up in system-wide mode with:

sudo pulseaudio --system 
share|improve this answer
    
pulseaudio-module-zeroconf is missing in the apt-get install part. Should mention maybe also the pulseaudio --log-level=debug to troubleshoot any problems. On the sound source (not the raspberry pi), you should launch paprefs to easily overview your pulseaudio conf (if you have X11). And don't forget to restart pulseaudio when in doubt. –  vaab Oct 2 '12 at 18:15

I had a hard time getting pulseaudio running on Wheezy raspbian (2012-10-28) using the analog output. The following is what I did just to get it working in per-session mode (not system mode). System mode may work as well, I haven't attempted it. Setting up server will require some more work. I found this information in various places, hopefully gathering it here will help someone.

Install pulseaudio and make sure user (e.g. eric) is part of the audio group:

sudo apt-get install pulseaudio pulseaudio-utils
sudo adduser eric audio

Change /etc/asound.conf look like the following. This sets up pulseaudio to be used as an alsa device by default so applications use it without any additional configuration. The first two declarations (including the commented one) was in the original file.

pcm.mmap0 {
    type mmap_emul;
    slave {
      pcm "hw:0,0";
    }
}

#pcm.!default {
#  type plug;
#  slave {
#    pcm mmap0;
#  }
#}

pcm.pulse { type pulse }
ctl.pulse { type pulse }
pcm.!default { type pulse }
ctl.!default { type pulse }

Add the following lines to /etc/pulse/daemon.conf:

default-sample-rate = 48000
resample-method = trivial

trivial is the lowest quality method, but uses about 6% cpu. src-sinc-fastest also worked for me, but use about 25% CPU. Others may work as well. This later bit I don't quite understand the need for, but it seemed to be the magic ingredient. You can read more about it here.

Finally, to silence the audio pops between song plays, comment out this line in /etc/pulse/default.pa as follows:

#load-module module-suspend-on-idle

There is still some dropouts when two sources play at once, if I discover a remedy for that I'll add to this answer.

share|improve this answer
    
When playing audio over the network, PulseAudio was using about 16% CPU even with trivial for me. –  Nathan Osman Jul 26 '13 at 7:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.