PulseAudio
The aim of the article is to guide you in installing and configuring the PulseAudio server. For more Information about the PulseAudio Server check the PulseAudio Wiki.
Contents |
[edit] Installation
[edit] USE Flags
Before installation check the active USE flags. The USE flags of media-sound/pulseaudio are:
- X - Send PulseAudio information through the X11 protocol.
- alsa - Enable ALSA support.
- asyncns - Asynchronous name resolution for network sound devices.
- avahi - Enable net-dns/avahi support for network sound devices discovery.
- bluetooth - Enable net-wireless/bluez support for Bluetooth sound devices.
- caps - Enable POSIX capabilities support for PulseAudio dropping root rights.
- dbus - Enable D-Bus support.
- doc - Installs API documentation.
- glib - Enable glib support for the libpulse client library, so it can be used by glib-based programs.
- gnome - Store user preferences in gconf. Not compatible with system-wide USE flag.
- ipv6 - Enable Internet Protocol Version 6 support.
- jack - Enable JACK support.
- libsamplerate - Use media-libs/libsamplerate for sample rate conversions.
- lirc - Enable support for remote controls.
- oss - Enable Open Sound System support.
- realtime - Enable sys-auth/rtkit support for realtime prioritization.
- system-wide - (Not recommend) Installs the system-wide PulseAudio server.
- tcpd - Enable TCP wrapper support.
- test - Installs some test programs.
- udev - (Recommend) Sound device discovery by udev.
Activate the pulseaudio USE flag in /etc/make.conf to enable support for PulseAudio in other programs. You don't need to install PulseAudio by yourself, but instead let it be installed as a dependency of these other programs:
For ALSA "fallback" support install media-plugins/alsa-plugins with the pulseaudio USE flag enabled:
[edit] Multi-user support
In a normal multi-user setup (no system-wide USE flag) it doesn't make sense to share sound devices. To give rights to the sound devices only to the local active user session, you have to have sys-fs/udev and sys-apps/coreutils installed with the USE flag acl enabled. Also you need the following kernel option:
| Linux Kernel Configuration: |
File systems --->
Pseudo filesystems --->
-*- Virtual memory file system support (former shm fs)
[*] Tmpfs POSIX Access Control Lists
|
After a restart the permission field of many of the sound device nodes should contain the plus character in the end:
crw-rw----+ 1 root audio 116, 7 Aug 2 08:57 pcmC0D0p
[edit] Configuration
PulseAudio's configuration files are located in /etc/pulse/. However, you probably don't need to edit the configuration to get PulseAudio working. If you do need to, make sure you pay close attention to the comments.
[edit] eselect esd
Run eselect so that esound applications use PulseAudio:
[edit] access rights
For an one-user system it is sufficient to add the user to the audio group:
For a normal multi-user system you should let udev manages the access rights, see above.
[edit] PulseAudio Server
At this point, you should have a working Pulseaudio installation. There are a few alternate ways to run PulseAudio, though. If you're just setting up a normal desktop system, skip ahead to the next section on application support.
[edit] System Server
It's possible to use a system-wide instance for the PulseAudio server. This is strongly discouraged by upstream, though, except in extremely special cases, such as
- embedded systems that don't have user accounts or
- running MPD independent of the currently logged in user.
You will want to add pulseaudio to the default runlevel.
Then, add your user to the pulse and pulse-access groups. For the Music Player Daemon, the user name is mpd.
[edit] Networking
If you want to setup PulseAudio as a network sound server and try to run it via the init.d-script with the unchanged default configs, you may get these messages:
| Code: Network error messages |
May 2 19:44:25 [pulseaudio] pid.c: Stale PID file, overwriting. May 2 19:44:25 [pulseaudio] main.c: setrlimit(RLIMIT_NICE, (31, 31)) failed: Operation not permitted May 2 19:44:25 [pulseaudio] main.c: setrlimit(RLIMIT_RTPRIO, (9, 9)) failed: Operation not permitted May 2 19:44:25 [pulseaudio] x11wrap.c: XOpenDisplay() failed May 2 19:44:25 [pulseaudio] module.c: Failed to load module "module-x11-publish" (argument: ""): initialization failed. May 2 19:44:25 [pulseaudio] main.c: Module load failed. May 2 19:44:25 [pulseaudio] main.c: failed to initialize daemon. May 2 19:44:25 [pulseaudio] main.c: daemon startup failed. |
The solution is to edit /etc/pulse/default.pa and to comment out the lines:
# load-module module-x11-publish ... # load-module module-gconf
For an easy configuration for listening on a TCP port (4713 by default), add this line to default.pa:
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/16
For the output of the sound, if you use ALSA and have only one card, this line (again in default.pa) should be fine:
load-module module-alsa-sink
On the client, add the pulseaudio to make.conf and reemerge the packages with this support (for example media-libs/xine-lib). This will also emerge media-sound/pulseaudio for you as a dependency. Then edit the file /etc/pulse/client.conf and add this(replace SERVER with you PulseAudio server):
default-server = tcp:SERVER:4713
[edit] Tools
There are several tools for managing PulseAudio in portage, use app-portage/eix to search for them and get their description:
One application in particular is media-sound/paprefs, it provides a nice "control panel" for the PulseAudio server which is useful when you're not running something like GNOME where the PulsaAudio control are integrated (provided you emerged GNOME with pulseaudio enabled).
Pavucontrol - Volume Control
emerge pavucontrol
Paprefs - Preferences configuration dialog for PulseAudio
emerge paprefs
[edit] Application support
The Pulseaudio wiki has an excellent page on setting up various applications to use PulseAudio for output. Particularly, the section on setting up ALSA applications will let you get apps using the ALSA APIs to run through Pulseaudio, which should cover most apps that don't directly support PulseAudio.
[edit] GStreamer
GStreamer plugins are available through "split" ebuilds on Gentoo. For the GStreamer Pulseaudio plugin, emerge media-plugins/gst-plugins-pulse:
Or set the pulseaudio USE flag on media-plugins/gst-plugins-meta. Which will merge media-plugins/gst-plugins-pulse automatically.
[edit] Troubleshooting
[edit] Locked sound device
PulseAudio handles things poorly when another program has locked the audio device. Open the PulseAudio volume control application(media-sound/pavucontrol), and check the Output Devices tab. If the only available device is "Dummy Output", it means that PulseAudio couldn't access your real audio devices. Running fuser /dev/snd/* will let you see which process IDs are holding the audio device, and closing / killing that process will frequently get PulseAudio working again(Pidgin and Flash are programs known to cause this).
If you see a Dummy Output but fuser doesn't show anything, it's possible that there's another issue with output. Kill all instances of PulseAudio, and then run "pulseaudio -vvvv" in a terminal to get more verbose debug output.
[edit] Flash support
Flash Player 9: If you want to have Flash support on your system you will have to install libflashsupport.
Flash Player 10: Flash 10 should work well with PulseAudio out-of-the-box, if the alsa device named "default" is configured to use the pulse plugin, as instructed in the ALSA section below on this page.
Note From the current ebuild:
- You do not need libflashsupport to use adobe-flash with pulseaudio
- Please consider removing this package and using
- media-plugins/alsa-plugins[pulseaudio] instead.
[edit] pbbuttonsd cannot adjust volumes
app-laptop/pbbuttonsd needs access to PulseAudio to adjust the sound volume. So you have to add the user that is running pbbuttonsd (probably root) to the PulseAudio groups.
[edit] System Server & GNOME
If you want to hear system sounds in system-wide instance you need change startup script /etc/init.d/pulseaudio. In function start() add this text after start-stop-daemon --start --exec /usr/bin/pulseaudio -- ${PA_ALL_OPTS}:
...
start-stop-daemon --start --exec /usr/bin/pulseaudio -- ${PA_ALL_OPTS}
...
if [ -e /var/run/pulse/.esd_auth ]; then
chown pulse:pulse-access /var/run/pulse/.esd_auth
chmod 640 /var/run/pulse/.esd_auth
fi
[edit] Bluetooth Headset support
Add to the end of /etc/pulse/default.pa, or /etc/pulse/system.pa for a system-wide pulseaudio install:
load-module module-alsa-sink device=bluetooth load-module module-alsa-source device=bluetooth
Then under Default Sink and Default Source in PulseAudio Device Chooser, select your bluetooth headset and all audio will be routed to it.
[edit] Skype not detecting pulseaudio
If Skype happens not to detect PulseAudio after following the guide above, this forum thread could help you get it working: http://forums.gentoo.org/viewtopic-t-789181-highlight-pulseaudio.html
[edit] Flash/other ALSA users not giving sound
Make sure you have installed the ALSA extra plugins: Emerge alsa-plugins by running:
For system-wide configuration add the following to /etc/asound.conf or alternatively for every user to ~/.asoundrc in order for applications which uses ALSA to give any sound:
pcm.pulse {
type pulse
}
ctl.pulse {
type pulse
}
pcm.!default {
type pulse
}
ctl.!default {
type pulse
}
load-module module-alsa-sink device=hw:0 load-module module-alsa-source device=hw:0
[edit] No sound from the subwoofer
To make PulseAudio use the subwoofer when upmixing stereo audio, "disable-lfe-remixing = no" shuld be added to /etc/pulse/daemon.conf (pulseAudio must be restarted to activate this setting).
