PulseAudio

PulseAudio (or PA for short) is a sound server that provides a number of features on top of the low-level audio interface ALSA on Linux, such as:
 * Networking support (P2P and server mode).
 * Per-application volume controls
 * Better cross-platform support
 * Dynamic latency adjustment, which can be used to save power

Prerequisites
PulseAudio uses either:
 * sys-fs/udev and sys-auth/consolekit.
 * sys-apps/systemd

Kernel
If you have an Intel HDA soundcard, you probably want the following kernel option to improve power-saving:

Software
Portage knows the global USE flag pulseaudio for enabling support for PulseAudio in other packages. Enabling this USE flag will pull in automatically:

The recommend USE flags of pulseaudio are:

Optional USE flags of pulseaudio are:

After setting this you want to update your system so the changes take effect:

Addons

 * - Pulseaudio Volume Control, a GTK+ based mixer for PulseAudio.
 * - PulseAudio Preferences, a configuration dialog for PulseAudio.
 * KDE's Phonon integrated PulseAudio configuration and mixing, but it is not as powerful as pavucontrol or paprefs.

Permissions
PulseAudio uses udev and ConsoleKit to dynamically give access to the soundcards to the currently "active" user. If you are running Systemd it will also take care of this without needing to use ConsoleKit.

To make this possible ACLs (Access Control Lists) are required:

If you're not using a desktop profile, check that or  are installed with enabled acl USE flag and that ConsoleKit is running if you are not running Systemd:

If not, enable it at boot time:

When you're finished, check, if your permissions are working correctly:

Configuring other applications
Some applications need to be configured to output to PulseAudio by default. A detailed list of these can be found on the PulseAudio wiki's PerfectSetup page.


 * ALSA

You need to install with pulseaudio USE flag enabled:

You need to enable the following module in :
 * OSS

You need to set several GConf keys:
 * GStreamer
 * You can use the graphical tool gstreamer-properties (part of ). Select under Audio Input and Audio Output each PulseAudio Sound Server.
 * Manuel with gconftool:

You need to enable the following module in :
 * ESD

Also you need to select with eselect the PulseAudio implementation:

You need to set the following in :
 * libao

You need to set the following in :
 * OpenAL

You need to set the following in :
 * MPlayer

Without udev/systemd
In case that you are using ALSA as a PulseAudio sink (output) and routing ALSA apps to PA but not using udev, you must make sure to have set a specific device to be used. Else, PulseAudio will use ALSA device "default" as sink which may be routed back to PulseAudio, forming a loop. To avoid this, add the parameter device=hw:0,0 (you can find the correct IDs by running aplay -l). In the following example, we use two soundcards, of which card 0, device 0 is used as a sink (audio output, e.g. speakers) and card 1, device 0 as a source (audio input, e.g. microphone). PulseAudio will still be able to access other cards than these but it needs these settings to avoid looping the default device in this setup.

Headless server
These instructions are for setting up a headless pulse audio server. Meaning a server which has no display on it but does have speakers. This provides the ability to use the remote server's speakers for audio output.

You will get warned in a dozen places for doing this, but it is the proper method.

Server
First configure USE flags and emerge the package. The system-wide USE flag is masked, so we have to unmask it.

Add the following 2 lines somewhere in the system.pa file

Replace 1.2.3.0/24 with the network mask that you want to be able to access the server.

Tell the init script that we really do want to do this, and then start it up.

Client
For a more permanent solution you can add the following to your default.pa file

Now in the pulse audio volume control you should see the remote server listed under Output Devices. Under playback you should have a button next to the Mute audio button that when clicked will let you switch that audio stream to whichever output you want.

Enable debug mode
To get more informations you need to set the following in :

Afterwards restart the daemon:

Audio/Video out of sync
When using PulseAudio over your local network, you can experience out-of-sync problems. Solve this by adding tsched=0:

This disables time scheduling. Afterwards restart the daemon:

Dummy Output
If the only playback device is the Dummy Output, PulseAudio can not access your sound devices. Either the user has no permissions (see section Permissions or another program blocks the access. Try:

It shows the relevant program. Close the program and reconfigure it to use PulseAudio.

No guarantees on actual latencies
Currently PA provides whatever latency at that moment is possible be it some milliseconds to hundreds of milliseconds without regard to what applications ask for.

In case of buffer under-run latencies are never decreased
Currently, if a buffer under-run occurs, PA buffers for longer increasing latency, but it then never tries to buffer for less until restart.

Re-sampling using up a lot of CPU time
Re-sampling can require quite a lot of computational power, PA defaults are rather conservative but in certain cases can still take a significant toll, in such cases edit and consider changing resample-method to something less CPU intensive, default-sample-format and default-sample-rate can also affect CPU utilization with higher bit-depth and larger difference in sample-rate generally needing more resources (e.g. re-sampling 44.1 kHz to 48 kHz is faster than re-sampling either to 192 kHz). Since re-sampling is done per each channel per input, channel configuration and number of applications can affect performance as well.

FAQ
See PA's Frequently Asked Questions.

External resources

 * PulseAudio: The Perfect Setup
 * Why you should care about PulseAudio (and how to start doing it)
 * More general troubleshoooting tips