How to fix disabled audio in OS X 10.10 Yosemite [Update]
Apple launched, almost a week ago, the second public beta build of OX 10.10 Yosemite, which, among other improvements, includes a healthy dose of bug fixes. But, for some reason, the company has not yet addressed a glaring sound problem, where the audio stops working until a restart is performed. It is likely this occurs in the developer-only builds too. (It looks like this may even happen with the stable -- final -- version of the operating system.)
I am not alone in experiencing this problem, as I have seen other OS X 10.10 Yosemite users reporting the same issue with the built-in audio. In my case, after some testing, it appears that this issue occurs after my 2013 MacBook Air wakes up the built-in and external displays from sleep. (The sound also appears to have been disabled even after a clean install of the stable release; check the information pertaining to it at the end of the story for another solution.)
After the displays are on again, the audio control in the menu bar is grayed out. That also implies that the sound level cannot be adjusted, so there is no apparent easy way to recover from this bug. As I mentioned previously, a restart gets the job done, but this is a process I -- and, I presume, everyone else who shares my grief -- would rather avoid doing a dozen times or so per day.
After looking into the issue, I found a number of terminal commands which were said to bring back the disabled audio, without having to restart the Mac. Of those, only one worked, namely "sudo killall coreaudiod" (of course, without the quotes).
You can type this in a Terminal window (Terminal is found in Other in Launchpad). The command is validated with your user password, which you will have to enter after triggering the command. Afterwards, the audio will work again. This is not a permanent fix, as you will have to use the aforementioned command every time after the audio stops working. Still, it is a much, much more convenient solution than frequently restarting your Mac.
What If I'm Running the Stable Version?
In case your Mac is running the final version, you should also check which device is used by default for audio playback. In my case, my external display was set to play audio by default through its built-in speakers (it uses an HDMI connection with a Thunderbolt adapter to connect to my Mac), and since they were disabled there was no sound. So, open System Preferences, go to the Sound menu and then look in the Output tab to see which device is used for output.
It should normally be the internal speakers (Internal Speakers in the list) which are selected. If you have headphones or external speakers plugged in, OS X 10.10 Yosemite may list them as headphones (Headphones in the list). You should select either Internal Speakers or Headphones to get your audio working again.