SDL crashing with ALSA

Using the hatari emulator, I was experiencing crashing at a certain point.
The hatari author and myself traced it down to
SDL_InitSubSystem(SDL_INIT_AUDIO). It works the first time, but if you
make changes in the menu, hatari will shutdown the SDL audio subsystem, and
reinitialize it. SDL crashes when it the audio subsystem gets
reinitialized.

I did further testing and found that the crashing will only happen if
SDL_CloseAudio() gets called first. When I comment out SDL_CloseAudio(),
there’s no problem with SDL_InitSubSystem(SDL_INIT_AUDIO).

The code normally works fine on most systems. The system I’m having a
problem on happens to use the ALSA drivers, which I suspect might be a
factor.

Here is test code that will cause the SDL crash to occur. I realize I don’t
have a corresponding SDL_OpenAudio(), but the hatari code does.

Thanks for any help or insights.

Tony Smolar

#include <SDL/SDL.h>
main()
{
int b;

SDL_Init(SDL_INIT_VIDEO);
for(b=0;b<10;b++)
{
SDL_InitSubSystem(SDL_INIT_AUDIO);
SDL_CloseAudio();

 }

}