Audio Callback Never Starts After Waking From Sleep

This might be a long shot but I am trying to solve a bug where audio stops working in the app after my computer wakes from sleep. The audio device type is a WASAPI audio device I am using the AudioDeviceManager to manage the audio devices when suspended() is called I make a call AudioDeviceManager::closeAudioDevice(). In resume I create an AudioDeviceManager::AudioDeviceSetup and then call AudioDeviceManager::setAudioDeviceSetup() passing it that setup and finally call AudioDeviceManager::restartLastAudioDevice() and the audio callback never starts.

Interestingly enough if I put a Sleep(1000) before the call to restartLastAudioDevice() for at least some users this seems to solve the problem. I have noticed WASAPI seems to create this OnSessionDisconnected error but checking for this and repeating the restart process doesn’t solve the problem.

Has anyone ran into something like this with WASAPI or AudioDeviceManager class. It appears to find the audio device but the callback itself just never starts. Any thoughts or suggestions on things to check are appreciated

I have narrowed it down quite a bit and discovered that for some reason after restartLastAudioDevice has been called and the AudioDevice is setup properly WASAPI thinks the device is removed.

Any recommendations for the best way to handle or “catch” there is no exception thrown with it that I can find. Would I implement my own AudioIODevice with type WASAPI and handle it in there?

Turns out even if I handle this and restart the audio device. The callback will run but WASAPI seems to think there are no input or output channels. Has anyone ran into this when there computer wakes from sleep?