PulseAudio - ParabolaWiki

# 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

- Required package: pulseaudio
- Optional GTK GUIs: paprefs and pavucontrol
- Optional volume control via mapped keyboard keys: pulseaudio-ctl
- Optional console (CLI) mixers: ponymix and pamixer-git
- Optional web volume control: PaWebControl
- Optional system tray icon: pasystray-git
- Optional KDE plasma applet: kdemultimedia-kmix and kdeplasma-applets-veromix (If KMix/Veromix fail to connect to PulseAudio at boot you may need to edit /etc/pulse/client.conf to include autospawn = yes instead of autospawn = no.)

## 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.

## Running

Warning: If you have per-user copies of configuration files (such as client.conf, daemon.conf or default.pa) in ~/.config/pulse/ or ~/.pulse/, make sure you keep them in sync with changes to the packaged files in /etc/pulse/. Otherwise, PulseAudio may refuse to start due to configuration errors.
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

### Autostarting in unsupported desktop environments

Note: As mentioned previously, PulseAudio is very likely launched automatically via either /etc/X11/xinit/xinitrc.d/pulseaudio or the files in /etc/xdg/autostart/ if users have some DE installed.

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

## 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.

### 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 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

## Applications

### 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.

Note:

- 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.

### 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

- 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

Categories:

- Sound
- Audio/Video
- Request:Merge