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 2940

Summary: default audio driver (xaudio2) doesn't support reopening device
Product: SDL Reporter: g1529208
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2    
Version: 2.0.3   
Hardware: x86_64   
OS: Windows 7   

Description g1529208 2015-04-11 17:04:22 UTC
The following does not work with the default audio driver on my system (xaudio2):

ASSERT (SDL_OpenAudio (&audio, nullptr) == 0);
SDL_PauseAudio (false);
// <Later>
SDL_CloseAudio ();
ASSERT (SDL_OpenAudio (&audio, nullptr) == 0); // <- this fails the assert

Checking SDL_GetError, "XAudio2: XAudio2Create() failed at open." is returned.

The above code works fine (as it should) with the directsound audio driver.

This bug prevents one from changing the audio format/sample-rate (by reopening the device with the new format/sample-rate), or from closing the device for a while while no sound is expected.
Comment 1 Ryan C. Gordon 2017-05-27 20:05:18 UTC
Coming along to this a long time later, I can't get this to reproduce, but we made heavy fixes to this code since then, so I'm assuming we fixed it.

(Also, we're about to dump XAudio2 entirely, with a new WASAPI renderer for Vista and later, and DirectSound remaining for WinXP...and winmm for XP users with bad DirectSound drivers. :)   ...so you should be good to go here in 2.0.6 in any case, if not already in 2.0.5).

--ryan.