A collection of articles, ideas, and rambling from a guy who wrote some software that one time.

Saturday, September 20, 2008

The Ultimate Ubuntu / PulseAudio Guide

After writing about how great Hardy was, I suddenly started experiencing mysterious crashes of various applications on my desktop.  That'll teach me to say anything nice about an operating system!  Firefox, Pidgin, Deskbar, and even the Gnome Panel would periodically freeze up.  It seemed particularly exacerbated by running applications in the Flash and AIR runtimes — which was pretty bad news, since I am supposed to be writing some code in Flex!

Eventually, I caught one of these programs in the act, and traced the buggy behavior down to the PulseAudio daemon.

Apparently this is a common problem, with a bewildering array of elaborate and perplexing "solutions".  I spent hours trying to figure out some kind of combination of ALSA and Pulse tools that would get me out of the increasingly crashy situation on my desktop.  Oddly, nobody mentions the most obvious solution:

"Turn it off."

While I can appreciate the benefits that Pulse will (eventually) bring, it seems that it doesn't actually do anything for me today.  The main idea is that Pulse will allow me to play and record multiple sounds simultaneously.  However, the out-of-the-box Ubuntu ALSA experience allows me to do this with my current sound card.  I don't pretend to understand why — maybe my card supports multiple channels, maybe things are using dmix somehow — but there is no problem to solve.  Running the pulseaudio daemon actually has the opposite effect: sounds from multiple programs stop working.

I wanted to remove the pulseaudio package, but it turns out that would remove the ubuntu-desktop package as well, which means everything will probably be broken (certainly when I do my next major upgrade).  So, here's an alternate and non-obvious way to turn it off, without any fancy configuration:
  1. Go to the "System → Preferences → Sound" in your menu.
    http://www.twistedmatrix.com/users/glyph/images/content/blogowebs/sound-menu-item.png
  2. Make sure none of the devices say "Pulse Audio"; they should all say "Autodetect", "ALSA", or something more specific.
    http://www.twistedmatrix.com/users/glyph/images/content/blogowebs/nothing-says-pulse.png
  3. Click on the "Sounds" tab, and make sure that the "Enable software sound mixing (ESD)" checkbox is un-checked:
    http://www.twistedmatrix.com/users/glyph/images/content/blogowebs/quote-esd-unquote-disabled.png
  4. Log out, and let it trouble you no more.
I got a little chuckle out of discovering the "ESD" footnote, but it turns out that really means "PulseAudio" these days.

Better luck next time to the Ubuntu audio team!  I look forward to using all these cool pulseaudio gadgets next time.  I hope skype, flash, air, and the dozen other proprietary-and-wrong audio apps out there get fixed before Intrepid hits the shelves.

9 comments:

A.M. Kuchling said...

Linux Weekly News had a recent conference report about Linux audio. The comments have a good discussion of PulseAudio and of problems with Flash; apparently Hardy is simply broken in this respect, but other distributions have it working.

Mary said...

The LPC reort certainly doesn't sound like the underlying problems will be fixed by Intrepid though.

glyph said...

Hello amk! Pleased to see you're reading my blag.

Hi, Mary. No, that report doesn't sound too good. Accurate though, especially in title: "it's a mess".

I omitted a lot of things I learned in about 9 hours of bashing my head against the wall in this post, but let me suffice it to say:

1. Hardy's configuration is definitely broken by default, and is missing some crucial features you need to try to make things work. However, if it were "correct" in the way that other distributions are, a different set of functionality would be broken. The way Redhat gets flash to work (although this is possibly a good idea) is to isolate browser plugins in a separate process and expecting it to crash all the time, not fixing it so it doesn't crash. Granted, this is probably a good idea, since flash is a pretty buggy piece of shit. Hopefully Firefox will start doing the isolating-tabs thing at some point too. You can find lots of Redhat users complaining about Skype, though.

2. PulseAudio is also buggy as hell, and can lock up hard when presented with a busy audio device (although this might be the result of bugs in ALSA, other programs don't do that)

3. Whatever client software most GTK applications use to talk to pulse (gstreamer, I think?) is alsobuggy, in that it does its I/O wrong.

4. The 'pulse' ALSA plugin is an unconvincing emulation of an audio device. Lots of software that works fine under dmix, USB sound cards, soundblasters and intel cards doesn't work with the pulse plugin.

5. All proprietary software is broken. Flash, skype, xten, sjphone, AIR, and RealPlayer (just to name a few) have an interlocking and mutually exclusive set of bugs, different bugs when interacting with each of the different sound layers.

And don't even get me started about mplayer.

grege said...

The best way to avoid Firefox crashing with flash is to install Seamonkey and use that instead. Opera works well too if you don't mind commercial software.

Cory said...

Grumble mumble.

Your post led me down a rabbit hole, I'm afraid. Turning it off turns out not to work. The magical faeries you have that allow mixing apparently do not live in this MBP.

However, you did then lead me down the correct primrose path - one of your bewildering links, specifically this one, actually contained the correct solution. (Which turns out to be: trust some random guy on the Internet to help you install flash 10.)

I still have to kill pandora to use skype, but this is the solution that minimizes the value of FUCK for me.

glyph said...

cory, sorry.

I have some other stuff you can try with dmix, dsnoop, and ALSA to get it to work; but that only works on a small subset of sound cards I've tried.

(The basic problem here is that the kernel sound drivers are buggy and inconsistent as shit, so no solution works for everyone. While I think the pulseaudio guys, and the ubuntu guys, could have done a lot better, I have some sympathy for them: they're building on top of a very shaky foundation.)

Ivanov said...

Hi all :)
I am new to linux, but I have pulseaudio problem, too. I am using Ubuntu and I had setted the sound server to PulseAudio. Everything was fine for few days and today my sound just disappear (no sound in Totem, Rhytmbox, only in Skype). I changed the sound server back to auto and I have sound again. When try to test PulseAudio I received this error: audiotestsrc wave=sine freq=512 ! audioconvert ! audioresample ! gconfaudiosink profile=music: Failed to connect: Connection refused

Uriah said...

I'm a little late to this party but I have been fighting sound problems in Hardy for more than a month.

With a 5.1 Creative sound card/Logitech speaker system I am getting stereo out of front & back speakers when it works. I am currently trying to remove some "gurgling" sounds that interfere with my music.

I am getting sick of fighting Ubuntu for every configuration setting!

Just venting my gripe! Thankls for the info!
Uriah

Anthony Hildoer said...

I automated the process of installing flash 32bit and 64bit in Ubuntu Desktop. It even works with pulseaudio. It works in feisty, gutsy, hardy, and intrepid.

Automated Flash Install:
http://www.hildoersystems.com/index.php?option=com_content&view=article&id=76:automated-install-of-flash-10-for-ubuntu-desktop-32bit-and-64bit&catid=39:multimedia&Itemid=59