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.
Contents
1 Installation
- Required package: pulseaudio
- Optional GTK GUIs: paprefs and pavucontrol
- Optional console (CLI) mixer: ponymix
- Optional web volume control: PaWebControl
- Optional system tray icon: pasystray
- Optional KDE plasma applet: kdemultimedia-kmix (If KMixfail to connect to PulseAudio at boot you may need to edit /etc/pulse/client.conf to include autospawn = yes instead of autospawn = no.)
2 Configuration
You'll see Pulseaudio supports many modules to extend its functionality. 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 /etc/pulse/default.pa.
3 Running
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
3.1 Autostarting in unsupported desktop environments
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 not running GNOME, KDE, or Xfce, and your ~/.xinitrc does not source the scripts in /etc/X11/xinit/xinitrc.d (such as is done in the example file /etc/skel/.xinitrc), then you can launch PulseAudio on boot with:
~/.xinitrc
/usr/bin/start-pulseaudio-x11
4 Back-end configuration
4.1 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
4.1.1 ALSA/dmix without grabbing hardware device
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.
4.2 OSS
There are multiple ways of making OSS-only programs output to PulseAudio:
4.2.1 ossp
Install ossp package and start osspd.service.
4.2.2 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.
4.3 GStreamer
Install gst-plugins-good, or gstreamer0.10-good-plugins if your intended program has a legacy GStreamer implementation.
4.4 OpenAL
OpenAL Soft should use PulseAudio by default, but can be explicitly configured to do so:/etc/openal/alsoft.conf
drivers=pulse,alsa
4.5 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.
5 Equalizer
PulseAudio has an integrated 10-band equalizer system. In order to use the equalizer do the following:
5.1 Load equalizer sink and dbus-protocol module
$ pactl load-module module-equalizer-sink $ pactl load-module module-dbus-protocol
5.2 Install and run the GUI front-end
Install python-pyqt4 and execute:
$ qpaeq
5.3 Load equalizer and dbus module on every boot
Edit the file /etc/pulse/default.pa 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
6 Applications
6.1 QEMU
To find out if QEMU supports the pulseaudio run:
$ qemu-system-x86_64 -audio-help | grep 'Name: pa'
The QEMU can use environment variables for audio configuration
export QEMU_AUDIO_DRV=pa export QEMU_PA_SINK=alsa_output.pci-0000_04_01.0.analog-stereo.monitor export QEMU_PA_SOURCE=input
For more pulseaudio configuration options run:
$ qemu-system-x86_64 -audio-help | grep '_PA_'
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.
- In the qemu-system-XXX command the XXX is the guest architecture. To see available use ls /usr/bin/qemu-system-* -1.
- 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.
6.2 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].
6.3 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.
6.4 Audacious
Audacious natively supports PulseAudio. In order to use it, set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.
6.5 Java/OpenJDK 6
Create a wrapper for the Java executable using padsp as seen on the Java sound with PulseAudio page.
6.6 Music Player Daemon (MPD)
configure MPD to use PulseAudio. See also MPD/Tips and Tricks#MPD and PulseAudio.
6.7 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
6.8 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.
7 Troubleshooting
See PulseAudio/Troubleshooting.
8 See also
- http://www.alsa-project.org/main/index.php/Asoundrc - ALSA wiki on .asoundrc
- http://www.pulseaudio.org/ - PulseAudio official site
- http://www.pulseaudio.org/wiki/FAQ - PulseAudio FAQ