The purpose of this brief note is to explain how BitPerfect attempts to interface with AirPlay, and describes some of the currently intractable problems that it encounters along the way.
When AirPlay was first introduced in 2004 it was called AirTunes, but was changed to AirPlay in 2010 with the introduction of the AppleTV and the expansion of the service to include video transmission. AirPlay was (and still is) a proprietary Apple protocol. Third-party licensing to use AirPlay is available through Apple, but only in a rigidly controlled manner and for a narrowly-specified range of applications and implementations. This licensing does not provide for companies such as BitPerfect to be able to access the AirPlay subsystem directly. Instead, with the introduction of OS/X Mountain Lion, Apple has included an ‘exposed standard audio device’ as a means for third-party Apps (such as BitPerfect) to access the AirPlay subsystem. An alternative approach is to use an illegal hack to access the AirPlay subsystem directly (AirPlay was comprehensively hacked within weeks of its 2004 introduction), but that is not an approach which interests BitPerfect.
Apple’s decision to use OS/X’s ‘Standard Audio Interface’ as a portal for third-party Apps is a pig in a poke. On the face of it, it is the ideal approach. Any third-party App which can direct audio to an audio output device can now use the exact same interface to direct audio through AirPlay with no additional special software extensions needed. But lurking below the surface are some fundamental incompatibilities between AirPlay and the Standard Audio Interface.
You see, AirPlay has some features and capabilities which the Standard Audio Interface is not designed or equipped to handle. The most important of these is that AirPlay is an entire subsystem and not a simple audio device. There can be many different actual devices in an AirPlay system. Each of these devices can have different capabilities and parameters. In my setup, for example, I have an AirPort Express, an AppleTV, and my Classé CP-800 Preamplifier is also an AirPlay receiver. The Standard Audio Interface was never designed to handle an audio device with multiple actual output devices. It can never know which one is actually in use, it can never select which one it wants to use, and it can never know if the one actually in use is being changed by someone else (such as by another App) to another one with different capabilities and parameters.
When BitPerfect is trying to play audio through AirPlay, it therefore knows none of these things. All BitPerfect knows is that you have selected ‘AirPlay’ as its audio output device. It relies on you taking steps elsewhere to tell AirPlay which of the available AirPlay devices you want it to use. With each new release of OS/X and iTunes, there are more ways in which the OS and iTunes can affect the AirPlay subsystem, and more and more devices on your home network which can also step in with their 5¢ worth. BitPerfect has no way of knowing if any of this is happening, and even if it did, it would have no way of doing anything about it. This is the same for all third-party Apps who wish to access the AirPlay subsystem without hacking their way in.
Furthermore, BitPerfect works by ‘hogging’ its designated audio output device. This means it takes exclusive control over it, thereby making sure no other App tries to use the device at the same time for some other purpose (for example, to announce “you got mail!”). Because it is hogging the audio output device, it makes the assumption that nothing is going to try to reconfigure it in the middle of playback (or be able to, if it did try). Being able to make this assumption safely is a key element in simplifying BitPerfect’s audio output chain, with a significant payback in terms of sound quality. With AirPlay, all it can hog is AirPlay’s Standard Audio Interface.
With all other audio devices, the Standard Audio Interface is the only door through which the audio device can be accessed at all. If, for example, BitPerfect ‘hogs’ the built-in output, then even OS/X itself cannot access that device, and as far as OS/X is concerned that device is no longer present in the system. But with AirPlay, only third-party Apps access AirPlay through its Standard Audio Interface. OS/X, iTunes, and other AirPlay-enabled Apple software can access the AirPlay subsystem directly, at a privileged level behind the Standard Audio Interface.
So if BitPerfect ‘hogs’ the AirPlay device, all it is doing is hogging AirPlay’s Standard Audio Interface. It is not stopping OS/X, iTunes, or other AirPlay-enabled Apple Apps from doing whatever it likes with the AirPlay subsystem - things that can cause problems of varying degrees for BitPerfect. Therefore, if BitPerfect tries playing through the AirPlay device, it is entirely possible that it will fail, and it may not be immediately or consistently obvious what the problem is. This is the reason why our User Manual includes a list of procedures that you have to go through to get AirPlay working under BitPerfect. This list is only ever a best guess, is based on trial and error rather than hard logic, and is not guaranteed to work.
Things apparently continue to evolve with each update to OS/X and iTunes. Running OS X 10.9 (Mavericks), if I go through the process of quitting both BitPerfect and iTunes, then relaunch both, and go through the process described in the BitPerfect User Manual for setting up AirPlay, what happens is that sometimes AirPlay works fine and sometimes it does not. When it does not, the symptoms fall into roughly five groups, and I have no intention of attempting to explain or describe them here. These symptoms include occasional unexpected error messages popping up on screen regarding the status of the chosen AirPlay device, unusual messages from CoreAudio in the console log, and failure of playback to commence within iTunes itself. None of the failure conditions makes much sense to me from a perspective of determining the root cause, and there is no consistency as to when AirPlay will work and when it will not, and if not, which failure scenario I will get. I just quit BitPerfect and iTunes and try again. Pretty soon, by rinsing and repeating a handful of times, it starts working again. Once it works, it seems to play nicely for an extended period.
I hope this note explains why it is that we can release a product with such spotty AirPlay support. It is not through our inept programming! I suppose we could take the view that since AirPlay support is problematic we should just eliminate it entirely from BitPerfect, and some angry voices have suggested just that, but I remain convinced that the majority view would have us leave it as it is. Please feel free to send me your 5¢ worth to our e-mail support line.
For an update following the release of OS X 10.10 (Yosemite) and iTunes 12.0.1 check out this post, together with the follow-on post that it links to.