audio: Make SDL_AudioDevice::shutdown an atomic value.

Just to make sure this get communicated to the audio thread properly.
This commit is contained in:
Ryan C. Gordon 2016-08-01 11:45:45 -04:00
parent 015dd8dd1d
commit c754662dda
2 changed files with 5 additions and 5 deletions

View File

@ -103,7 +103,7 @@ static const AudioBootStrap *const bootstrap[] = {
&ESD_bootstrap, &ESD_bootstrap,
#endif #endif
#if SDL_AUDIO_DRIVER_NACL #if SDL_AUDIO_DRIVER_NACL
&NACLAUD_bootstrap, &NACLAUD_bootstrap,
#endif #endif
#if SDL_AUDIO_DRIVER_NAS #if SDL_AUDIO_DRIVER_NAS
&NAS_bootstrap, &NAS_bootstrap,
@ -611,7 +611,7 @@ SDL_RunAudio(void *devicep)
current_audio.impl.ThreadInit(device); current_audio.impl.ThreadInit(device);
/* Loop, filling the audio buffers */ /* Loop, filling the audio buffers */
while (!device->shutdown) { while (!SDL_AtomicGet(&device->shutdown)) {
/* Fill the current buffer with sound */ /* Fill the current buffer with sound */
if (device->convert.needed) { if (device->convert.needed) {
stream = device->convert.buf; stream = device->convert.buf;
@ -874,7 +874,7 @@ static void
close_audio_device(SDL_AudioDevice * device) close_audio_device(SDL_AudioDevice * device)
{ {
device->enabled = 0; device->enabled = 0;
device->shutdown = 1; SDL_AtomicSet(&device->shutdown, 1);
if (device->thread != NULL) { if (device->thread != NULL) {
SDL_WaitThread(device->thread, NULL); SDL_WaitThread(device->thread, NULL);
} }

View File

@ -157,10 +157,10 @@ struct SDL_AudioDevice
SDL_AudioStreamer streamer; SDL_AudioStreamer streamer;
/* Current state flags */ /* Current state flags */
/* !!! FIXME: should be SDL_bool */ SDL_atomic_t shutdown; /* true if we are signaling the play thread to end. */
/* !!! FIXME: these should be SDL_bool */
int iscapture; int iscapture;
int enabled; /* true if device is functioning and connected. */ int enabled; /* true if device is functioning and connected. */
int shutdown; /* true if we are signaling the play thread to end. */
int paused; int paused;
int opened; int opened;