PulseAudio

!PulseAudio is a next generation sound server for Linux, making all sorts of "ear-candy" possible: from dynamically changing the volume of individual applications to hot-plugging support for many different devices. Fedora 8 is going to be the first distribution to ship and enable !PulseAudio by default and with this in mind we talked to LennartPoettering who is the upstream and Fedora developer of !PulseAudio and Avahi about the work he has put into this.

Digg it!

If you enjoy this article, consider giving it a digg :D

http://digg.com/linux_unix/PulseAudio_by_default_in_Fedora_8

Screenshot: PulseAudio volume control showing multiple applications with different volumes

Screencast And New Features

Developer Interview

Lennart Poettering

Location: Hamburg, Germany

Profession: Software Engineer

Age: 27

IRC Nick: mezcalero

Interviewed by: JonathanRoberts



If you could start by telling us about the problems that existed with Fedora's previous audio implementation?

As long as you only play MP3 music or movies everything is fine with the traditional Linux audio architecture. However, if you want to do anything beyond that, the classic Linux audio architecture is too simple. In comparison to what MacOS X or Windows Vista offer plain ALSA is more like a 90's audio system -- although from a technical standpoint the Linux kernel and the ALSA could offer a lot more for implementing a userspace sound system. The Linux kernel is quite useful as a real-time kernel nowadays, and since the Free Software community controls the whole audio stack from kernel through drivers to userspace we can offer a much better system. And thus we now have !PulseAudio.

See the next question for a few examples of things you cannot with classic ALSA-only Linux audio system, but which you can do by using !PulseAudio.

And if you could expand to explain how Pulse Audio differs and what benefits this will have for end-users? Or even for developers of existing applications too, such as Audacity/Jokosher/Rhythmbox/$general_audio_application.

A lot of things have changed. For example, you can now change the volume of every playback stream seperately. Then, we have better hotplug support: Just plug in your USB speaker and it will appear in your mixer (as long as you use pavucontrol, of course, PA's native mixer tool; the classic gnome-volume-control which we still ship is not hotplug-capable). You can move streams during playback between output devices. With a single click in our "paprefs" tool you can aggregate all local audio devices into a virtual one, which distributes audio to all outputs, and deals with the small frequency deviations in the sound card's quartzes -- and that code even deals with hotplugging/unplugging. If that checkbox is checked, just plugin in your USB headset and you get audio through it. (This is actually pretty cool, and it might be something we enable by default in F9)

How has the work on this gone so far, with respect to getting your changes into Fedora 8?

Pretty well I think. All important bugs (I think) are fixed. Fedora is a very friendly community I guess and most changes went through without too much discussion. I am happy!

Any significant obstacles you've faced? I see from the feature's wiki page that you had to get some patches incorporated up-stream in a number of different packages?

The balkanization we have in Linux audio was the biggest obstacle in itself. Before we could think of moving everything to a new audio system we had to make sure that we have compatibility support with all that software that is out there right now (or at least the majority of it). There are so many audio systems and APIs around, some being very hard to virtualize, so this was a major amount of work. But I guess we tackled most now, and even have special support for closed source software like Adobe Flash.

Any future goals in mind with respect to Fedora's sound systems, things you'd like to see implemented post Fedora 8?

Now that most of the groundwork is laid, I am thinking of adding more "earcandy" stuff (i.e. "planet-gnome-worthy") to PA. One of the things !PulseAudio is supposed to be is a "Compiz for sound". Three items are on the top of my list:

- Spatial event sounds: click on a button on the left side of your screen, and the event sound comes out of your left speaker. Click on one on the right side of your screen, and the event sound comes of of the right speaker. It's earcandy, but I think this could actually be quite useful, but only if we get better quality event sounds, than we have right now.

- If you run two Totems side-by-side, the one that is active should have 100% volume, the other one 20%. And if you change focus with your window manager, the two volumes should slide to the inverse. I think this would be very, very useful. Especially for things like Flash: if a flash video is running in your web browser, the system should automatically slide down the volume of everything else and slide it up again when the Flash clip finished to play.

- For playback streams where we know the average volume a priori (e.g. event sounds) it might make sense to scale the volume in relation to the average volume of what else is being played. The idea is that right now it is sometimes very annoying if an event sound like "You got an IM" interrupts your move playback with a volume that is a lot louder than the audio track of the movie.

On the technical side, beyond earcandy I plan to change the ALSA-based playback core to schedule audio not based on IO-IRQs from the sound card, but instead on system timers. With the recent kernel work regarding hrtimers and stuff like this, this finally becomes feasible. The big advantage is that we can change the latency parameters and wakeup points dynamically during playback without discontinuities in sound. This will allow us to flexible adjust the frequency of interrupts to what is required by the connected applications, which will save power in the general case but also allow lower latencies (reaction time) for applications that need it. So basically, very soon now PA will play a part in increasing your battery lifetime when you play music!

Lot's of stuff is coming. My TODO list is huge. We'll see how much I'll be able to push into Fedora by time of F9.

And finally, if you could tell us a little bit about yourself: how you got involved in free software? Things you love to do when not hacking!?

I got involved in Free Software back when I installed Slackware in Kernel 1.x times on my 486, where I totally didn't get it. Some classmate of mine talked about that Linux thing that supposedly was free of charge, and I installed it, and it didn't work for me at all. I quickly removed it from my hard drive, but I guess in a way I was already hooked. So a year or two later later I bought Red Hat Linux 5.1, together with a friend, to give it another try. That was 1998. Very quickly I moved to Debian, though, and used it for almost 8 years, and never used anything else again.

Oh, and in real life I am into photography, love to sort my music collection, and go skiing.