AirPlay Volume Bug: Goto Mute
Posted By Quentin Carnicelli on April 3rd, 2018
Earlier today, we shipped an update to our home audio streamer Airfoil for Mac. The just-released version 5.7.3 works around a bug introduced by Apple in tvOS 11.3. This bug is likely to affect not just Airfoil users, but anyone who sends AirPlay audio to their Apple TV, so a summary of Apple’s bug may be helpful.
In short, for Apple TV receiving audio via AirPlay, volume handling is broken on tvOS 11.3. When the sender has its volume set to zero, audio will still be heard from the Apple TV. You can try it yourself by setting the iTunes volume slider to the far left, as seen below. Send audio to an Apple TV running tvOS 11.3, and you’ll still hear audio leaking out of the AppleTV. This issue occurs with any source sending to the device, including Apple’s iTunes and iOS, as well as previous versions of our own Airfoil.
The sending volume in iTunes is at 0, but audio will still be heard.
A little background on AirPlay volume control helps explain what’s occurring. To eliminate slider latency, AirPlay audio has its volume set on the receiving end (here, that’s the Apple TV). To do this, the sender (here, iTunes) provides the volume level using a special SET_PARAMETER volume command. As a result, adjusting the volume slider in iTunes immediately changes the remote volume, with no lag.
That volume command allows a value range of 0 dB for full volume down to -30 dB for full reduction. However, a -30 dB reduction is often not enough to mute very loud audio, so there’s also a special value to force full muting. When audio should be fully muted, a sender tells the receiver to set volume to -144 dB. The receiver then knows it should not play any audio at all.
With the tvOS 11.3 update, this mute special case is now kicking in at -145 dB, instead of -144 dB. Though it’s impossible to be certain without actually seeing Apple’s source code, this is very likely to be an off-by-one bug. Specifically, it seems that a less-than-or-equal sign got changed to a less-than.
The previous code would have looked something like this:
if $volume <= -144
While the updated code would look like this:
if $volume < -144
This one small change leads to a very unexpected result for users. We expect Apple will correct this bug in a future tvOS update, but until they do, iTunes and iOS sending won’t properly mute audio to the Apple TV devices.
For our part, once we understood the problem, we could update Airfoil for Mac to work around it. Be sure update to Airfoil for Mac 5.7.3, which will correctly mute audio for all versions of tvOS (Airfoil for Windows users, watch for an update coming soon as well).