AirPlay no longer enumerable in 10.11 unless selected for system

One of my Mac apps offers selection of an output device to play alert sounds.


Since AirPlay system sound output on the Mac was introduced, I was able to select an AirPlay device. This worked but wasn't quite perfect — my app would block while it connected to the AirPlay speaker and the first second or two of audio would drop, but I could at least hear (some of) my alert sounds from across the room with headphones plugged into my Mac.


In 10.11, I can't even enumerate AirPlay devices unless they're selected as the system sound output in Sound System Prefs — they just don't show up. Even in the GM seed, the option-click speaker menu looks like it's not quite finished too, with the AirPlay icon jumping around.


I notice the same thing in Audio MIDI Setup — AirPlay devices don't even show up unless they're selected.


Is this an intentional change in 10.11? Is it documented somewhere? Is there some way to get the (imperfect, but better than nothing) 10.10 behavior back? Is there an alternate method to use for per-app AirPlay output in 10.11 which resolves these issues?


Thanks.

Replies

Somehow I managed to get the AirPlay devices to stick around, but now I'm seeing “AirPlayNullEndpointAudioDataSource” from time to time as the name of the device; never saw that before. I'm beginning to think I should just disallow selection of AirPlay devices entirely in 10.11, even if they do manage to show up.

I found a workaround. You can use the kAudioHardwarePropertyTranslateUIDToDevice get the AudioDeviceID even if the AirPlay device does not appear when iterating over kAudioHardwarePropertyDevices.


    OSStatus status = noErr;
    AudioObjectPropertyAddress propertyAddress = {
        kAudioHardwarePropertyTranslateUIDToDevice,
        kAudioObjectPropertyScopeGlobal,
        kAudioObjectPropertyElementMaster
    };
    CFStringRef airplayDeviceUID = CFSTR("AirPlay");
    UInt32 dataSize = 0;
    status = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &propertyAddress, sizeof(CFStringRef), &airplayDeviceUID, &dataSize);
    if(kAudioHardwareNoError != status) {
        /
        return nil;
    }
    AudioDeviceID airplayDeviceId;
    status = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, sizeof(CFStringRef), &airplayDeviceUID, &dataSize, &airplayDeviceId);
    if(kAudioHardwareNoError != status) {
        /
        return nil;
    }

Thanks for posting this, very helpful and it works 🙂

Hmm, even though I can now get a handle on the AirPlay device, it doesn't seem to have any data sources, which is how it used to present the various network devices that support AirPlay.


Do you happen to know where that info has moved?

To reply to myself, a quick poke around in SystemUIServer to see what the AppleVolumeExtra menu extra is doing, suggests that it's calling into private API in AVFoundation to do the AirPlay device discovery 😟

I can confirm that. I am also not able to stream any audio to the device if it is not selected as the system output device. This ***** Apple! This doesn't look like a bug, but rather intention.

I filed http://openradar.appspot.com/radar?id=5039701907996672 and I would strongly suggest that others file a radar with Apple too, so they can see that developers were using the old API and would benefit from the new API being moved public.

actually it might be a bug. if you open system preferences -> sound / output tab, and THEN you start your app then it does provides the list.

but behaves odd and the list disappears after closing preferences.

Hi cmsj,

Did you ever get a response from Apple or elsewhere on this? I've just come across this in one of my own applications and it's a huge pain - Apple seem to be changing the AirPlay functionality with each release and then not documenting it.


Thanks,


P

(As you can see from the OpenRadar page, my Radar was closed as a dupe of another. Sadly, one which OpenRadar doesn't know about)