Log the error returned by XAudio2Create()

This commit is contained in:
Sam Lantinga 2017-02-09 06:01:14 -08:00
parent 8eee82cd84
commit 107c19daad
1 changed files with 4 additions and 2 deletions

View File

@ -453,6 +453,7 @@ XAUDIO2_Init(SDL_AudioDriverImpl * impl)
#else #else
/* XAudio2Create() is a macro that uses COM; we don't load the .dll */ /* XAudio2Create() is a macro that uses COM; we don't load the .dll */
IXAudio2 *ixa2 = NULL; IXAudio2 *ixa2 = NULL;
HRESULT hr = S_FALSE;
#if defined(__WIN32__) #if defined(__WIN32__)
// TODO, WinRT: Investigate using CoInitializeEx here // TODO, WinRT: Investigate using CoInitializeEx here
if (FAILED(WIN_CoInitialize())) { if (FAILED(WIN_CoInitialize())) {
@ -461,11 +462,12 @@ XAUDIO2_Init(SDL_AudioDriverImpl * impl)
} }
#endif #endif
if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) { hr = XAudio2Create( &ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR );
if ( hr != S_OK) {
#if defined(__WIN32__) #if defined(__WIN32__)
WIN_CoUninitialize(); WIN_CoUninitialize();
#endif #endif
SDL_SetError("XAudio2: XAudio2Create() failed at initialization"); SDL_SetError("XAudio2: XAudio2Create() failed at initialization: 0x%.8x", hr );
return 0; /* not available. */ return 0; /* not available. */
} }
IXAudio2_Release(ixa2); IXAudio2_Release(ixa2);