Upgrades and on-the-fly network audio redirection using PulseAudio
It's been a productive bout of geekery (thus the silence). As part of a project I needed to upgrade all the boxes in the home to Fedora 10, that is 5 boxes running various incarnations of Core from version 6 to 9 on both mundane and fairly exotic hardware and with complex and often custom installations. Instead of grabbing the latest DVD as torrent I tried the preupgrade package on all the version 7 and ups with mixed but generally good results. The idea behind preupgrade is pretty cool, you run it, it grabs and does everything it needs to upgrade your system in the background while you carry on using the system, then asks for a reboot and finishes up. This worked pretty well on the version 9 boxes, beyond expectation even. The v7 and v8 had some quirks and I ended up formatting them and starting from scratch. All in all it was fun to do, something I don't usually associate with OS upgrades.
Fedora 10 is pretty sweet overall even though I immediately turn off everything that I think wastes CPU cycles and run fluxbox instead of KDE. One of the reasons for this upgrade-fest (besides 5 boxes running different versions being a pain in the ass) was the latest incarnation of pulseaudio, a very clever network/zeroconf-capable audioserver. It's been officially adopted by Fedora and Ubuntu so it makes sense to learn a little more about it, and it does have a lot of nifty features. Once you've set it up correctly the servers use zeroconf/avahi to learn about other sound servers on remote machines and with the correct configuration (the howto and faq help) make them available as local sound cards. Applications output streams, you can redirect these streams on the fly (or output to multiple targets). Two mouse clicks, or some trivial scripting. That is simply awesome.
I've talked about making your machines aware of what room you are in using bluetooth proximity before, and now I could move on to phase two - redirecting audio streams to whatever room you happen to be in. The computers which didn't have bluetooth built in already were outfitted with a 10$ bluetooth USB stick, blueproximity was modified to report to a central location, and I wrote a little script to look at all these bluetooth signal strength readings, decide which room I was in and redirect the audio stream to the relevant sound card.
This works surprisingly well. I'm wondering if using a bluetooth bracelet such as this one would also work for presence detection. I'm also going to seriously look into X10 or similar to extend this budding system to light switching, room heating and so on. It would also require a more advanced scripting/recipe/agent kind of thing to control it all, something like Narval although I haven't seen a lot of movement in that project lately.
For now, I have the music played from my main Amarok installation follow me around the house, and that is freaking sweet.
Update: I've found a script which adds resume play capability to mplayer. Pretty damn cool, and just what I needed both to make mplayer's behavior fit better with mythtv and for my redirection scripts, which I adjusted to check whether mplayer or amarok is running on the machine I am moving away from and suspend play there. If it then detects me near a different machine it will resume play. Note to self: add fix to fade out volume on suspend and fade in on resume.

4 reacties:
I always wondered if Bluetooth proximity worked reliably.
It's nice to know there's an open source alternative to the iTunes multi-point audio streaming. Though I will add that it works really well and I can use my phone to turn sets of speakers on and off.
Congrats on all the upgrading geekery. I keep meaning to give UbuntuStudio another chance too and just haven't had the time.
With 5 sample points in 4 rooms you can do a lot :)
That said, different bluetooth devices have different capabilities. Many return signal strength as a raw number, and good luck with it. This number varies a lot, I found one which returns 0-10, another 0-255, 0-127 and so on.
But once hardware quirks have been taken into account it all works smoothly.
After toying with this soundserver for a week and the wonder of instantly redirecting any audio stream from any application anywhere I now want the same for the applications themselves - I want the video I'm watching to follow me downstairs. I want that web page I'm reading to follow me around. Conditionally, of course.
In short, I want my disparate machines to become a whole, a many-headed beast to do my bidding and what is more, to anticipate me :)
Did you mean narf! instead of :)
Hey, if it leads naturally to taking over the world, Pinky, then that is the way it has to be.
Post a Comment