PulseAudio

From Gentoo Linux Wiki

Jump to: navigation, search

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

If you use ALSA you first need to make sure media-plugins/alsa-plugins is emerged with the pulseaudio USE flag enabled and if you'd like to use pulseadio system-wide deamon don't forget about enabling system-wide flag.

To find what USE-flags PulseAudio carries, run:

emerge -pv pulseaudio

For instance if you need JACK support, enable the jack USE flag.

To enable application support for Pulseaudio, add pulseaudio to your USE flags in /etc/make.conf. Specifying the --newuse switch to emerge will rebuild packages that have new USE flags, so once you've added the USE flag, run:

emerge --newuse world

Alternatively one can find which packages have the pulseaudio use flag via:

equery hasuse pulseaudio

and then re-build those packages.

[edit] Emerging

Emerge PulseAudio by running:

emerge -av pulseaudio

[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:

eselect esd list eselect esd set 1

[edit] plugdev group

In order for PulseAudio to be able to detect your sound devices using hal / dbus, the user running the pulseaudio daemon needs to be a member of the plugdev group.

Run usermod to add the pulse user to the group. Repeat for any additional users who may run audio applications that start the pulseaudio daemon.

usermod -a -G plugdev pulse usermod -a -G plugdev anotheruser

For more details, see Bug 273909.

[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 Music Player Daemon independent of the currently logged in user.

You will want to add pulseaudio to the default runlevel.

rc-update add pulseaudio default

Then, add your user to the pulse and pulse-access groups. For the Music Player Daemon, the user name is mpd.

gpasswd -a <USER> pulse gpasswd -a <USER> pulse-access

Finally, allow PulseAudio to own org.pulseaudio.Server by creating the file /etc/dbus-1/system.d/PulseAudio.conf

File: /etc/dbus-1/system.d/PulseAudio.conf
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>
    <policy user="pulse">
        <allow own="org.pulseaudio.Server"/>
    </policy>
</busconfig>

And do not forget to reload your dbus configuration by issuing:

/etc/init.d/dbus reload

[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:

File: /etc/pulse/default.pa
# 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:

File: /etc/pulse/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:

File: /etc/pulse/default.pa
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):

File: /etc/pulse/client.conf
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:

eix -S PulseAudio

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).

[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:

emerge -av media-plugins/gst-plugins-pulse

[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.

emerge -av 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 above on this page.

[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.

gpasswd -a root pulse gpasswd -a root pulse-access

[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}:

File: /etc/init.d/pulseaudio
...
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:

File: /etc/pulse/default.pa
 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] External links

Personal tools
In other languages