PulseAudio

From ArchWiki
Revision as of 11:18, 22 September 2007 by Erm67 (talk | contribs)
Jump to navigation Jump to search


Introduction

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.

This article focus on having multiple programs playing sound at the same time on one machine.

Install

All packages are from the community repository so you need to have it enabled

pacman -Sy pulseaudio 

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

pacman -Sy padevchooser paman paprefs pavucontrol pavucontrol

For the applications who doesn't support PulseAudio and support ALSA it's recommend to install PulseAudio plugin for alsalibs. This plugin is available in the alsa-plugins package. (Note: When I write this, 20 of August of 2007, the package has not the PulseAudio plugin on it for a unknown reason to me but it's on the PKGBLUID of the same on the Arch Linux CVS)

pacman -Sy alsa-plugins

Configuration

First you need to add "pulseaudio" daemon in /etc/rc.conf example:

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

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 -d <user> pulse-access

Now you just need to set all the applications that you use to work with pulse, possibly through a plugin.

Configuration of ALSA for PulseAudio plugin

It's recommend that since most of applications use ALSA that you configure it so it works with PulseAudio also. This is done through the PulseAudio plugin for alsalibs (PulseAudio plugin is available through the alsa-plugins package). In order to ALSA use the PulseAudio we need to edit the /etc/asound.conf (recommended) or ~/.asoundrc to have this lines:

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

pulse in pcm.pulse and ctl.pulse it's just a name, you can change it but it would change the next steps.

If you want that by default that ALSA use PulseAudio plugin you change also add this to /etc/asound.conf or ~/.asoundrc

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

If you selected pulse to be your default device you need to specify the hardware device to PulseAudio in /etc/pulse/default.pa 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


If haven't made the PulseAudio as ALSA default, in the applications that you use you need to change the ALSA device to "pulse" so it works.

Configuration of adobe flash plugin for PulseAudio

The default Adobe flash plugin for Mozilla doesn't work well with the PulseAudio plugin for ALSA so you won't get no sound but there is a way make the flash plugin work with PulseAudio even if you end up with a little delay. This is done through the libflashsupport and there is a package for it on the AUR. Link : [1] This lib should auto detect the PulseAudio and work but it doesn't so we need to make this library to use PulseAudio. We can do this through the enviromment variable FLASH_FORCE_PULSEAUDIO and in order to all users have this working without any trouble we can create the variable at the login of a user. We do this editing the script /etc/profile.d/libflashsupport.sh (installed by the latest PKGBUILD):

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

Configuration of SDL for PulseAudio plugin

Many SDL games and applications can use pulseaudio setting the variable SDL_AUDIODRIVER="esd"


Configuration of OpenAL for PulseAudio plugin

Games that uses OpenAL can use pulseaudio directly writing this line in ~/.openalrc:

(define devices '(esd))

Using OSS apps with PulseAudio plugin

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

  padsp OSSprogram

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

  #!/bin/sh
  if test -x /usr/bin/padsp ; then
      exec /usr/bin/padsp /usr/bin/OSSprogram-real "$@"
  else
      exec /usr/bin/OSSprogram "$@"
  fi

Permanently change the daemon priority

Take a look at "schedtoold" [2]

See also

Allow multiple programs to play sound at once

External Links

http://www.pulseaudio.org/wiki/PerfectSetup - A good guide to make your configuration perfect
http://www.alsa-project.org/main/index.php/Asoundrc - Alsa wiki on .asoundrc
http://www.pulseaudio.org/ - PulseAudio official site