sdl: clean up audio driver

This prevents a (highly improbable) race condition when exiting, and uses
pcm_set_frequency() instead of mixer_set_frequency(), since that seems like
the Right Thing to Do (TM).

Change-Id: Icb6a4597843215f08b3835490ac63f67c9a04736
This commit is contained in:
Franklin Wei 2018-01-05 17:30:09 -05:00
parent beaeb28a29
commit ef373c03b9

View file

@ -211,6 +211,7 @@ static Uint8 *ROCKBOXAUD_GetAudioBuf(_THIS)
static void ROCKBOXAUD_CloseAudio(_THIS)
{
rb->pcm_play_stop();
if ( this->hidden->mixbuf != NULL ) {
SDL_FreeAudioMem(this->hidden->mixbuf);
this->hidden->mixbuf = NULL;
@ -221,7 +222,6 @@ static void ROCKBOXAUD_CloseAudio(_THIS)
if(this->hidden->rb_buf[i])
SDL_FreeAudioMem(this->hidden->rb_buf[i]);
}
rb->pcm_play_stop();
rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
}
@ -236,7 +236,7 @@ static int ROCKBOXAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
SDL_CalculateAudioSpec(spec);
LOGF("samplerate %d", spec->freq);
rb->mixer_set_frequency(spec->freq);
rb->pcm_set_frequency(spec->freq);
/* Allocate mixing buffer */
this->hidden->mixlen = spec->size;