Linux.com

Feature: Graphics & Multimedia

Why you should care about PulseAudio (and how to start doing it)

By Nathan Willis on November 02, 2007 (3:00:00 PM)

Share    Print    Comments   

The sound server PulseAudio is a relative newcomer to the Linux audio arena, but since it has been selected as the default setup in the next releases of at least two major distributions (Fedora and Ubuntu), it's probably time to start looking into it.

The audio system options in Linux can be a bit confusing. The projects (ALSA, OSS, ESD, aRts, JACK, and GStreamer, to name a few) all describe themselves in broad, similar terms, and the panoply of packages reads like a circular mix-and-match game -- alsaplayer-esd, libesd-alsa, alsa-oss, alsaplayer-jack, gstreamer-alsa, gstreamer-esd, and so on. It can be difficult to tell how all the pieces fit together. Consider the package description for libasound2-plugins in Ubuntu, which says: "The ALSA library plugin 'jack' allows the ALSA library to play or capture via JACK (This should not be confused with the jackd output driver 'alsa', included in the jackd package, which allows the JACK daemon to play back via the ALSA library." Yeah -- how could anybody ever get those confused?

Sorting it out

This potential for confusion stems from multiple sources, including a shortage of user-friendly (as opposed to developer-friendly) documentation, and overlapping goals among several of the projects.

For instance, the Advanced Linux Sound Architecture (ALSA) project includes several distinct components. The set of kernel hardware drivers for audio cards is one, and the library that exposes the ALSA application programming interface (API) to software is another. You need the hardware drivers to get your sound card to produce audio, but any particular application may or may not use the library.

Or consider the KDE sound library aRts. It includes a sound server -- the low-level daemon that accepts audio from apps and feeds it to the hardware driver -- and higher-level functions like encoding and decoding various file and stream formats. Things are a little cleaner on the GNOME side. The Enlightened Sound Daemon (ESD) is the sound server, and a separate library (GStreamer) handles the codecs.

But the biggest source of confusion is that there are so many audio projects offering their own APIs, including the userspace ALSA library, aRts, ESD, and GStreamer. And as we have seen, each pair among them overlaps in different ways. In addition we have SDL and OpenAL for games, Open Sound System (OSS) for older general-purpose applications, and JACK for pro-level, low-latency operations.

Finally, some applications don't rely on any external libraries for audio functionality, but do it all internally. Most notable among these are the full-featured media playback apps, such as Xine and MPlayer. They often handle everything from format decoding to multichannel demuxing within the app itself.

It's easiest to explain where PulseAudio fits into the GNOME system because of that desktop environment's separation between individual tasks. An application like Rhythmbox relies on GStreamer to decode sound files from compressed form into raw audio. GStreamer in turn passes the audio down to ESD, and ESD delivers it to the ALSA hardware driver.

In this situation, PulseAudio replaces ESD without affecting the rest of the pipeline. But another player might rely on the ALSA userspace library, which is not part of the previous example. Here you can insert PulseAudio into the pipeline, again right above the kernel-level hardware drivers. It adds an extra layer, but with it you enjoy the benefit of all of your audio passing through the same sound server.

And that's the point: some apps are written to use the userspace ALSA API, some aRts, some JACK, some handle the audio internally. If you can reroute all of the audio through one handler, you get more control, fewer conflicts, and fewer surprises.

Sounds simple

The fastest way to get started with PulseAudio on your system is see if your distro provides packages, because many do. Although the next releases of Fedora and Ubuntu will use PulseAudio by default, they and other distros make packages available for the current releases, too. The PulseAudio wiki includes a list of which distros provide packages, including the development versions of Mandriva and openSUSE.

If your distro doesn't provide pre-packaged binaries, you can download and compile PulseAudio yourself. But for most users, getting started is a matter of installing the packages and setting up the configuration options in your audio apps.

The PulseAudio wiki page entitled The Perfect Setup offers basic step-by-step instructions, but you may want to seek out distro-specific guides if your distro supplies the packages. Ubuntu does not yet provide its own instructions, so on my Ubuntu Feisty box, I had the most success when following the Debian HOWTO posted at forum.debian.net.

I started by installing all of the PulseAudio-related packages available through Synaptic. There are separate packages for connecting PulseAudio to audio frameworks such as GStreamer, ALSA, and JACK. The most important one is pulseaudio-esound-compat; it replaces the ESD package esound entirely, creating a dummy /usr/bin/esd that is actually a symbolic link to PulseAudio. With this in place, all applications that expect ESD are fooled into using PulseAudio automatically.

An important caveat is that PulseAudio creates its own group, and all users that want to use PulseAudio must be a member of it. Since most desktop users don't spend much time thinking about groups or group permissions, this can be an easy step to overlook. Under Ubuntu, you change group membership by visiting System -> Administration -> Users and Groups. This launches the Users settings manager; you have to click on the Manage Groups button and bring up Properties window for the pulse, pulse-access, and pulse-rt groups separately in order to add yourself.

That done, I copied a sample /etc/asound.conf file from the Debian tutorial. This is an ALSA setup file, but it is not created for you because in most cases ALSA apps will run fine without it. But you need to create it in order to specify that ALSA apps should use PulseAudio as their default output.

Feel the beat

Using PulseAudio as a drop-in replacement for ESD, and setting up ALSA to use PulseAudio through /etc/asound.conf, will account for 90% of the audio needs of a regular desktop Linux session.

For the remaining apps -- including those oddballs that handle all audio internally -- the specific instructions at the PulseAudio wiki serve as an invaluable resource. For instance, most KDE apps use aRts, but you can set up aRts to use ESD, which is then rerouted automatically to PulseAudio. Amarok, XMMS, and some other media players let you choose a back-end engine from within their application preferences.

The only major holdouts at present are the audio editor Audacity and the video player MPlayer. Both require fetching development version code from their respective project pages. More importantly, because of the way Audacity controls the sound device, you must shut down PulseAudio before you use it. Changes are in the works, but have not made it to the stable code base yet.

Basic service is well and good, but PulseAudio earned a place in Linux distros' default audio stacks by doing considerably more. PulseAudio can route audio from multiple sources to multiple sinks, both locally and over the network. You can use it to combine multiple soundcards into a single virtual device, to forward music from one PC to another, or to share a single microphone as an input between multiple PCs.

The best place to start learning is at the PulseAudio wiki. The latter half of the FAQ page is devoted to specific examples showing how to take advantage of PulseAudio's advanced features. You specify most of the setup options in text configuration files, but you can test them out without a restart -- at most, relaunching the pulseaudio executable itself will allow you to try out your new configuration.

The project also recommends looking into Lennart Poettering's GUI tools. They include PulseAudio-specific volume control, volume meter, and device choosers much like the default tools from GNOME or KDE -- all of which can be accessed through a panel applet. There is also a more feature-filled PulseAudio Manager app, which allows you to connect and disconnect devices and modules on the fly.

There is no need to feel intimidated by all of the complexity built into PulseAudio. The project has done a good job of making the common tasks simple enough that they don't demand any expertise. But in traditional open source fashion, the power to do more is there, too, right in front of your ears.

Share    Print    Comments   

Comments

on Why you should care about PulseAudio (and how to start doing it)

Note: Comments are owned by the poster. We are not responsible for their content.

PulseAudio in Ubuntu? There are lies and then there are damned lies

Posted by: Anonymous [ip: 209.104.55.5] on November 02, 2007 06:20 PM
No one has said a word about PulseAudio in Ubuntu. Actually, there was a pretty long flamewar on the gnome desktop-devel mailinglist about why or why not Pulse should be part of gnome. It looks like it won't.

While Pulse is cool, it won't be in Ubuntu anytime soon.

#

Re: PulseAudio in Ubuntu? There are lies and then there are damned lies

Posted by: Nathan Willis on November 02, 2007 09:30 PM
The link speaks for itself.


Nate

#

Re: PulseAudio in Ubuntu? There are lies and then there are damned lies

Posted by: Anonymous [ip: 84.189.79.113] on January 03, 2008 09:32 PM

Why you should care about PulseAudio (and how to start doing it)

Posted by: Anonymous [ip: 58.110.215.183] on November 03, 2007 02:49 AM
i still have no idea what PulseAudio is...

#

Why you should care about PulseAudio (and how to start doing it)

Posted by: Anonymous [ip: 72.77.208.233] on November 03, 2007 02:56 AM
I don't know anything about the previous two comments but all I know so far is that this article is really badly written. After reading it and several of the links provided I still have no clue as to what advantage Pulse has to using what is already installed by default on my distro. Perhaps there are some compelling reasons for someone to switch over to using Pulse but the author failed to make a clear argument as to the benefits of Pulse in comparison to the already existing sound systems. Perhaps things are a little confused as he points out but all he has managed to do is to further muddy the waters. I am more confused than ever, please save me from such lame articles!!

#

Re: Why you should care about PulseAudio (and how to start doing it)

Posted by: Anonymous [ip: 65.92.102.247] on November 07, 2007 04:07 AM
I've been using PulseAudio for sound for the last few months, and I can tell you there are huge advantages to doing it this way. First of all, using PulseAudio basically eliminates the legendary "audio device busy" problems you frequently get when using sound in Linux, due to various audio daemons locking up ALSA for their own purposes. By assigning the PulseAudio ALSA plugin as the default ALSA source, you trick these programs into thinking they've got exclusive audio control when they don't, thus avoiding those problems. Secondly, PulseAudio, as mentioned, has an ESound compatibility mode that allows it to fool ESound programs into thinking it IS ESound. That means it integrates into GNOME rather well. Thirdly, aRts can be fooled into sending sound to PulseAudio as well, using the same ESound compatibility mode or even the ALSA mode. This leads to both GNOME and KDE programs feeding their sound into PulseAudio. Then GStreamer and Xine can be told to feed audio into PulseAudio, and any program with an ESound mode can be fooled into using PulseAudio. By setting up the system correct, you can get EVERYTHING to send audio to the PulseAudio daemon, which gives you a single point of audio control. PulseAudio handles merging the audio streams automatically, so you don't have to worry about your hardware having to deal with it, either. PulseAudio is also capable of using audio sources from over the network as if they were native (meaning you can send audio from one computer to another using it, like NAS).

#

PulseAudio and Gnome

Posted by: Anonymous [ip: 78.86.121.24] on November 03, 2007 08:53 AM
As long as pulse is tied so deeply into Gnome (its configuration apps even have GConf dependencies) I'll be staying well away.

#

Re: PulseAudio and Gnome

Posted by: Anonymous [ip: 87.9.176.194] on November 11, 2007 12:08 PM
The GConf module IS a module, and thus optional, as well as for the ESD compat layer. Pulseaudio isn't in any way tied to GNOME only apps. Let's try not to make it another KDE vs. GNOME holy war.

tchernobog.

#

I'm none the wiser.

Posted by: Anonymous [ip: 87.194.113.211] on November 03, 2007 06:09 PM
So why then should I care about PulseAudio? I still don't really know. How about some practical examples of this stuff as applied to the real world of media production? Can I ditch my Windows/Nuendo box and still get the job done on my Debian-KDE box?

#

Re: I'm none the wiser.

Posted by: Nathan Willis on November 03, 2007 11:25 PM
I that's really more of a question of the apps than of the subsystem. In any event, if you want a discussion on it, you might try asking in the <a href="http://www.linux.com/forums/">forums</a>; you're more likely to get responses there, particularly as this article moves off of the front page.



Nate

#

ALSA is still lower level than PulseAudio, right?

Posted by: Anonymous [ip: 130.243.141.205] on November 04, 2007 05:27 PM
My understanding from the article: multimedia apps can send their decoded streams to PulseAudio which in turn can redirect it to several destinations, such as remote computers via LAN or to the local sound card(s) via ALSAs kernel drivers. Apps need to be able to pick PulseAudio as a destination, but since some apps use ALSA directly (not aRts or ESD or some other middle layer), ALSA needs to be able to redirect those to PulseAudio if they should gain the same features (which could mean that they just bounce back to ALSA again if the user wants output on the local soundcard).

My experience is that ALSA and OSS are the lowest audio layers in that they actually do the talking to the hardware, and that they are mutually exclusive (although there is a OSS compatibility layer in ALSA so that apps programmed against OSS works with ALSA). Everything else such as JACK, ESD, PulseAudio and aRts provide "user environments" with different neat features, such as low latency or LAN transmission. Some of these features, such sending over LAN, are not new with PulseAudio but have mainly been restricted to individual apps before, e.g. vlc. PulseAudio aspires to provide the feature to a broad set of apps.

As far as I've heard one nice feature with PulseAudio is that it allows you to set the volume individually for each application that uses it, which I imagine can come in handy sometimes.

I hope though that PulseAudio does not mask which app is actually streaming audio to ALSA (such as aRts does), because that can potentially break the way my little remote control program ReMoot (reviewed at linux.com a little while ago) figures out which apps are playing and so on (it parses /proc/asound/timers and looks at the reported pids).

#

It looks a lot like Phonon....

Posted by: Anonymous [ip: 89.89.20.170] on November 05, 2007 12:40 PM
... which will be included in KDE4. Seems both project had the same great idea (or one copied on another, but let's stay naïve).
Well, if it is the case, here what on Phonon site "Actually Phonon is mostly a project that benefits application developers. But if all of KDE utilizes Phonon it is a benefit for the enduser:". Read the rest on http://phonon.kde.org/. So in the end, don't bother with PulseAudio unless you're a developper. In the end, what the user will see is sound working better on gnome, with improved stability.

#

Re: It looks a lot like Phonon....

Posted by: Anonymous [ip: 65.92.102.247] on November 07, 2007 04:10 AM
Uh, Phonon is simply a sound frontend to whatever system the user wants to use. The KDE designers decided to get away from requiring a specific audio system after aRts stagnated. Ultimately, Phonon will have different backends written for it, and I'd bet on one for PulseAudio.

#

The best way to solve the linux audio mess

Posted by: Anonymous [ip: 89.205.184.140] on November 05, 2007 12:59 PM
Is to add another server/api/daemon?

Yeah right, that will make everything much simpler. /sarcasm

#

<a href="http://www.javasigns.com/decals">window graphics</a>

Posted by: Anonymous [ip: 72.236.163.214] on January 25, 2008 04:45 PM
Agreed. This is all turning into a tangled mess...The "too many chefs in the kitchen" problem.

#

Why you should care about PulseAudio (and how to start doing it)

Posted by: Anonymous [ip: 99.239.253.14] on November 05, 2007 05:06 PM
HI. Planning to get Fedora 8 later this week. Looking forward to using this PulseAudio. Do you know if it will allow me to hear the benefits of my new Mother Asus M2A-VM mother board's Realtek high definition audio on board sound? Thanks, Charles

#

Included in Ubuntu? Not.

Posted by: Anonymous [ip: 201.244.226.174] on November 05, 2007 08:36 PM
Please read the actual bluprint proposal in launchpad.net. The little link in the first line you give as supporting evidence that Ubuntu will have PulseAudio included in the next release. The proposal has been around for year-and-a-half (UDS Boston was last week) and it is still up in the air. In fact. it wasn't discussed in Boston meetings at all. Link to the real proposal: https://blueprints.launchpad.net/ubuntu/+spec/cleanup-audio-jumble and the link to the UDS Boston agenda: https://blueprints.launchpad.net/sprints/uds-boston-2007

#

Why you should care about PulseAudio (and how to start doing it)

Posted by: Anonymous [ip: 59.100.12.225] on November 06, 2007 04:35 AM
Why should users look forward to PulseAudio? There was nothing in the article that made me remotely interested in it. Audio is already working fine on my system.

#

The Simple Sound Stack

Posted by: Anonymous [ip: 68.160.60.172] on November 06, 2007 04:37 AM
From what I can gather as a Linux newbie from using this article and Wikipedia a simple sound stack would be as follows:

Audio Application
|
Legacy KDE/aRts or GNOME/ESD sound server/daemon (w/Pulse Audio sound server now replacing ESD in GNOME); Jack an optional sound server for KDE/GNOME
|
legacy OSS driver/kernal module and new ALSA driver/kernal module
|
hardware (sound card, etc.)

#

Why you should care about PulseAudio (and how to start doing it)

Posted by: Anonymous [ip: 71.72.44.3] on December 24, 2007 07:15 PM
I think any step towards a stable audio environment is a good thing and it sounds like PulseAudio will help in that way. I have struggled with using Linux (Ubuntu presently) for audio recording and editing for a long time, and although there is still lot's of problems, it has come a long way. I say keep up the good work and let the market of ideas pick the best Linux sound system.

#

This story has been archived. Comments can no longer be posted.


 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya