Selecting Airplay Speakers in OS X Has No Effect

It appears to have started occurring after I upgraded to Mavericks (OS X 10.9), though I can’t confirm this for sure. When I select an airplay output device from my Macbook Air nothing happens.

TLDR;

If you have this problem restart the music service for your mac with the following command:

sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'`

THE DETAILS

If I hold the option key and click on the speaker icon in the menu bar, I see the Airplay devices available on my network and am able to select them:

However, after selecting a device the audio will continue to play from my Macbook Air, and if I re-open the menu under ‘Output Device:’ my ‘Internal Speakers’ are still selected.

Looking for a solution to this problem I came across this forum thread which suggested the following command, which I break down below:

##### Full Command #####
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'`
 
##### Breaking down the command #####
# Lists the running processes on your computer
ps -ax                                   
# Finds the line for the core audio process in the process list
ps -ax | grep 'coreaudiod'       
# Avoids the problem where the grep process also shows up in the ps results        
ps -ax | grep 'coreaudiod' | grep 'sbin' 
# Pulls out the Process ID for the core audio process
ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}' 
# Uses the Process ID of the core audio process to kill it (it will auto-restart)
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'`

This command has been a life saver for me, though I’m still not sure why Apple’s core audio service would be so brittle to get into the bad state necessitating this command so frequently.

Tagged , , , , ,