Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,621 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I was wondering how I can produce a Device Lost message for XAudio2. I tried using the dxcaps -forcetdr command in the Developer Command Prompt window for Visual Studio, but it did not work. I am using C++ and programming for Windows 10.
Derek
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);