PulseAudio
- English
PulseAudio (or PA for short) is a multi-platform, open source, sound server that provides a number of features on top of the low-level audio interface ALSA, 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.
- Plugin modules.
Installation
Prerequisites
PulseAudio can use, but does not need, either systemd or sys-auth/elogind. If using the latter, remember to add elogind and -systemd as global USE flags.
Kernel
For motherboards containing HDA sound cards, use the following kernel option for improved power-saving only on machines that are not amd64- or x86-based.
Device Drivers ---> <*> Sound card support Search for <code>CONFIG_SOUND</code> to find this item. ---> <*> Advanced Linux Sound Architecture Search for <code>CONFIG_SND</code> to find this item.
Refer to the "Kernel" section of the "ALSA" page for setting the right kernel options for sound card detection.
PulseAudio uses udev to dynamically give the currently 'active' user access to the soundcard(s). To make this possible, ACLs (Access Control Lists) are required.
File systems ---> Pseudo filesystems ---> [*] Tmpfs virtual memory file system support (former shm fs) Search for <code>CONFIG_TMPFS</code> to find this item. [*] Tmpfs POSIX Access Control Lists Search for <code>CONFIG_TMPFS_POSIX_ACL</code> to find this item.
CONFIG_HIGH_RES_TIMERS is needed to avoid (snd_pcm_recover) underrun errors and degraded audio when some applications are using PulseAudio. Not all applications require CONFIG_HIGH_RES_TIMERS to operate properly; however, it is recommended for applications such as Audacity, and good practice to enable it to ensure compatibility with other audio applications.
General setup --->
Timers subsystem --->
[*] High Resolution Timer Support Search for <code>CONFIG_HIGH_RES_TIMERS</code> to find this item.
USE flags
The global pulseaudio USE flag enables support for PulseAudio in packages. Enabling it in make.conf will cause media-libs/libpulse to be installed when emerging such packages.
The USE flags for libpulse itself are:
USE flags for media-libs/libpulse Libraries for PulseAudio clients
+asyncns
Use libasyncns for asynchronous name resolution.
+glib
Add support to dev-libs/glib-based mainloop for the libpulse client library, to allow using libpulse on glib-based programs.
X
Add support for X11
dbus
Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc)
doc
Build the doxygen-described API documentation.
gtk
Add support for x11-libs/gtk+ (The GIMP Toolkit)
selinux
!!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
systemd
Enable use of systemd-specific libraries and features like socket activation or session tracking
test
Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
valgrind
Enable annotations for accuracy. May slow down runtime slightly. Safe to use even if not currently using dev-debug/valgrind
The USE flags for the media-sound/pulseaudio-daemon package are:
USE flags for media-sound/pulseaudio-daemon Daemon component of PulseAudio (networked sound server)
+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.
+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
Build the GSettings PA module.
+orc
Use dev-lang/orc for just-in-time optimization of array operations
+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.
aptx
aptX (HD) over Bluetooth (many Android compatible headphones), requires media-plugins/gst-plugins-openaptx.
bluetooth
Enable Bluetooth Support
dbus
Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc)
elogind
Use sys-auth/elogind for giving each session a PA client
equalizer
Enable the equalizer module (requires sci-libs/fftw and sys-apps/dbus).
fftw
Enable the virtual surround sink module (requires sci-libs/fftw).
gstreamer
Build GStreamer-based RTP protocol module which supports more advanced RTP features like OPUS payload encoding.
jack
Add support for the JACK Audio Connection Kit
ldac
LDAC over Bluetooth (primarily Sony headphones), requires media-plugins/gst-plugins-ldac.
lirc
Add support for lirc (Linux's Infra-Red Remote Control)
ofono-headset
Build with optional oFono HFP backend for bluez 5, requires net-misc/ofono.
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.
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)
valgrind
Enable annotations for accuracy. May slow down runtime slightly. Safe to use even if not currently using dev-debug/valgrind
zeroconf
Support for DNS Service Discovery (DNS-SD)
Emerge
After setting USE flags, be sure to update the system so the changes take effect:
root #emerge --ask --changed-use --deep @worldOnce the system has been updated, the libpulse and pulseaudio-daemon packages can be installed:
root #emerge --ask media-libs/libpulse media-sound/pulseaudio-daemonAdditional software
- media-sound/pavucontrol - Pulseaudio Volume Control, a GTK mixer. media-sound/pavucontrol-qt is the Qt version.
- media-sound/pulsemixer - TUI mixer.
- media-sound/paprefs - PulseAudio Preferences, a GTK-based configuration UI.
- kde-plasma/plasma-pa - KDE Plasma applet integrating configuration and mixing, but not as powerful as pavucontrol or paprefs.
Configuration
Permissions
This is the only supported configuration by upstream and Gentoo developers.
If a desktop profile is not being used:
- for systemd, check that sys-apps/systemd is installed with the acl USE flag is enabled.
- for OpenRC, check that sys-auth/pambase is installed.
Then, verify the permissions are working correctly:
user $getfacl /dev/snd/controlC0 | grep -Eo "user:.+:" | cut -d: -f2
This should output the name of the user using PulseAudio.
For systemd logind-managed permissions to be respected, no-one should belong to the
audio group, not even the pulse user. To remove a user from the audio group:
root #gpasswd -d <username> audioFiles
- /etc/pulse/default.pa - daemon startup file. Refer to default.pa(5) .
- $HOME/.config/pulse/default.pa - user-specific version of /etc/pulse/default.pa.
- /etc/pulse/system.pa - daemon startup file for system-wide setups.
- /etc/pulse/client.conf - client configuration file. Refer to pulse-client.conf(5) .
- $HOME/.config/pulse/client.conf - user-specific version of /etc/pulse/client.conf.
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.
The media-plugins/alsa-plugins must be installed with the pulseaudio USE flag enabled:
root #emerge --ask media-plugins/alsa-pluginsEnable the following module in /etc/pulse/default.pa:
/etc/pulse/default.paload-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.
- libao
Set the following in /etc/libao.conf:
/etc/libao.confdefault_driver=pulse
- OpenAL
Set the following in /etc/openal/alsoft.conf:
/etc/openal/alsoft.confdrivers = pulse
Set the following in /etc/mplayer/mplayer.conf:
/etc/mplayer/mplayer.confao=pulse
Without udev or systemd
Using PulseAudio without udev or systemd is not recommended. This breaks both auto-detection and hot-plugging.
If using ALSA as a PulseAudio sink (output) and routing ALSA apps to PulseAudio but not using udev, the device to use must be specified. 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 to /etc/pulse/default.pa, where 0,0 should be replaced by the appropriate values as found in the output of aplay -l. Without this, problems may only show up on restating PulseAudio (e.g. by logging out and back in or rebooting): there will be with no audio, a slow desktop environment and hanging applications until the loop is resolved. Once the configuration is updated, restart alsasound and kill all running PulseAudio processes.
In the following example, there are two soundcards specified: card 0, device 0 is used as a sink (audio output, e.g. speakers), and card 1, device 0 is used as a source (audio input, e.g. microphone). PulseAudio will still be able to access other cards.
/etc/pulse/default.paUsing 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
Headless server
A headless PulseAudio server is a server which has no display attached to it but does have speakers. This provides the ability to use the remote server's speakers for audio output.
Server
root #mkdir -p /etc/portage/profile
root #echo "-system-wide" >> /etc/portage/profile/use.mask
root #echo "media-sound/pulseaudio-daemon system-wide" >> /etc/portage/package.useThen re-emerge pulseaudio-daemon:
root #emerge --ask --oneshot pulseaudio-daemonNext, add the following two lines somewhere in the /etc/pulse/system.pa file:
/etc/pulse/system.paload-module module-native-protocol-tcp auth-ip-acl=x.x.x.x/24 load-module module-alsa-sink
where x.x.x.x/24 should be replaced by the network mask for accessing the server.
With multiple ALSA devices, specify the device to use by adding the device or device_id to the module-alsa-sink module, as described in the "Without udev or systemd" section.
Finally, on OpenRC systems, configure the pulseaudio service to confirm the required setup, and start the service:
root #echo "PULSEAUDIO_SHOULD_NOT_GO_SYSTEMWIDE=1" >> /etc/conf.d/pulseaudio
root #rc-update add pulseaudio defaultroot #rc-service pulseaudio start
Client
user $pacmd load-module module-tunnel-sink server=x.x.x.xserver (x.x.x.x) is the IP of the server.
where x.x.x.x should be replaced by the IP address of the server.
For a more permanent solution, add the following to the /etc/pulse/default.pa file:
/etc/pulse/default.paload-module module-tunnel-sink server=x.x.x.x
where x.x.x.x should again be replaced by the IP address of the server.
When setup is complete, pavucontrol should list the remote server listed under "Output Devices", and under "Playback" there should be a button next to the "Mute audio" button which, when selected, will switch that audio stream to whichever output is required.
Multiple concurrent users
By default, the PulseAudio daemon doesn't accept connections from secondary users. However, in some situations, like software isolation, it may be desirable for a user to run programs as some other user and still have access to the PulseAudio daemon.
In this situation, configure PulseAudio to use a UNIX domain socket that accepts connections from secondary users:
/etc/pulse/default.pa.d/multi-user.paConfigure PulseAudio to use a UNIX domain socketload-module module-native-protocol-unix auth-anonymous=1 socket=/tmp/pulse-socket
Then configure the PulseAudio client library to use this socket:
/etc/pulse/client.confMake the clients use the UNIX socketdefault-server = unix:/tmp/pulse-socket
This configuration does not need users to be in the audio, pulse-access, or pulse groups.
Equalizer
To enable the equalizer, build media-sound/pulseaudio-daemon with the equalizer USE flag enabled. This also requires that the dbus USE flag be enabled.
Add the following two lines somewhere in the default.pa file :
/etc/pulse/default.paload-module module-dbus-protocol load-module module-equalizer-sink
Usage
Starting the daemon
systemd
To enable PulseAudio for the current user run:
user $systemctl --user enable --now pulseaudio.service pulseaudio.socketRoot can enable PulseAudio for all users:
root #systemctl --global enable pulseaudio.service pulseaudio.socketOpenRC
Running PulseAudio "system-wide" via the pulseaudio OpenRC system service is strongly discouraged unless there is good reason to do so.
The standard way of starting the PulseAudio daemon is autospawning[1] , in which D-Bus is used to request that the daemon be started. On non-systemd systems, the media-sound/pulseaudio-daemon package will install the file enable-autospawn.conf to enable autospawning.
The pulseaudio.desktop file calls the start-pulseaudio-x11 script, which configures PulseAudio for running under X.
Manually
To start a PulseAudio daemon:
user $pulseaudio -DEqualizer
To list the index and name of the equalizer sink:
user $pacmd list-sinks | grep -B1 -e "name:.*equalizer"Use pavucontrol or a similar program to select the equalizer sink for sound output. It may be listed as a device starting with "FFT based equalizer".
Equalizer levels can be controlled with media-sound/qpaeq , a Qt GUI.
Short sound events (e.g. the terminal bell) can distort ongoing sound streams (e.g. music).
Troubleshooting
Refer to PulseAudio/troubleshooting.
See also
- ALSA — the Linux kernel's API for sound cards, together with an associated software framework
- PipeWire — low-latency, graph-based, processing engine and server, for interfacing with audio and video devices.
External resources
Official documentation
- Running PulseAudio
- PulseAudio: The Perfect Setup
- PulseAudio Frequently Asked Questions
- pulseaudio(1)
- pulse-daemon.conf(5)
- default.pa(5)
- pacmd(1)
Other information
- Getting DTS 5.1+ sound via S/PDIF or HDMI using PulseAudio
- More general troubleshooting tips
- Why you should care about PulseAudio (and how to start doing it)
References
- ↑ "Running PulseAudio". Retrieved on 2026年08月18日.