AudioIODeviceList Changed bug

On Mac, I’m not getting notifications about device changes. Tracking it, in juce_Mac_coreAudio.cpp, we have at line 1356:

static OSStatus hardwareListenerProc (AudioDeviceID, UInt32, const AudioObjectPropertyAddress*, void* clientData) { static_cast <CoreAudioIODeviceType*> (clientData)->audioDeviceListChanged(); return noErr; }

This never fires. But there is another function at line 1129:

[code] static OSStatus hardwareListenerProc (AudioDeviceID /inDevice/, UInt32 /inLine/, const AudioObjectPropertyAddress* pa, void* inClientData)
CoreAudioInternal* const intern = static_cast <CoreAudioInternal*> (inClientData);

    switch (pa->mSelector)


This does get triggered when I change devices, but it doesn’t do anything. pa->mSelector is ‘ownd’, which appears to be: kAudioObjectPropertyOwnedObjects, which is not in the same enum as the ones that function is checking for. Maybe the callback is registered to the wrong place?

With two static functions with the same name, is the compiler picking the wrong one?

Edit - godammit. After carefully debugging this, I kept running, and plugged a device back in, and the ‘correct’ function triggered. I can’t repeat it though. Am I meant to be doing anything on a timer? ScanForDevices or similar?

Edit 2 - I can’t recreate that result. The correct handler isn’t being called, so the listeners don’t get notified.


It’s not just something simple like your CoreAudioIODeviceType having being deleted? It’ll only receive those callbacks while there’s a device object around to receive them.

I’m sure that’s it. I assumed that getting the types was accessing a global list. I’m getting that list from an AudioDeviceManager I keep around to deal with Midi (I’m doing my own callbacks for audio) and I guess it’s not hanging onto them.


Sorry, also - will there be a type for any possible type on that platform? Types won’t come and go, will they?


Not sure I understand the question! The audiodevicemanager class keeps a full set of type objects, but if you’re not using that it’s up to you to keep whatever type objects you need.

I did have an AudioDeviceManager around, but only dealing with Midi. I tried to listen to types from its list, but didn’t get responses. When I keep the types array around, it works fine (thanks).

My question was more if, say, there are no Jack devices alive at app start, will Jack still in in the list?

(Probably doesn’t apply to Jack, but hopefully you get the idea)


Yes - there’s an instance of each type regardless of whether any devices of that type are connected.