PulseAudio Tames the Linux Audio Zoo, Part 2

Monday Jun 30th 2008 by Carla Schroder

After encountering a number of problems on both Kubuntu Gutsy and Hardy and debugging them, this week's PulseAudio series entry will be Fixing *buntu. This may be useful to users on other distributions as well because it covers permission problems, ALSA problems, and init problems.

Last week we learned a bit about the chaotic jumble that is audio on Linux, and about the new PulseAudio sound server that just may create bit of order, and perhaps some more user-friendliness. Several Linux distributions default to using PulseAudio, such as Fedora, Ubuntu Hardy Heron, and Mandriva. Many others now include it in their software repositories, or you can follow this guide for installing the latest version from source code.

Application support for PulseAudio is not quite complete. Notable problem applications are Skype, Flash Player, and Real Player. I shall refrain from my usual sarcastic commentary on the inability of the vendors of closed, proprietary applications to keep pace with FOSS development, because a person should exhibit a bit of class now and then, however insincere. Visit The Perfect Setup for instructions on getting these to work.

I had originally intended to make this as general a guide as possible, but I ran into a number of problems on both Kubuntu Gutsy and Hardy and got all wrapped up in debugging them, so today is going to be Fix *buntu Day. This may be useful to users on other other distributions as well because it covers permission problems, ALSA problems, and init problems, so everyone is welcome to tag along.

PulseAudio has a collection of good user-space utilities:
  • Device Chooser
  • Volume Control
  • Volume Meter
  • Manager
  • Preferences
If your distribution has not messed with the package names, installing pulseaudio gets you the core sound server, and pavucontrol, pavumeter, paman, padevchooser, and paprefs are the user-space applications. Your distribution may also install Avahi/Zeroconf because PulseAudio uses it to auto-detect other audio servers on your network, and it should also install libasound2-plugins for ALSA compatibility.

After installation, run a simple command-line test:

$  pulseaudio --version

W: main.c: WARNING: called SUID root, but not in group 'pulse-rt'.
pulseaudio 0.9.6

pulse-rt stands for "pulse real-time", and you need to be a member of the pulse-rt group to get rid of this warning. The easy and safe way is to edit the /etc/group file directly:


Anytime you change your group memberships you have to log out and then log back in to activate the changes, so do that next. After logging back in, check your group membership:

$ groups
carla adm dialout floppy audio dip video plugdev fuse lpadmin admin pulse-rt

It isn't strictly necessary to do this, but enabling realtime priority means better audio quality.

We still need ALSA compatibility, so add these lines to /etc/asound.conf:

pcm.pulse {type pulse}
ctl.pulse {type pulse}

Now find yourself a nice WAV file to play and give it a whirl:

$  aplay -D pulse music/1st-set.wav
*** PULSEAUDIO: Unable to connect: Connection refused
aplay: main:545: audio open error: Connection refused

Oops. A quick ps ax|grep pulse reveals that the PulseAudio daemon isn't even running. Another symptom of this is when you open the graphical Pulse Audio Manager, you see something like Figure 1 with a "connection refused" message. So what to do?

PulseAudio can run as an ordinary system-wide daemon if you wish. To enable this, edit /etc/default/pulseaudio like this:

That should be the opposite of the default. Then any user that needs access to the Pulse server needs to be added to the pulse-access group, including root. Then start it in the usual way:

$ sudo /etc/init.d/pulseaudio start

 * Starting PulseAudio Daemon      [ OK ]

Now when you open the PulseAudio Manager it looks like Figure 2, and aplay will play your file.

But on a multi-user system this is not the best way to run PulseAudio, according to the developers. It is better to run it per-user for these reasons: it creates a potential security hazard because it runs SUID, users can mess with other users' sound, and settings are system-wide instead of individualized. If you're on a single-user system then it doesn't matter.

If you want it to run per-user, then each user needs individual configuration and startup files. PulseAudio is already well-integrated into Gnome, and Gnome supports per-session startup, so the hard work is already done. If you're running a distribution that does not default to PulseAudio, create a symlink from Pulse's compatibility script to the ESD binary to load PulseAudio instead:

# ln -sf /usr/local/bin/esdcompat /usr/bin/esd

Verify your filepaths first, of course.

What do users of other desktop environments do? We'll get into detail on that next week. Meanwhile, KDE users can do this: stop it by running sudo /etc/init.d/pulseaudio stop, then reverse the changes to /etc/default/pulseaudio so that it does not start at boot. Then start it manually like this:

$ pulseaudio --high-priority --log-target=syslog

Check out the various userland tools, which you should find in your multimedia menu, and next week we'll learn how to configure per-user startup, learn about sinks and sources, and play networked sounds.


Carla Schroder is the author of the Linux Cookbook and the newly-released Linux Networking Cookbook, and is a regular contributor to LinuxPlanet.

This article was first published on LinuxPlanet.com.

Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved