PulseAudio
- Networking support (P2P and server mode).
- Per-application volume controls.
- Better cross-platform support.
- Dynamic latency adjustment, which can be used to save power.
Installation[edit | edit source]
Prerequisites[edit | edit source]
PulseAudio can use but does not need any of:
- sys-apps/systemd or
- sys-auth/elogind (remember to add
elogind -systemd
to global USE flag).
Kernel[edit | edit source]
For motherboards containing Intel HDA sound cards, use the following kernel option for improved power-saving:
Device Drivers ---> <*> Sound card support ---> <*> Advanced Linux Sound Architecture ---> (2048) Pre-allocated buffer size for HD-audio driver
CONFIG_HIGH_RES_TIMERS is needed to avoid (snd_pcm_recover) underrun
errors and degraded audio when some applications are using pulseaudio:
General setup ---> Timers subsystem ---> [*] High Resolution Timer Support
Not all applications require CONFIG_HIGH_RES_TIMERS to operate properly however it is recommended for applications like audacity and it is good practice to enable it anyway to ensure compatibility with more advanced audio applications.
USE flags[edit | edit source]
Global[edit | edit source]
Several packages are aware of the pulseaudio
USE flag for enabling support for PulseAudio in other packages. Enabling this USE flag will pull in media-sound/pulseaudio automatically:
/etc/portage/make.conf
USE="pulseaudio"
Package[edit | edit source]
USE flags for media-sound/pulseaudio A networked sound server with an advanced plugin system
X
|
Build the X11 publish module to export PulseAudio information through X11 protocol for clients to make use. Don't enable this flag if you want to use a system wide instance. If unsure, enable this flag. |
alsa
|
Add support for media-libs/alsa-lib (Advanced Linux Sound Architecture) |
alsa-plugin
|
Request installing media-plugins/alsa-plugins with PulseAudio plugin enabled. This ensures that clients supporting ALSA only will use PulseAudio. |
asyncns
|
Use libasyncns for asynchronous name resolution. |
bluetooth
|
Enable Bluetooth Support |
caps
|
Use Linux capabilities library to control privilege |
dbus
|
Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc) |
doc
|
Build the doxygen-described API documentation. |
elogind
|
Use sys-auth/elogind for giving each session a PA client |
equalizer
|
Enable the equalizer module (requires sci-libs/fftw). |
gconf
|
Ensure gnome-base/gconf is present for pulseaudio GConf to GSettings module automatic migration (keeping the user configuration) |
gdbm
|
Use sys-libs/gdbm to store PulseAudio databases. Recommended for desktop usage. This flag causes the whole package to be licensed under GPL-2 or later. |
glib
|
Add support to dev-libs/glib-based mainloop for the libpulse client library, to allow using libpulse on glib-based programs. Build the GSettings PA module. |
gtk
|
Add support for x11-libs/gtk+ (The GIMP Toolkit) |
ipv6
|
Add support for IP version 6 |
jack
|
Add support for the JACK Audio Connection Kit |
libressl
|
Use dev-libs/libressl instead of dev-libs/openssl when applicable (see also the ssl useflag) |
libsamplerate
|
Build with support for converting sample rates using libsamplerate |
lirc
|
Add support for lirc (Linux's Infra-Red Remote Control) |
native-headset
|
Build with native HSP backend for bluez 5. |
ofono-headset
|
Build with oFono HFP backend for bluez 5, requires net-misc/ofono. |
orc
|
Use dev-lang/orc for just-in-time optimization of array operations |
oss
|
Enable OSS sink/source (output/input). Deprecated, upstream does not support this on systems where other sink/source systems are available (i.e.: Linux). The padsp wrapper is now always build if the system supports OSS at all. |
qt5
|
Add support for the Qt 5 application and UI framework |
realtime
|
Makes PulseAudio use RealtimeKit (sys-auth/rtkit) to get real-time priority while running. |
selinux
|
!!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur |
sox
|
Add support for Sound eXchange (SoX) |
ssl
|
Use dev-libs/openssl to provide support for RAOP (AirPort) streaming. |
system-wide
|
Allow preparation and installation of the system-wide init script for PulseAudio. Since this support is only supported for embedded situations, do not enable without reading the upstream instructions at https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/ . |
systemd
|
Build with sys-apps/systemd support to replace standalone ConsoleKit. |
tcpd
|
Add support for TCP wrappers |
test
|
Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently) |
udev
|
Enable virtual/udev integration (device discovery, power and storage device support, etc) |
webrtc-aec
|
Uses the webrtc.org AudioProcessing library for enhancing VoIP calls greatly in applications that support it by performing acoustic echo cancellation, analog gain control, noise suppression and other processing. |
zeroconf
|
Support for DNS Service Discovery (DNS-SD) |
Emerge[edit | edit source]
After setting USE flags be sure to update the system so the changes take effect:
root #
emerge --ask --changed-use --deep @world
Additional software[edit | edit source]
- media-sound/pavucontrol - Pulseaudio Volume Control, a GTK based mixer for PulseAudio.
- media-sound/pulsemixer - CLI and curses mixer for PulseAudio
- media-sound/paprefs - PulseAudio Preferences, a configuration dialogue for PulseAudio.
- KDE's Phonon integrated PulseAudio configuration and mixing, but it is not as powerful as pavucontrol or paprefs.
- media-sound/pulseaudio-modules-bt - replacement for
bluetooth
USE-flag, may have better sound quality and allows for a codec selection inpavucontrol
Configuration[edit | edit source]
Permissions[edit | edit source]
This is the only supported configuration by upstream and Gentoo developers.
PulseAudio uses udev to dynamically give access to the soundcards to the currently "active" user.
To make this possible, ACLs (Access Control Lists) are required:
File systems ---> Pseudo filesystems ---> [*] Tmpfs virtual memory file system support (former shm fs) [*] Tmpfs POSIX Access Control Lists
If a desktop profile is not being used, check that sys-apps/systemd are installed with the acl
USE flag enabled, and (if using OpenRC) that sys-auth/pambase is installed.
When finished, verify the permissions are working correctly:
user $
getfacl /dev/snd/controlC0 | grep -Eo "user:.+:" | cut -d: -f2
<YOUR_USERNAME>
For systemd logind managed permissions to be respected, no one may be part of the audio group (not even even the user pulse). Remove any and all users from the audio group:
root #
gpasswd -d <user> audio
Configuring other applications[edit | edit source]
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
If you previous had followed this article, upon upgrade to a fixed version (there should also be an einfo reminder), please remove the asound.conf file.
The media-plugins/alsa-plugins must be installed with the pulseaudio
USE flag enabled:
root #
emerge --ask media-plugins/alsa-plugins
You need to enable the following module in /etc/pulse/default.pa:
/etc/pulse/default.pa
load-module module-oss
- GStreamer
Several GConf keys must be set:
- Manual with gconftool:
user $
gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosink pulsesink
user $
gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosrc pulsesrc
Some programs might still require GStreamer output plugin to be manually set to PulseAudio Audio Sink.
- ESD
Enable the following module in /etc/pulse/default.pa:
/etc/pulse/default.pa
load-module module-protocol-esound-unix
Also eselect the PulseAudio implementation:
root #
eselect esd set esdcompat
- libao
Set the following in /etc/libao.conf:
/etc/libao.conf
default_driver=pulse
- OpenAL
Set the following in /etc/openal/alsoft.conf:
/etc/openal/alsoft.conf
drivers = pulse
Set the following in /etc/mplayer/mplayer.conf:
/etc/mplayer/mplayer.conf
ao=pulse
Without udev or systemd[edit | edit source]
Using PulseAudio without udev or systemd is not recommended. This breaks both auto-detection and hot-plugging.
If you are using ALSA as a PulseAudio sink (output) and routing ALSA apps to PA but not using udev, you must set a specific device to be used. Otherwise, PulseAudio will use the ALSA device "default" as the 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.
/etc/pulse/default.pa
Using a specific ALSA device as PulseAudio sink/sourceload-module module-alsa-sink device=hw:0,0 load-module module-alsa-source device=hw:1,0
If you forget to specify this when using the ALSA sink/source modules, you may not notice any problems until you restart PulseAudio (e.g. by logging out and back in or rebooting). You will be left with no audio, a slow desktop environment and hanging applications until you resolve the loop, restart alsasound and kill all running pulseaudio processes.
Headless server[edit | edit source]
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[edit | edit source]
First configure USE flags and emerge the package. The system-wide USE flag is masked, so we have to unmask it.
root #
mkdir -p /etc/portage/profile
root #
echo "-system-wide" >> /etc/portage/profile/use.mask
root #
echo "media-sound/pulseaudio system-wide" >> /etc/portage/package.use
root #
emerge --ask --oneshot pulseaudio
Add the following two lines somewhere in the system.pa file:
/etc/pulse/system.pa
load-module module-native-protocol-tcp auth-ip-acl=1.2.3.0/24 load-module module-alsa-sink
Replace 1.2.3.0/24 with the network mask that you want to be able to access the server.
If you have multiple ALSA devices, you will need to specify the device to use by adding device or device_id to the module-alsa-sink module
Tell the init script that we really do want to do this, and then start it up:
root #
echo "PULSEAUDIO_SHOULD_NOT_GO_SYSTEMWIDE=1" >> /etc/conf.d/pulseaudio
root #
rc-update add pulseaudio default
root #
rc-service pulseaudio start
Client[edit | edit source]
user $
pacmd load-module module-tunnel-sink server=1.2.3.4
server (1.2.3.4) is the IP of the server.
For a more permanent solution you can add the following to your default.pa file
/etc/pulse/default.pa
load-module module-tunnel-sink server=1.2.3.4
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.
Allow multiple users to use PulseAudio concurrently[edit | edit source]
In some situations, like software isolation, it may be desirable to run some programs as another users and have access to the Pulseaudio daemon. By default, the PulseAudio daemon does not accept connections by secondary users.
The following configuration runs PulseAudio daemon using a UNIX socket that accepts connections from other users.
/etc/pulse/default.pa
load-module module-native-protocol-unix auth-anonymous=1 socket=/tmp/pulse-socket
/etc/pulse/client.conf
default-server = unix:/tmp/pulse-socket
The above configuration allows different users to access the same sound server. Users do not need to be in the audio, pulse-access or pulse groups. PulseAudio server may need to be executed at startup with the command pulseaudio -D. For example, in case you are using i3wm:
/home/user/.config/i3/config
exec pulseaudio -D
Equalizer[edit | edit source]
The equalizer module is considered unstable and might be removed from pulseaudio. For more, see the mailing list.
Make sure you installed pulseaudio with the equalizer
USE flag enabled.
Enabling the required modules[edit | edit source]
Add the following two lines somewhere in the default.pa file :
/etc/pulse/default.pa
load-module module-dbus-protocol load-module module-equalizer-sink
Restart the pulseaudio instance. This should be as easy as:
user $
pulseaudio -k
user $
pulseaudio --start
Choosing the equalizer sink[edit | edit source]
The command should list the index and name of the equalizer sink:
user $
pacmd list-sinks | grep -B1 -e "name:.*equalizer"
Use pavucontrol or a similar program like media-sound/pulsemixer to select the equalizer sink for sound output. It may be listed as a device starting with FFT based equalizer.
Control the equalizer levels[edit | edit source]
The equalizer levels can now be controlled with the Qt GUI called qpaeq.
Known issues[edit | edit source]
- Short sound events (e.g. the terminal bell) distort ongoing sound streams (e.g. music)
Troubleshooting[edit | edit source]
No sound[edit | edit source]
- After installation: If you have no sound while using ALSA, consider unmuting the sound card. Launch alsamixer and make sure each column has a green
00
under it (use the m key to toggle mute/unmute). Install media-sound/pavucontrol and check if there is any output on the pavucontrol panel when playing audio. - After upgrading the system: pulseaudio's user configuration files can become corrupt. Deleting ~/.pulse* configuration files and forcing fresh ones to be generated by restarting the daemon may fix no sound condition.
Enable debug mode[edit | edit source]
To get more informations you need to set the following in /etc/pulse/daemon.conf:
/etc/pulse/daemon.conf
log-level=debug
Afterward restart the daemon:
user $
pulseaudio -k
Audio/Video out of sync[edit | edit source]
When using PulseAudio over your local network, you can experience out-of-sync problems. Solve this by adding tsched=0:
/etc/pulse/default.pa
load-module module-udev-detect tsched=0
This disables time scheduling. Afterwards restart the daemon:
user $
pulseaudio -k
Dummy output[edit | edit source]
If the only playback device is the Dummy Output, PulseAudio cannot access your sound devices. Either the user has no permissions (see section Permissions or another program blocks the access. Try:
user $
fuser -v /dev/snd/*
It shows the relevant program. Close the program and reconfigure it to use PulseAudio.
No guarantees on actual latencies[edit | edit source]
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[edit | edit source]
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[edit | edit source]
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 /etc/pulse/daemon.conf 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.
Starting with version 7.0 there is also soxr resamplers made available by enabling the sox USE flag. In particular resample-method = soxr-mq should provide acceptable quality while even the higher quality and hence slower soxr-hq is still cheaper than the default speex-float-1. But be warned that the soxr resamplers have roughly 5-20 times higher latency than speex-float, in terms of time the worst case for soxr-mq/hq can be as high as 20 ms while soxr-vhq latency can in few specific setups reach over 27 ms. In terms of feeling 20 ms can range from unnoticeable to irritating depending on person and use case (the usual PA latency's lower bound is around 20-25 ms and more commonly often around 70-90 ms, for comparison).
Using a version of PA with Orc support can noticeably decrease CPU usage, too. Also PA has the ability, if certain conditions are met, to automatically switch sinks between common sampling rates, this effectively can avoid some re-sampling.
grsec and PulseAudio[edit | edit source]
Gentoo no longer provides sys-kernel/hardened-sources with the grsecurity patches. See [this post].
Make sure CONFIG_GRKERNSEC_SYSFS_RESTRICT is not enabled if you are using a grsecurity kernel. PulseAudio’s module-udev-detect needs to access /sys to discover what cards are available on the system, and that kernel option disallows this for anyone but root.
Volume gets randomly louder or reset to 100%[edit | edit source]
This may be caused by misbehaving PulseAudio-enabled programs when PulseAudio has flat volumes feature enabled. Disable it in daemon config:
/etc/pulse/daemon.conf
flat-volumes = no
In pavucontrol, unable to change output device for applications that use OpenALsoft[edit | edit source]
It can happen that you want to change the output device for an application, but trying to change it in pavucontrol has no effect. If this application use OpenALsoft, this one has a configuration option that inhibits sink changes. To disable this option, you can create a configuration file for OpenALsoft :
~/.config/alsoft.conf
[pulse] allow-moves=yes

Or, by running alsoft-config :
FAQ[edit | edit source]
See PulseAudio's Frequently Asked Questions.
See also[edit | edit source]
- ALSA — describes the setup of a sound card with ALSA (Advanced Linux Sound Architecture).
- PipeWire — low-latency and graph-based processing engine and a server for interfacing with audio and video devices
External resources[edit | edit source]
- PulseAudio: The Perfect Setup
- Why you should care about PulseAudio (and how to start doing it)
- More general troubleshooting tips