I’ve encountered a weird bug, and I’m not even sure how to adequately
describe it. But here goes:
I have an app (Stella, 2600 emulator) that can use software or OpenGL
rendering. Stella tends to re-initialize the video and sound subsystems
quite a bit during a typical run. For example, the ROM launcher is one
video mode, and starting emulation is another video mode.
Entering/exiting the debugger while playing a game toggles yet another
different video mode.
Anyway, switching video with SDL_SetVideoMode multiple times in fine.
Starting a ROM also does an SDL_OpenAudio, and closing later does an
SDL_CloseAudio. Generally, this is also working fine.
However, I’ve found a bug where a Windows system using OpenGL mode with
ATI video cards doesn’t seem to open the audio card once it’s been closed
(ie, the first open succeeds, then a close, but a subsequent open won’t
work).
This is the sequence of calls in various parts of the code:
// Initialize system in very beginning to detect desktop res, etc
if(SDL_WasInit(SDL_INIT_VIDEO) == 0)
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
return;
...
// Start up video subsystem, possibly called multiple times per app run
// (will never re-init, since the video subsystem wasn’t closed)
if(SDL_WasInit(SDL_INIT_VIDEO) == 0)
{
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
{
cerr << "ERROR: … "
return false;
}
}
...
// Start up audio subsystem, possibly called multiple times per app run
// (will always re-init, since the audio subsystem was closed)
if(SDL_WasInit(SDL_INIT_AUDIO) == 0)
{
…
if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
{
cerr << "WARNING: Couldn’t initialize SDL audio system! " << endl
<< " " << SDL_GetError() << endl;
return;
}
else
{
…
}
Block 1 is always called just once (when the app starts). Block 3 always
re-opens the audio when called, since it was closed previously by an
SDL_CloseAudio. It really shouldn’t matter which order blocks 2 and 3
are called in, but apparently it does.
If the order is 1, 2 ,3, sound doesn’t work at all. If it’s 1,3,2, sound
works for the first time, but not on subsequent 2,3 (or 3,2) calls.
It’s really weird. Does anyone have any advice??
Thanks,
SA