Recent changes Random page
GAMING
Technology
 
Gaming
Entertainment
Science Fiction
Biggest wikis
Hobbies
Music
See more...

PulseAudio

From Music Player Daemon Community Wiki

Jump to: navigation, search

Contents

[edit] Description

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.

[edit] Setting up PulseAudio

[edit] 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.

[edit] 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 default.pa 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=0.0.0.0
load-module module-waveout

The first line will load the TCP protocol module with a single argument: listen=0.0.0.0. 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+alt+del to bring it up). You can also start PulseAudio by running pulseaudio.exe --high-priority to set the default priority to "High".

[edit] Setting up MPD

[edit] Version 0.11.5 and earlier

MPD version 0.11.5 and earlier use libao exclusively for audio output. To use PulseAudio with this you will need to download and install the libao-pulse plugin. Once this is done you must tell MPD to use this by setting ao_driver to "pulse". You may also wish to specify a server to use, which can be done by setting ao_driver_options to "server=<server to use>". The server to use is in the PulseAudio server string format. An example config:

ao_driver         "pulse"
ao_driver_options "server=localhost"

Note that 0.11.5 can only support one audio output, so you will need to restart MPD if you wish to switch between PulseAudio and another output.

[edit] Version 0.12.0 and later

As of MPD 0.12.0 there is a new audio output system which supports outputting directly to supported audio devices. PulseAudio support is included. 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
}

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.

[edit] 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=127.0.0.1:16001"
name "esd"
}

Another solution found at Ubuntuforums.org 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"
}

[edit] 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, does 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...

[edit] An alternate solution for fixing access rights

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

  $ sudo aptitude install paprefs
  $ paprefs

Select the following settings:

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

Set mpd.conf as follows and restart mpd

audio_output {
	type    "pulse"
	name    "My MPD PulseAudio Output"
}
Rate this article:
Share this article: