I've spent a lot of time reading posts about how to stream to an Airport Express using VLC; this is fairly straightforward if you want to stream an audio file that VLC is itself playing, but it's a little less straightforward if you want to stream the computer's own audio. However, it turns out to be fairly easy, with the only catch being that you need to install a later version of VLC (at least 1.2, I believe) than normally installs on Ubuntu 11.10. I used a nightly (you can get it here: http://nightlies.videolan.org/). This is because the ability to stream directly from Pulseaudio (using pulse://) is new to VLC. Then you have to find the monitor of your currently active sound sink (you may have to activate the monitor under "Input Devices -> Monitors" using "pavucontrol"). I found the name of the monitor by running "pacmd list-sources" in a terminal and using the "name" of the appropriate monitor. In my case, this was "alsa_output.pci-0000_00_1b.0.analog-stereo.monitor". If I then type this into a terminal:
Code: Select all
vlc pulse://alsa_output.pci-0000_00_1b.0.analog-stereo.monitor :sout='#transcode{acodec=alac,channels=2,samplerate=44100}:raop{host=<ip address of Airport Express>,volume=175}'
There is a significant delay between the computer audio and the Airport Express, so you have to turn your computer speakers' volume down if you can hear the AE output from where the computer is, or you'll find the result pretty annoying.
To manage this delay issue (if it bothers you), I wrote a simple script (below) to divert all of my computer's audio to the null sink and then stream its monitor via VLC to the AE and simultaneously to my analog sink with an appropriate delay. This way, all of the audio comes via VLC, which can adjust for the delay so that the AE and my computer's sound are in sync (and both somewhat delayed from when the computer actually generated them). I had to add "load-module module-null-sink" to the end of /etc/pulse/default.pa to make this work, then killall pulseaudio (or restart the computer). Make sure to substitute the ip address of your Airport Express in the vlc line below:
Code: Select all
#default.pa loaded the null sink as sink 1; the analog (default) sink is sink 0. Set null as the default, so that all new audio gets routed to it.
pacmd set-default-sink 1
#Set SPS to a list of all of of the currently playing audio inputs (e.g., browser, Banshee)
SPS=$(pacmd list-sink-inputs | grep index | sed -e s/index://)
#Move each input to the null sink.
for d in $SPS; do
pacmd move-sink-input $d 1
done
#Sleep a little to let this all take effect
sleep 3
#Start VLC monitoring the null sink, streaming to the AE, and playing via the analog sink with a 4.2-second delay.
vlc --qt-start-minimized --aout alsa --alsa-audio-device front pulse://null.monitor :sout='#duplicate{dst="transcode{acodec=alac,channels=2,samplerate=44100}:raop{host=<ip address of Airport Express>,volume=175}",dst=display{delay=4200}}'
#Once VLC is closed by the user (doesn't want to stream to AE anymore), set default sink back to 0 (analog, in my case)
pacmd set-default-sink 0
#Assign the current sink inputs to SPS again
SPS=$(pacmd list-sink-inputs | grep index | sed -e s/index://)
#Move the sink inputs back to the analog sink
for d in $SPS; do
pacmd move-sink-input $d 0
done