Called if a critical system error occurs that requires XAudio2 to be closed down and restarted.
Error code returned by XAudio2.
This method does not return a value.
If you provide the ID of a specific device in the szDeviceId parameter to IXAudio2::CreateMasteringVoice or use the XAUDIO2_NO_VIRTUAL_AUDIO_CLIENT flag, then a critical error will occur and OnCriticalError is raised if the underlying WASAPI rendering device becomes unavailable. This can occur when a headset or speaker is unplugged or when a USB audio device is removed, for example. Once a critical error has occurred, audio processing stops and all further calls to XAudio2 fail. The only way to recover in this situation is to release the XAudio2 instance and create a new one.
If you specified NULL or szDeviceId parameter to IXAudio2::CreateMasteringVoice, then the system uses a Virtual Audio Client to represent the audio endpoint. In this case, if the underlying WASAPI rendering device becomes unavailable, the system automatically selects a new audio rendering device for rendering, audio processing continues, and OnCriticalError is not raised.
On the mobile device family, a Virtual Audio Client is always used and OnCriticalError is never raised, regardless of the values you provide to CreateMasteringVoice.
Windows 10 (XAudio2.9); Windows 8, Windows Phone 8 (XAudio 2.8); DirectX SDK (XAudio 2.7)