Music Player Daemon Wiki


From the PulseAudio website:

PulseAudio, previously known as Polypaudio, is a sound server for POSIX and Win32 systems. A sound server is basically a proxy for your sound applications. It allows you to do advanced operations on your sound data as it passes between your application and your hardware. Things like transferring the audio to a different machine, changing the sample format or channel count and mixing several sounds into one are easily achieved using a sound server.

Setting up PulseAudio[]

On Linux[]

If you happen use one of the distributions with PulseAudio packages you should first try installing it from that. Other users will have to download and compile it themselves.

Once installed, you should take a glance at the PulseAudio first steps page for the basics of running and configuring PulseAudio.

On Windows[]

Start by downloading and unzipping the Windows PulseAudio binaries from Cendio.

Because MPD doesn't currently run on Windows you'll have to configure PulseAudio to allow remote TCP connections. Create a new file named in the unzipped pulseaudio-x.x.x directory. Open it with your favourite text editor and add the following text:

load-module module-native-protocol-tcp listen=
load-module module-waveout

The first line will load the TCP protocol module with a single argument: listen= This argument will cause the TCP protocol module to accept connections from anywhere, instead of just from the computer PulseAudio is running on. The second line will load the module needed to play sound on Windows.

You can now simply double click on pulseaudio.exe to run it.

To prevent random people from playing audio on your computer, PulseAudio requires authentication before accepting connections. To authenticate MPD you need to copy C:\Documents and Settings\<Your Windows Username>\.pulse-cookie (generated the first time you run pulseaudio.exe) to the home directory of the user MPD is running as. Alternatively, you may add auth-anonymous=1 to the end of the load-module module-native-protocol-tcp line to disable authentication.

If you experience skipping while under load you may want to try increasing the priority of the pulseaudio.exe process. This can be done manually by right clicking on it and choosing a new priority in the Windows Process Explorer (on Windows XP, press ctrl+shift+esc (or ctrl+alt+del) to bring it up). You can also start PulseAudio by running pulseaudio.exe --high-priority to set the default priority to "High".

Setting up MPD[]

You can check that your copy of MPD includes PulseAudio support by running mpd --version and making sure "pulse" is in the list of supported outputs.

If your copy of MPD supports PulseAudio, you just need to add a new audio_output section with the type set to "pulse". You can also specify a server and sink parameter. An example audio_output section:

audio_output {
        type    "pulse"
        name    "My MPD PulseAudio Output"
        #server  "localhost"   # optional
        #sink    "alsa_output" # optional

For controlling the master mixer volume with mpd, you can use the following configuration (tested with Ubuntu 10.04):

audio_output {
	type           "alsa"
	name           "MPD"
	device         "pulse"
	mixer_control  "Master"

## This settings have to be commented out:
#mixer_type			"hardware"
#mixer_type			"software"
#mixer_type			"disabled"

Note that this can be specified in addition to your usual outputs. This will allow you to enable and disable the PulseAudio output (and any other audio outputs) at will. You should run mpd as the logged-in user on desktop systems. Alternately, you can run in System Mode and give the mpd user membership in the pulse-access group. Good howto for system mode with networking here. (N.B. you really shouldn't do this on a desktop system: see WhatIsWrongWithSystemMode.)

For Distros where PulseAudio output is broken[]

As PulseAudio is a ESD replacement, the ESD plugin can work in cases where PulseAudio support is missing or broken. First remove the MPD PulseAudio setting. Configure MPD to use esd as shown, this assumes that MPD and PulseAudio are running on the same system.

audio_output {
type "ao"
driver "esd"
options "host="
name "esd"

Another solution found at is to replace the "ao" with "pulse", which works in some cases where ao fails.

audio_output {
type "pulse"
driver "esd"
options "host=localhost"
name "esd"

For Distros where PulseAudio access rights are broken[]

If you still can't get connectivity, your mpd will possibly log to a location specified in mpd.conf, e.g. /var/mpd/errors.log, the following lines:

Feb 15 21:41 : problems opening audio device while playing "Electric Universe/Divine Design/02 - High Fly.mp3"
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified

E: client-conf-x11.c: XOpenDisplay() failed
W: main.c: WARNING: called SUID root, but not in group 'pulse-rt'.
Feb 15 21:45 : Cannot connect to server in PulseAudio output "pulseaudio" (attempt 1): Connection refused

In this case, your problems are twofold:

  1. You are running mpd as user mpd which has no rights to access pulseaudio as you, the interactive user, have.
  2. You are enjoying PulseAudios X11-bell plugin which requires access to your X11 session, a right mpd was not granted before.

Solutions: To remedy cause 1, add user mpd to the pulseaudio groups so that mpd can even start pulseaudio on demand:

  $ sudo usermod -a -G pulse-access mpd
  $ sudo usermod -a -G pulse mpd
  $ sudo usermod -a -G pulse-rt mpd

To further fix cause 2, open your X11 session to mpd either by

xhost +local:mpd

or get rid of the X11-bell-plugin.

Also, if you don't have sound access from e.g. gdmflexiserver spawned sessions, it may be necessary to do either xhost +local or remove the X11-bell plugin...

An alternate solution for fixing access rights[]

This is required in Ubuntu Jaunty.

Another solution, found on [Ubuntu Forums] is to adjust the network access permissions using the paprefs tool. On Ubuntu:

  $ sudo aptitude install paprefs
  $ paprefs

Note: For Ubuntu 10.4 (Lucid), paprefs must not be called directly but via System / Preferences / PulseAudio Preferences.

Select the following settings:

  • Enable network access to local sound devices
  • Don't require authentication

(Note: in a headless system where mpd and pulseaudio are not run under your account, you can't use your paprefs GUI to configure options for that account. Use the command line to make a system-wide change:

On all systems that need to communicate, edit /etc/pulse/ and uncomment:
load-module module-native-protocol-tcp
Then on all systems for the account that will run mpd/pulseaudio, make sure ~/.pulse-cookie is the same.)

Set mpd.conf as follows and restart mpd

audio_output {
	type    "pulse"
	name    "My MPD PulseAudio Output"

Note: if you're running a headless configuration where you're running mpd as user "mpd" (and therefore pulseaudio as user "mpd") pulseaudio usually won't quit and restart if you do a "sudo service mpd restart".

So when you've made changes to the pulseaudio configuration (either with the GUI paprefs or with the edit above) you'll want to either "sudo service mpd stop" and then wait for the pulseaudio task to timeout on its own (use "ps axfu | grep pulse" to check) or just sudo kill it once you've stopped mpd.

Then do a "service mpd start" (after which launching a client like ncmpcpp will cause mpd to relaunch pulseaudio.)

To restrict access, you may want to configure your firewall on tcp-port 4713 (I just found this through trial&error&digging, so take it with a rock of salt ;-))

Adding the right for TCP wrapper on Ubuntu 8.04(hardy)
After adjusting the network access permissions, in syslog I found a messeage like this.

pulseaudio[6389]: socket-server.c: TCP connection refused by tcpwrap

In my case, My config file /etc/hosts.deny is "ALL: ALL".

Edit hosts.allow file.

$ sudo gedit /etc/hosts.allow

In gedit add this line to make pulseaudio accept mpd in tcp port.

pulseaudio-native: LOCAL

Reboot inetd by this command

sudo killall -HUP inetd

see here. reference: FAQ-PulseAudio

Mixer settings[]

Versions of MPD older than 0.15~alpha1 don't support pulseaudio mixers, so by default, MPD probably won't have mixer settings which work with pulseaudio. Edit your mpd.conf and uncomment the following:

mixer_type "software"

Running MPD as user[]

As PulseAudio usually runs on a per-user session it makes sense, especially if MPD is used by a single user, to run MPD as a single user. Instructions are here: [1]