HRESULT hr = XAudio2Create(&pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR);
std::cout << "hresult: " << hr << std::endl;
if (hr == XAUDIO2_E_DEVICE_INVALIDATED) std::cout << "XAUDIO2_E_DEVICE_INVALIDATED";
if (hr == XAUDIO2_E_INVALID_CALL) std::cout << "XAUDIO2_E_INVALID_CALL";
if (hr == XAUDIO2_E_XAPO_CREATION_FAILED) std::cout << "XAUDIO2_E_XAPO_CREATION_FAILED";
if (hr == XAUDIO2_E_XMA_DECODER_ERROR) std::cout << "XAUDIO2_E_XMA_DECODER_ERROR";
if (hr == S_OK) std::cout << "S_OK";
You just need to use XAudioCreate
to match XAUDIO2_E_DEVICE_INVALIDATED
.
Don't forget Initializing it before using it:
CoInitializeEx(NULL, COINIT_MULTITHREADED);