AudioIODevice gets incorrectly restarted when unplugged [patch included]


When e.g. a USB device is unplugged, the following happens (not 100% sure about the order of the two first events here here):

1. the device gets stopped (with callbacks, as expected)

2. deviceListenerProc gets notified with kAudioDevicePropertyDeviceIsAlive, which will trigger a normal "device changed" check

3.  AudioObjectGetPropertyData for kAudioDevicePropertyDeviceIsAlive inside updateDetailsFromDevice will fail, which will trigger an error callback

4. However, after this, the device will be "restarted", and you will get a started callback.


I fixed this by adding a bool return to updateDetailsFromDevice, and skip the restart in this case, patch attached. Not sure if this is the best place to fix it, but at least it works. Would appreciate it if a fix for this would be made, as it is causing a nasty live-lock for me in some lock-free code, when the device is supposed to be running, but you don't get any process callbacks.

BTW, could you please allow .patch and .diff attachments?


Thanks! Will investigate that today..