streaming to Airtunes (Airport Express) with PulseAudio

So, being back in Australia, the sun is shining, I'm sat on my sofa and I can't help but feel like I'm on summer holidays. So I want to crank some Uh Huh Her on the stereo.

We have an Airport Express, but using would normally require using Steph's computer, or the computer downstairs. So instead I thought I'd give the support in PulseAudio a go.

It's pretty easy to set up. Install the (Debian/Ubuntu) packages paprefs pavucontrol pulseaudio-module-raop pulseaudio-module-zeroconf (Fedora packages might have different names). Run paprefs and tick the option to discover Airtunes devices.

Then using pavucontrol you can set the output device for an application.

It's not perfect yet, it can sometimes get stuck skipping, and you have to move the stream to your local computer and back to the Airport (apparently the buffering is just implemented using windowing, but maybe needs to be smarter?), but it's working pretty good. Still, it's insanely neat, and because it's in PulseAudio, you can redirect any stream you like (not just from your music player).

It's not just Airtunes either. You can stream to other PulseAudio servers (discovered over mDNS) as well as UPnP media renderers.

Upgrading to Ubuntu Karmic

Upgraded to Ubuntu Karmic pre-release today on my Thinkpad X200s. Had two issues:

  1. machine wouldn't prompt for the key to unencrypt the hard disk so it didn't boot. This seems to be Launchpad bug 446591. I followed this fix.
  2. forgot that I had downgraded my Intel graphics driver to v2.4, causing my consoles to break, suspend to RAM to break and only support a broken version of EXA. apt-get install xserver-xorg-video-intel fixed this.

Things seem much better now than the mess I had this morning.

improving your code by fixing warnings

I don't know why, but there is a class of software programmer who seem to believe that compiler and runtime warnings are somehow optional, or something that can be cleaned up at a later date. This class of programmer is very common in the commercial software world.

I've never really been sure why people think these warnings can be ignored. Compilers are pretty smart these days, and if a the compiler says you have a type-mismatch for your pointer assignment… there's a good chance you did something silly.

Library developers don't just add all of those pesky assertions to their methods for fun. If your code is outputting critical warnings, you probably shouldn't be surprised that it's crashing shortly afterwards. Something clearly went wrong.

So what can you do? Compiling your code with warnings-as-errors when developing it is a very good step (-Werror in gcc). For runtime warnings, you can probably set an environment variable to make the program abort when reached (e.g. for GLib you can export G_DEBUG=fatal-warnings or fatal-criticals) — this allows you to attach a debugger when the warning is reached.

Simple steps for much better code.

and now for something from the school of pure evil (setting a background on a GtkTextView)

This is something that comes up from time to time, someone wants to set some attractive background on a GtkTextView. Well, unfortunately for you, the theme engine isn't able to help you here because GtkTextView never calls gtk_paint_box() or friends. Still, today I stared at the code for a bit and came up with a particularly hacky solution: see for yourself. You have to handle everything yourself, resizing (hook into size-allocate), scaling whatever is needed. You could probably cheat though and call something like gtk_paint_box() and then let the theme engine do that bit of the work for you… I've not tried.

Just to prove it works:

This depends on what is basically an implementation detail of the widget, and I make no promises that it will continue working in the future. With that warning in mind, do what you will with the code.

P.S. the background image is a photo of the art in my hotel room. If I was Google, I'd totally sue.