We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2723

Summary: XAudio 2Create() failed at initialization
Product: SDL Reporter: rswhite4
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED WONTFIX QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.3   
Hardware: x86_64   
OS: Windows 7   

Description rswhite4 2014-09-08 19:46:10 UTC
In Code::Blocks (Code::Blocks 13.12) and with MinGW (gcc (GCC) 4.8.1) I get the error
 > XAudio2: XAudio2Create() failed at initialization
all the time.
The responsible code is this:
 > if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) {
 >	std::cerr << "SDL init failed: " << SDL_GetError() << std::endl;
 >	exit(1);
 > }
If I check SDL_GetError after that, I get the error message above.
But it works with Visual Studio 13

If I do not abort and proceed with:
 > int flags = MIX_INIT_OGG | MIX_INIT_MP3;
 > int initted = Mix_Init(flags);
 > if ((initted & flags) != flags) {
 > 	std::cerr << "Failed to init SDL_mixer: " << Mix_GetError() <<  std::endl;
 > 	exit(1);
 > }
 >
 > if (Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 4096) != 0) {
 > 	std::cerr << "Error by Mix_OpenAudio: " << Mix_GetError() << std::endl;
 > 	exit(1);
 > }
The sound (an *.ogg file with a length of several minutes) plays only the first few seconds and repeat that gain and gain.
The code to play the sample is:
 > Mix_FadeInMusic(_music, 1, 1);
The Mix_Music pointer '_music' is (of course) valid.
Comment 1 rswhite4 2014-09-08 19:48:57 UTC
Sorry, I mistyped:
The code to play the sample is:
 > Mix_FadeInMusic(_music, 1, -1);
Comment 2 rswhite4 2014-09-08 21:19:54 UTC
Sorry, I changed the title. It seems that SDL and SDL_OpenAudio is the culprit.
Comment 3 Sam Lantinga 2017-08-14 05:06:26 UTC
We're removing XAudio2 in favor of WASAPI after the 2.0.6 release.