PulseAudio

PulseAudio is a sound server commonly used by desktop environments like GNOME or KDE. It serves as a proxy to sound applications using existing kernel sound components like ALSA or OSS. Since ALSA is included in Arch Linux by default, the most common deployment scenarios include PulseAudio with ALSA.

Installation

Note: Some confusion can be made between ALSA and PulseAudio. ALSA both includes a Linux kernel component with sound card drivers, and a userspace component, libalsa. PulseAudio only builds on the kernel component, but offers compability with libalsa through pulseaudio-alsa.

Configuration

Configuration files

Tango-two-arrows.png

Tango-two-arrows.png

This article or section is a candidate for merging with PulseAudio/Configuration.

Notes: Configuration should stay in the main article, so the linked page should be merged here. Split #Troubleshooting instead if this page is found too long. (Discuss)

By default, PulseAudio is configured to automatically detect all sound cards and manage them. It takes control of all detected ALSA devices and redirect all audio streams to itself, making the PulseAudio daemon the central configuration point. The daemon should work mostly out of the box, only requiring a few minor tweaks.

PulseAudio will first look for configuration files in home directory ~/.config/pulse, then in system wide /etc/pulse.

PulseAudio runs as a server daemon that can run either system-wide or on per-user basis using a client/server architecture. The daemon by itself does nothing without its modules except to provide an API and host dynamically loaded modules. The audio routing and processing tasks are all handled by various modules. You find a detailed list of all available modules at Pulseaudio Loadable Modules. To enable them you can just add a line load-module <module-name-from-list> to ~/.config/pulse/default.pa.

Tip:
  • It is strongly suggested not to edit system wide configuration files, but rather edit user ones. Create the ~/.config/pulse directory, then copy the system configuration files in it and edit according to your need.
  • Make sure you keep user configuration in sync with changes to the packaged files in /etc/pulse/. Otherwise, PulseAudio may refuse to start due to configuration errors.
  • There is no need to add user to audio group, as it uses udev and logind to dynamically give access to the currently "active" user

daemon.conf

It defines base settings like the default sample rates used by modules, resampling methods, realtime scheduling and various other settings related to the server process. These can not be changed at runtime without restarting the PulseAudio daemon. Most defaults make sense here.

Notable configuration options
Option Description
system-instance If set to yes, the daemon will run as a system-wide instance. Highly discouraged as it can introduce security issues. Can be used when multiple users will use sound at the same time, either remotely or locally using Xorg_multiseat. Defaults to no.
resample-method When PulseAudio needs to pass audio from one module to another using incompatible sample-rate (for example, playback at 96kHz to a card that only supports a maximum of 48kHz), specifies which resampler to use. You can use the command $ pulseaudio --dump-resample-methods to list all available resamplers and choose the best tradeoff between CPU usage and audio quality for your taste.
Tip: One of the major complaint about PulseAudio is its high CPU usage in some use cases. A lot of these cases happens when pulse needs to resample multiple streams (individually). If you intend to mix multiple sample rates often, consider creating an additional sink at the correct sample rate which you can then feed back to your main sink, resampling only once.
flat-volumes If yes (default), all input sources have their volume relative to the maximum volume of the entire sound card. This allows each application to individually adjust their volume so for example, raising your VoIP call volume will raise the hardware volume and adjust your music player volume so it stays where it was, avoiding confusion by having to lower manually the music player then raise the global volume.
Warning: Sometimes this can be more confusing than what it solves and some applications unaware of this feature can set their volume at 100% at startup, potentially blowing your speakers or your ears. If unsure, prefer to set this to no so pulse will use the classic ALSA behavior instead.
default-fragments Audio samples are splitted into multiple fragments of default-fragment-size-msec each. The larger the buffer is, the less likely audio will skip when the system is overloaded, but will also increase the overall latency. Increase this value if you have issues.

default.pa

This file is a startup script and is used to configure modules. It is actually parsed and read after the daemon has finished initializing and additionnal commands can be sent at runtime using $ pactl or $ pacmd. The startup script can also be provided on the command line by starting PulseAudio in a terminal using $ pulseaudio -nC. This will make the daemon load the CLI module and will accept the configuration directly from the command line, and output resulting information or error messages on the same terminal. This can be useful when debugging the daemon or just to test various modules before setting them permanently on disk. The manual page is quite self explaining, please consult man pulse-cli-syntax for the details of the syntax.

Tip:
  • Run $ pacmd list-sinks|egrep -i 'index:|name:' to list available sinks. The present default sink is marked with an asterix.
  • Edit ~/.config/pulse/default.pa to insert/alter the set-default-sink command using the sink's name as the numbering cannot be guaranteed repeatable.

client.conf

This is the configuration file read by every PulseAudio client applications. It is used to configure runtime options for individual clients. It can be used to set the configure the default sink and source statically as well as allowing (or disallowing) clients to automatically start the server if not currently running.

Configuration command

The main command to configure a server during runtime is $ pacmd. Run $ pacmd --help for a list options, or just run $ pacmnd to enter the shell interactive mode and Ctrl+d to exit. All modifications will immediately be applied.

Once your new settings have been tested and meet your needs, edit the default.pa accordingly to make the change persistent. See PulseAudio/Examples for some basic settings.

Tip: leave the load-module module-default-device-restore line in the default.pa file untouched. It will allow you to restart the server in its default state, thus dismissing any wrong setting.

It is important to understand that the "sources" and "sinks" accessible and selectable through PulseAudio depend upon the current hardware "Profile" selected. These "Profiles" are those ALSA "pcms" listed by the command aplay -L, and more specifically by the command pacmd list-cards, which will include a line "index:", a list beginning "profiles:", and a line "active profile: <...>" in the output, among other things.

The "active profile" can be set with the command pacmd set-card-profile INDEX PROFILE, with no comma separating INDEX and PROFILE, where INDEX is just the number on the line "index:" and a PROFILE name is everything shown from the beginning of any line under "profile:" to just before the colon and first space, as shown by the command pacmd list-cards. For instance, pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo.

It may be easier to select a "Profile" with a graphical tool like pavucontrol, under the "Configuration" tab, or KDE System Settings, "Multimedia/Audio and Video Settings", under the "Audio Hardware Setup" tab. Each audio "Card", which are those devices listed by the command aplay -l, or again by the command pacmd list-cards, will have its own selectable "Profile". When a "Profile" has been selected, the then available "sources" and "sinks" can be seen by using the commands pacmd list-sources and pacmd list-sinks. Note that the "index" of the available sources and sinks will change each time a card profile is changed.

The selected "Profile" can be an issue for some applications, especially the Adobe Flash players, typically /usr/lib/mozilla/plugins/libflashplayer.so and /usr/lib/PepperFlash/libpepflashplayer.so. Often, these Flash players will only work when one of the Stereo profiles is selected, and otherwise, will play video with no sound, or will simply "crash". When all else fails, you might try selecting a different profile.

Of course, when configuring some variation of Surround Sound in PulseAudio, the appropriate Surround profile will have to be selected, before Surround Sound will work, or in order to do things like remap the speaker channels.

Running

Note: Most X11 environments start PulseAudio automatically with the X11 session.

In the unlikely event that PulseAudio is not automatically started upon entering X, it can can be started with:

$ pulseaudio --start

PulseAudio can be stopped with:

$ pulseaudio --kill
Note: As of version 6.0, PulseAudio no longer automatically starts this way.

If the line autospawn=no exists in either /etc/pulse/client.conf or ~/.pulse/client.conf, you may need to change it to autospawn=yes and restart.

Autostarting in unsupported desktop environments

Note: As mentioned previously, PulseAudio is very likely launched automatically via the files in /etc/xdg/autostart/ if your DM/DE supports it.
Note: As of PulseAudio version 5, /etc/X11/xinit/xinitrc.d/pulseaudio is no longer included in the official repository package. This causes some DMs, such as LightDM to no longer load PulseAudio automatically. The instructions below detail alternate ways of doing so.

Check to see if PulseAudio is running:

$ pgrep -af pulseaudio
369 /usr/bin/pulseaudio

If PulseAudio is not running and users are using X, the following will start PulseAudio with the needed the X11 plugins manually:

$ start-pulseaudio-x11

If you are running a DM or DE that doesn't support autostarting from /etc/xdg/autostart/, then you can launch PulseAudio on login through ~/.xprofile (Some older DMs may require this to be placed in ~/.xinitrc instead):

~/.xprofile
/usr/bin/start-pulseaudio-x11 &

Back-end configuration

ALSA

Install pulseaudio-alsa from the official repositories. This package contains the necessary /etc/asound.conf for configuring ALSA to use PulseAudio.

Also install lib32-libpulse and lib32-alsa-plugins if you run a x86_64 system and want to have sound for 32-bit multilib programs like Wine, Skype and Steam.

To prevent applications from using ALSA's OSS emulation and bypassing PulseAudio (thereby preventing other applications from playing sound), make sure the module snd_pcm_oss is not being loaded at boot. If it is currently loaded (lsmod | grep oss), disable it by executing:

# rmmod snd_pcm_oss

ALSA/dmix without grabbing hardware device

Note: This section describes alternative configuration, which is generally not recommended.

You may want to use ALSA directly in most of your applications and to be able to use other applications, which constantly require PulseAudio at the same time. The following steps allow you to make PulseAudio use dmix instead of grabbing ALSA hardware device.

  • Remove package pulseaudio-alsa, which provides compatibility layer between ALSA applications and PulseAudio. After this your ALSA apps will use ALSA directly without being hooked by Pulse.
  • Edit /etc/pulse/default.pa.
Find and uncomment lines which load back-end drivers. Add device parameters as follows. Then find and comment lines which load autodetect modules.
load-module module-alsa-sink device=dmix
load-module module-alsa-source device=dsnoop
# load-module module-udev-detect
# load-module module-detect
  • Optional: If you use kdemultimedia-kmix you may want to control ALSA volume instead of PulseAudio volume:
$ echo export KMIX_PULSEAUDIO_DISABLE=1 > ~/.kde4/env/kmix_disable_pulse.sh
$ chmod +x ~/.kde4/env/kmix_disable_pulse.sh
  • Now, reboot your computer and try running ALSA and PulseAudio applications at the same time. They both should produce sound simultaneously.
Use pavucontrol to control PulseAudio volume if needed.

Bluetooth Audio

Install pavucontrol to select the Output Device as well as direct the Playback app to the correct bluetooth audio device.

OSS

There are multiple ways of making OSS-only programs output to PulseAudio:

ossp

Install ossp package and start osspd.service.

padsp wrapper

Programs using OSS can work with PulseAudio by starting it with padsp (included with PulseAudio):

$ padsp OSSprogram

A few examples:

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

You can also add a custom wrapper script like this:

/usr/local/bin/OSSProgram
#!/bin/sh
exec padsp /usr/bin/OSSprogram "$@"

Make sure /usr/local/bin comes before /usr/bin in your PATH.

GStreamer

Install gst-plugins-good, or gstreamer0.10-good-plugins if your intended program has a legacy GStreamer implementation.

OpenAL

OpenAL Soft should use PulseAudio by default, but can be explicitly configured to do so:
/etc/openal/alsoft.conf
drivers=pulse,alsa

libao

Edit the libao configuration file:

/etc/libao.conf
default_driver=pulse

Be sure to remove the dev=default option of the alsa driver or adjust it to specify a specific Pulse sink name or number.

Note: You could possibly also keep the libao standard of outputting to the alsa driver and its default device if you install pulseaudio-alsa since the ALSA default device then is PulseAudio.

Equalizer

PulseAudio has an integrated 10-band equalizer system. In order to use the equalizer do the following:

Load equalizer sink and dbus-protocol module

$ pactl load-module module-equalizer-sink
$ pactl load-module module-dbus-protocol

Install and run the GUI front-end

Install python-pyqt4 and execute:

$ qpaeq
Note: If qpaeq has no effect, install pavucontrol and change "ALSA Playback on" to "FFT based equalizer on ..." while the media player is running.

Load equalizer and dbus module on every boot

Edit the /etc/pulse/default.pa or ~/.config/pulse/default.pa file with your favorite editor and append the following lines:

### Load the integrated PulseAudio equalizer and D-Bus module
load-module module-equalizer-sink
load-module module-dbus-protocol

Applications

QEMU

Tango-two-arrows.png

Tango-two-arrows.png

This article or section is a candidate for merging with QEMU.

Notes: QEMU is the most complex of the "applications" described in this section, merging to the main article would provide better context. (Discuss)

The audio driver used by QEMU is set with the QEMU_AUDIO_DRV environment variable:

$ export QEMU_AUDIO_DRV=pa

Run the following command to get QEMU's configuration options related to PulseAudio:

$ qemu-system-x86_64 -audio-help | awk '/Name: pa/' RS=

The listed options can be exported as environment variables, for example:

$ export QEMU_PA_SINK=alsa_output.pci-0000_04_01.0.analog-stereo.monitor
$ export QEMU_PA_SOURCE=input

Tango-mail-mark-junk.png

Tango-mail-mark-junk.png

This article or section needs language, wiki syntax or style improvements.

Reason: The following is not specific to PulseAudio. (Discuss)

To get list of the supported emulation audio drivers

$ qemu-system-x86_64 -soundhw help

To use e.g. ac97 driver for the guest use the -soundhw ac97 commnad with QEMU.

Note: Video graphic card emulated drivers for the guest machine may also cause a problem with the sound quality. Test one by one to make it work. You can list possible options with qemu-system-x86_64 -h | grep vga.

AlsaMixer.app

Make alsamixer.app dockapp for the windowmaker use pulseaudio, e.g.

$ AlsaMixer.app --device pulse

Here is a two examples where the first one is for ALSA and the other one is for pulseaudio. You can run multiple instances of it. Use the -w option to choose which of the control buttons to bind to the mouse wheel.

# AlsaMixer.app -3 Mic -1 Master -2 PCM --card 0 -w 1
# AlsaMixer.app --device pulse -1 Capture -2 Master -w 2
Note: It can use only those output sinks that set as default.

XMMS2

Make it switch to pulseaudio output

$ nyxmms2 server config output.plugin pulse

and to alsa

$ nyxmms2 server config output.plugin alsa

To make xmms2 use a different output sink, e.g.

 $ nyxmms2 server config pulse.sink alsa_output.pci-0000_04_01.0.analog-stereo.monitor

See also the official guide [1].

KDE Plasma Workspaces and Qt4

PulseAudio will automatically be used by KDE/Qt4 applications. It is supported by default in the KDE sound mixer. For more information see the KDE page in the PulseAudio wiki. One useful tidbit from that page is to add load-module module-device-manager to /etc/pulse/default.pa.

If the phonon-gstreamer backend is used for Phonon, GStreamer should also be configured as described in #GStreamer.

Audacious

Audacious natively supports PulseAudio. In order to use it, set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.

Java/OpenJDK 6

Create a wrapper for the Java executable using padsp as seen on the Java sound with PulseAudio page.

Music Player Daemon (MPD)

configure MPD to use PulseAudio. See also MPD/Tips and Tricks#MPD and PulseAudio.

MPlayer

MPlayer natively supports PulseAudio output with the -ao pulse option. It can also be configured to default to PulseAudio output, in ~/.mplayer/config for per-user, or /etc/mplayer/mplayer.conf for system-wide:

/etc/mplayer/mplayer.conf
ao=pulse

guvcview

guvcview when using the PulseAudio input from a Webcam may have the audio input suspended resulting in no audio being recorded. You can check this by executing:

$ pactl list sources

If the audio source is "suspended" then modifying the following line in /etc/pulse/default.pa and changing:

load-module module-suspend-on-idle

to

#load-module module-suspend-on-idle

And then either restarting PulseAudio or your computer will only idle the input source instead of suspending it. guvcview will then correctly record audio from the device.

Troubleshooting

See PulseAudio/Troubleshooting.

See also