An audio close bug fix

Hi,

We are using SDL to develop our games on Linux. Sevel days ago we found
a big bug in SDL library and fixed it.

The test environment,
SDL 1.2.2
Linux kernel 2.4.10
Redhat 7.1
XFree86 4.1.0
Intel 815E mainboard with AC97 sound subsystem. Made by GIGABYTE
TECHNONLGY, board type GA-60MM7E.

The bug happens when colse the SDL audio subsystem, sometimes the
program will go into deadloop, or go on running after a very very long
time.

We have modified the SDL-1.2.2/src/audio/dsp/SDL_dspaudio.c,
The original code,

static void DSP_CloseAudio(_THIS)
{
if ( mixbuf != NULL ) {
SDL_FreeAudioMem(mixbuf);
mixbuf = NULL;
}
if ( audio_fd >= 0 ) {
close(audio_fd);
audio_fd = -1;
}
}

We modified it as,

static void DSP_CloseAudio(_THIS)
{
int value; //modified

if ( mixbuf != NULL ) {
    SDL_FreeAudioMem(mixbuf);
    mixbuf = NULL;
}
if ( audio_fd >= 0 ) {
  ioctl(audio_fd, SNDCTL_DSP_RESET, &value);    //modified
    close(audio_fd);
    audio_fd = -1;
}

}

The new code running on our system perfectly. And by the way, we haven’t
found any difference in the newest SDL 1.2.3 about this file. Hope our
fix is right.

Regards,

Tang Meng