When I try to use XAudio2 it already fails at the XAudio2Create(...) function. (INITIALIZE returns at this line: if (FAILED(hr)) return false;
I don't know why and google only tells me to install the directx redistributable, which I did but nothing changed... Any Ideas?
This is basicly code from MSDN:
IXAudio2* pXAudio2 = NULL;
bool INITIALIZE()
{
HRESULT hr = XAudio2Create(&pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR);
if (FAILED(hr)) return false;
.
.
.
}
I tried this but none of those Error-Codes seem to match:
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";
Output:
hresult: -2147221008
Never mind Google: use the documentation:
Simply check that error code to find out what's going on.