I like to watch video on one laptop, while speakers are connected to the other; I don’t like the cable hanging in midair between the tables, begging to be pulled by someone when passing. I used to solve this by NAS, the Network Audio Server, an ancient, but still usable project that allows you to send audio through network and play from one computer to another. The problem is that I couldn’t lately get it to work. I’ve solved this yesterday, so here you go, back to the tradition of blogging my tech notes.
- problem: nasd (the NAS daemon) would interfere with other applications, or other applications with nasd
- symptoms: nasd won’t play, or Firefox won’t play, or music won’t play
- how to discover: applications complain about /dev/dsp being busy
- cause: nasd uses OSS, the deprecated “open sound system”, instead of ALSA, and OSS drivers often don’t allow applications to share sound output
- solution: make NAS (and other applications, too) use alsa by using aoss wrapper
sudo apt-get install alsa-oss
sudo gedit /usr/bin/start-nas
nice -n -10 /usr/bin/nasd -b "$@"
nice -n -10 aoss /usr/bin/nasd -b "$@"
As for Firefox, follow these short instructions.
What happens now is, that the aoss wrapper hijacks calls to /dev/dsp made by NAS and handles them by using Alsa. The main interesting difference between OSS and ALSA is that in most OSS drivers, the sound output /dev/dsp cannot be shared among applications. For instance, having Firefox open might mean that Flash application is keeping the sound device open, even though it isn’t playing anything at the moment. And keeping /dev/dsp open means that no other application is allowed to play sound.
So far, I’ve watched one video using this setup, and the audio wasn’t perfect; I could hear clicks quite often. But I’m fine with that. If it annoys me, I’ll consider switching over to Pulse Audio.
I’ve switched to PulseAudio a couple weeks ago and I have to say it’s the best audio system I’ve ever used. The only strange thing I had to do was installing a library for Flash Player 9 that would make it able to use Pulse Audio. I have two computers transparently using a single set of speakers. Best setup ever.