The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL[audio]:XAudio2: XAudio2Create() failed at initialization
Architekt


Joined: 08 Sep 2014
Posts: 2
I get this error on Windows 7, 64 Bit with Code::Blocks 13.12 and g++ (MinGW) 9.8.1.
I simply try to call:
Code:

if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) {
   std::cerr << "SDL init failed: " << SDL_GetError() << std::endl;
   exit(1);
}

It works fine, but if I call SDL_GetError after that, I get the error. Is that only a note? Or is that something bad?
Architekt


Joined: 08 Sep 2014
Posts: 2
So, nobody knows?
SDL[audio]:XAudio2: XAudio2Create() failed at initialization
Jonny D


Joined: 12 Sep 2009
Posts: 932
All SDL functions that set error messages have a way to signal that an error has occured (e.g. returning a NULL pointer or non-zero int).


So you should not be calling SDL_GetError() just to see if an error has occurred.  Call it to get more info for an error that you've already detected.


If you really do want to use SDL_GetError() to detect errors, you must call SDL_ClearError() to reset the error status before you make the calls that might generate the errors.


See:
https://wiki.libsdl.org/SDL_GetError



Jonny D