I figured it out! One just needs to add a listener to the appropriate AudioDeviceID (the device you wish to monitor):
// add listener for detecting when a device is removed
const AudioObjectPropertyAddress alive_address =
{
kAudioDevicePropertyDeviceIsAlive,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
AudioObjectAddPropertyListener(current_device_id_, &alive_address, deviceIsAliveCallback, &player_);
And then write the corresponding callback:
OSStatus deviceIsAliveCallback(AudioObjectID inObjectID,
UInt32 inNumberAddresses,
const AudioObjectPropertyAddress inAddresses[],
void* inClientData)
{
// your code here
}
Hope this helps someone!