Redirecting audio output over a network with Inferno

We are inaugurating a new NineTimes section for small tips and tricks.

The first one explains how to export all audio output from a Linux box over the network using Inferno to any other system that can run Inferno (or to native Plan 9) without having to mess around with pulseaudio or any other such beast.

The difficult bit is figuring out how to get ALSA to output all audio to a fifo, you will need to have this in your /etc/asound.conf (note that many lunix systems don’t include that file by default so you might need to create it):

pcm.!default {
    type file               # File PCM
    slave.pcm "hw:0,0"      # This should match the playback device at /proc/asound/devices
    file /tmp/audio         # Output filename
    format raw              # File format ("raw" or "wav")
    perm 0666               # Output file permission (octal, def. 0600)
}

The slave.pcm is the most mysterious and magic part, hw:0,0 should work in most cases, but if for example you have an entry like: 48: [ 1- 0]: digital audio playback you should use “hw:1,0”.

Once you have alsa setup properly do: mkfifo /tmp/audio; chmod 666 /tmp/audio

And you are done messing with Linux and can move on to the real easy part, start Inferno’s emu: emu ; bind ‘#U*/’ /n/local/ ; listen -A tcp!YOUR.LINUX_BOX.IP.ADDRESS!9999 {export /n/local/tmp/}

Now go to your windows or OS X box start Inferno there and run (tried this in acme-sac, which has a reasonable default setup, if you are using inferno-os you might need to mount your ‘#A’ device to /dev): ; echo rate 44100 > /dev/audioctl ; mount -A tcp!YOUR.LINUX_BOX.IP.ADDRESS!9999 /n/lunix ; while {sleep 1} { cat /n/lunix/audio > /dev/audio }

And you are done, after this all audio you play on your linux box should be heard on your other box. How to listen from Plan 9, do proper auth, and how to reverse the setup so you export the audio device rather than the fifo are left as exercises for the reader.

Thanks to hiro for that inspired this trick (he was doing the same but with only the output of mpd), and thanks to the folks in the #alsa irc channel that helped me decipher the incomprehensible ALSA docs.


To post a comment you need to login first.