From ArchWiki
Revision as of 13:33, 2 May 2009 by Magus (Talk | contribs) (Configuration of the ALSA PulseAudio plugin: the file /etc/asound.conf isn't present by default, added a note that it likely has to be created (for the absolute newbies, like me))

Jump to: navigation, search

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end


PulseAudio is a sound server for POSIX and Win32 systems. It allows to have multiple programs playing sound at one machine and even more advanced features. PulseAudio is a drop-in replacement for the enlightened sound daemon (esd).

PulseAudio is not a drop-in replacement for aRts. If you use KDE 3, it is not currently possible to use PulseAudio.

This article focuses on the more basic PulseAudio features.


All packages are from the community repository so you need to have it enabled. Then, to install pulseaudio:

# pacman -S pulseaudio 

Optionally you can install some GTK front-ends for PulseAudio (recommended):

# pacman -S padevchooser paman paprefs pavucontrol pavumeter

For the applications that don't support PulseAudio and support ALSA it's recommended to install the PulseAudio plugin for alsalibs. This plugin is available in the alsa-plugins package.

# pacman -S alsa-plugins

Drop-in replacement for ESD (EsounD)

Current GNOME versions have support for starting ESD on session startup. Because PulseAudio can be used as drop-in replacement for ESD you can fool GNOME to load the PulseAudio daemon just like the traditional ESD daemon. To achieve this use the esdcompat script shipped with PulseAudio. Create a symlink from Template:Filename to this script:

# ln -sf /usr/bin/esdcompat /usr/bin/esd

That's it. Now GNOME should load and make use of PulseAudio automatically on each login.

Pulseaudio uses by default a different socket (Template:Filename) as the stock to prevent different users to access the same socket. If you want gnome to start esd (esdcompat actually) automatically as a user you should edit the file Template:Filename to make it use the default socket as expected by most gnome apps. Find the line Template:Codeline and edit it as follows:

load-module module-esound-protocol-unix socket=/tmp/.esd/socket 

This works only if you are the only user of the computer however, as soon as a second user starts gnome on the same computer problems are likely to appear. To have a more general solution for the problem start esdcompat on a server basis. Though I did not have to edit the above line (because my Ubuntu was working fine even without editing the above line, so tried the same with Arch and it worked) but YMMV.

Configuring your system for Pulse

System-wide daemon (optional)

By default, PulseAudio is run per-user and will be started automatically when it is needed. This is simpler, more efficient and more secure. If for some reason you need a system-wide daemon e.g. multiple users log in at the same time, do the following:

First you need to add the "pulseaudio" daemon to Template:Filename. Example:

DAEMONS=(syslog-ng ipw3945d network netfs crond fam hal avahi-daemon pulseaudio)

To use the PulseAudio Device Chooser (padevchooser), you might also need to add the 'avahi-daemon' to this list.

Then you need to add the user(s) to the pulse-access group, even for root (if you want to have sound as root).

# gpasswd -a <user> pulse-access

Permissions for per-user daemon

It's a good idea to add your user to the pulse-rt group, this can help performance but doesn't seem to be done automatically in installation.

# gpasswd -a <user> pulse-rt

Configuration of the ALSA PulseAudio plugin

It's recommended to configure ALSA for PulseAudio, since most applications use ALSA. This is done through the PulseAudio plugin for alsalibs (the ALSA PulseAudio plugin is available through the alsa-plugins package). In order for ALSA to use PulseAudio we need to edit (and most likely create) Template:Filename (recommended) or Template:Filename to have these lines:

pcm.pulse {
    type pulse
ctl.pulse {
    type pulse

Template:Codeline in Template:Codeline and Template:Codeline is just the name, you can change it but it would change the next steps.

If you want ALSA to use PulseAudio by default you should also add this to Template:Filename or Template:Filename:

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

If you selected pulse to be your default device you need to either specify the hardware device to PulseAudio in Template:Filename example:

load-module module-alsa-sink device=hw:0
load-module module-alsa-source device=hw:0

or you can use automatic detection using hal with:

load-module module-hal-detect

The above line sholud be there by default in Template:Filename, make sure it is uncommented.

If you haven't configured PulseAudio as the ALSA default, you need to change the ALSA device to "pulse" in the applications that you use to make it work.

Multiple PulseAudio ALSA devices

If you want to use multiple sound cards or multiple virtual PCMs of your sound card (for example, to separate front and rear outputs), you'll need to tell PulseAudio to use multiple ALSA sinks:

load-module module-alsa-sink device=front
load-module module-alsa-sink device=rear

If you want the client to have separate Pulse/ALSA outputs for each device, edit Template:Filename or Template:Filename:

pcm.pulsefront {
    type pulse
    device front
pcm.pulserear {
    type pulse
    device rear

And specify the appropriate ctl elements:

ctl.pulsefront {
    type pulse
    device front
ctl.pulserear {
    type pulse
    device rear

Configuration of GStreamer for PulseAudio

To make GStreamer use PulseAudio, you'll need to install the gstreamer0.10-pulse package:

# pacman -S gstreamer0.10-pulse

Then, execute Template:Codeline (part of Template:Codeline package) and select PulseAudio Sound Server in both Audio Input and Output. Alternatively, this can be done by setting the gconf variables Template:Codeline to pulsesink and Template:Codeline to pulsesrc:

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

Configuration of the Adobe Flash plugin for PulseAudio

Note: Adobe Flash starting with version 10 has native PulseAudio support, so there should be no need for libflashsupport-pulse anymore.

The default Adobe Flash plugin for Mozilla doesn't work well with the PulseAudio plugin for ALSA so you'll get no sound but there is a way to make the Flash plugin work with PulseAudio even though you might end up with a little delay. This is done through libflashsupport-pulse and there is a package for it on the AUR. Link : [1]

This lib version should correctly auto detect PulseAudio and work, if it doesn't we can force it to use PulseAudio. We can do this through the environment variable FLASH_FORCE_PULSEAUDIO and in order for all users to have this working without any trouble we can create the variable at the login of a user. We do this by editing the script Template:Filename (create it if it doesn't exist):

# export FLASH_AUDIODEBUG="1" If you want to see debug from the flash audio
# export FLASH_PULSEDEBUG="1" If you want to know the delay from the sound

If your PulseAudio daemon is running remotely Flash cannot autodetect it. Therefore, you'll need to specify the PULSE_SERVER environment variable:


replacing the IP address with that of your server, of course.

It also looks like the new beta version of flashplugin 10 can use pcm_pulse plugin without additional libraries. Get the package for it on the AUR. Link: [2]

Configuration of SDL for PulseAudio

Since SDL version 1.2.12, SDL has native pulseaudio support. Add this to your Template:Filename or similar:

export SDL_AUDIODRIVER="pulse"

to use it. Other environment variables to configure: set PASERVER to the host of the PulseAudio server and set PADEVICE to the device used on the server. (the "pulse" driver has no support, yet, for reading your pulseaudio configuration, it seems.).

Or, if this driver does not work for you or if you are using an older version of SDL,

export SDL_AUDIODRIVER="esd"

might do the trick.

Note: You may need to use the ABS to compile SDL with pulseaudio support. Until the quality of the driver is fixed upstream, please use the patch located here: SDL PulseAudio Patch. It should fix most if not all the sound issues you may be having.

Configuration of OpenAL for PulseAudio

Games that uses OpenAL can use PulseAudio directly writing this line in Template:Filename:

(define devices '(esd))

or alternatively

(define devices '(alsa))
(define alsa-device "pulse")

Configuration of libao for PulseAudio

# pacman -Sy libao-pulse

Edit Template:Filename, add:


Using OSS apps with PulseAudio wrapper

If you have a program that uses OSS you can make it work with PulseAudio by starting it with padsp:

$ padsp OSSprogram

A few examples:

$ padsp aumix
$ padsp sox foo.wav -t ossdsp /dev/dsp

If you prefer you can rename the program OSSprogram-real and replace it with a script like this:

if test -x /usr/bin/padsp ; then
    exec /usr/bin/padsp /usr/bin/OSSprogram-real "$@"
    exec /usr/bin/OSSprogram "$@"

PulseAudio over network

One of PulseAudio's magnificent features is the possibility to stream audio from clients over TCP to the server running the PulseAudio daemon, allowing sound to be streamed through your LAN. To accomplish this, one needs to enable module-native-protocol-tcp, and copy the pulse-cookie to the clients. To enable the TCP module, add (or uncomment, if already there) this to Template:Filename:

load-module  module-native-protocol-tcp

To allow remote connections to the TCP module, you also have to remember to unblock the service in Template:Filename with for example the following line:

pulseaudio-native: ALL

If you're running a system-wide PulseAudio instance, which makes sense for networked audio, the cookie is located in Template:Filename. This cookie needs to be sent to the client and placed somewhere the pulse-access group can read (and with permissions so only they can read it).

# scp /var/run/pulse/.pulse-cookie client:/etc/pulse-cookie
# chown pulse:pulse-access /etc/pulse-cookie
# chmod 640 /etc/pulse-cookie

The pulse client needs to know where to look for the cookie. Template:Filename:

### Cookie file
cookie-file = /etc/pulse-cookie

Then the client needs to be configured to connect to the specified server. Template:Filename:

## The default server to connect to
default-server =

That's it!

Pulseaudio through JACK

The JACK-Audio-Connection-Kit is popular for audio work, and is widely supported by Linux audio applications. It fills a similar niche as Pulseaudio, but with more of an emphasis on professional audio work. In particular, audio applications such as Ardour and Audacity (recently) work well with Jack. Pulseaudio provides module-jack-source and module-jack-sink which allow Pulseaudio to be run as a sound server above the JACK daemon. This allows the usage of per-volume adjustments and the like for the apps which need it, play-back apps for movies and audio, while allowing low-latency and inter-app connectivity for sound-processing apps which connect to JACK.

To use pulseaudio with JACK, JACK must be started up before pulseaudio, using whichever method you prefer. Pulseaudio then needs to be started loading the 2 relevant modules. Edit your Template:Filename (as root, of course), and change the following region:

### Load audio drivers statically (it's probably better to not load
### these drivers manually, but instead use module-hal-detect --
### see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink

### Automatically load driver modules depending on the hardware available
.ifexists module-hal-detect.so
load-module module-hal-detect
### Alternatively use the static hardware detection module (for systems that
### lack HAL support)
load-module module-detect

to the following:

### Load audio drivers statically (it's probably better to not load
### these drivers manually, but instead use module-hal-detect --
### see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink
load-module module-jack-source
load-module module-jack-sink

### Automatically load driver modules depending on the hardware available
#.ifexists module-hal-detect.so
#load-module module-hal-detect
### Alternatively use the static hardware detection module (for systems that
### lack HAL support)
#load-module module-detect

Basically, this prevents module-hal-detect from loading. module-hal-detect will always try to grab your sound-card (JACK has already done that, so this will cause an error). Also, the jack source and sink must be explicitly loaded.

Pulseaudio from within a chroot (ex. 32-bit chroot in 64-bit install)

Since a chroot sets up an alternative root for the running/jailing of applications, pulseaudio must be installed within the chroot itself (Template:Codeline within the chroot environment).

Pulseaudio, if not set up to connect to any specific server (this can be done in Template:Filename, through the PULSE_SERVER environment variable, or through publishing to the local X11 properties using module-x11-publish), will attempt to connect to the local pulse server, failing which it will spawn a new pulse server. Each pulse server has a unique ID based on the machine-id value in Template:Filename. To allow for chrooted apps to access the pulse server, the following directories must be mounted within the chroot:-


Template:Filename should also be mounted for efficiency and good performance. Note that mounting /home would normally also allow sharing of the Template:Filename folder.

For specific direction on accomplishing the appropriate mounts, please refer to the wiki on installing a bundled 32-bit system, especially the additional section specific to Pulseaudio.


authkey.c: Failed to open cookie file '/home/<user>/.esd_auth': Permission denied

If this error message appears in Template:Filename, then add:

if [ -e /var/run/pulse/.esd_auth ]; then
  chown pulse:pulse-access /var/run/pulse/.esd_auth
  chmod 640 /var/run/pulse/.esd_auth

before Template:Codeline in Template:Filename.


If PulseAudio fails to start and the messages

 x11wrap.c: XOpenDisplay() failed
 module.c: Failed to load  module "module-x11-publish" (argument: ""): initialization failed.
 main.c: Module load failed.
 main.c: failed to initialize daemon.

appear in your logs, you need to disable module-x11-publish in Template:Filename:

 #load-module module-x11-publish

"daemon startup failed"

If PulseAudio fails to start as a daemon and the message

 E: main.c: daemon startup failed.

appear, you may need to disable the line in Template:Filename that reads


Simply add a "#" as a comment in front of that line.

Glitches and high CPU usage since 0.9.14

The PulseAudio sound server has been rewritten to use timer-based audio scheduling instead of the traditional interrupt-driven approach. Timer-based scheduling may expose issues in some Alsa drivers. To turn timer-based scheduling off, replace the line:

load-module module-hal-detect 

in Template:Filename by:

load-module module-hal-detect tsched=0


According to the PulseAudio.org Wiki, Audacity doesn't currently support PulseAudio. Therefore they suggest killing pulseaudio before using it. look here

PulseAudio Device Chooser (padevchooser)

If you can't launch the PulseAudio Device Chooser, first (re)start the Avahi daemon as follows:

$ sudo /etc/rc.d/avahi-daemon restart


If you are having audio problems with the audio playback of DVDs in VLC, uninstall VLC and install the vlc-nightly package from the AUR, and set the audio output method to Template:Codeline.


There is a pulseaudio enabled version of mpd in the AUR. You will need to add the mpd user to the "pulse-access" group in order for mpd to connect to the daemon.


If you receive an error message about HAL, module-hal, or something along those lines, you will need to remove module-hal-detect from your Template:Filename and explicitely specify the ALSA devices yourself, for example:

load-module module-alsa-sink device=hw:0
load-module module-alsa-source device=hw:0

No sound after install

If you experience no audio output via any means while using ALSA as your default device, you may have to unmute your sound card. To do this, you will want to launch alsamixer and make sure each column has a green 00 under it (this can be toggled by pressing 'm')

$ alsamixer -c 0

Sometimes the snd_pcsp driver conflicts with the snd_hda_intel driver (for those of you using Intel cards) and no sound output is experienced. To fix this, you can blacklist the snd_pcsp driver in the MODULES array of Template:Filename (by appending Template:Codeline).

I have a surround sound card, but PulseAudio uses just the front speakers!

Many people have a surround card, but have speakers for just two channels, so PulseAudio can't really default to a surround setup. To enable all the channels, edit Template:Filename: uncomment the default-sample-channels line (i.e. remove the semicolon from the beginning of the line) and set the value to 6 if you have a 5.1 setup, or 8 if you have 7.1 setup etc. After doing the edit, restart pulseaudio daemon.

# Default
default-sample-channels = 2
# For 5.1
default-sample-channels = 6
# For 7.1
default-sample-channels = 8

See also

External Links