How to get PulseAudio running?

  • 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:


    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 cracks repeatedly, printing this error:

    [0x7503d0] alsa audio output error: cannot write: Broken pipe

    Can you show the errors you are getting?

  • 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/

    and uncomment the lines:

    load-module module-native-protocol-tcp auth-ip-acl=;
    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 

    ``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.

  • If you want pulseaudio to start at boot, but as a user-level service, you can make a systemd unit file. This may help, as pulseaudio does not prefer to run in systems mode.

    Here is the service I wrote in /etc/systemd/system/pulseaudio.service

    Description=PulseAudio Sound System

    Before= tells it to wait until after initializes. BusName= connects it to D-Bus is a helpful default, but I don't really know what it does.

    Apparently we can put this in `~/.config/systemd/user/pulseaudio.service` and use systemd with the `--user` flag to avoid root privileges.

  • 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/ 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.

    When playing audio over the network, PulseAudio was using about 16% CPU even with `trivial` for me.

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM