From c754662dda0d9c5698e7ebb5f8dfafc8efa914e4 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 1 Aug 2016 11:45:45 -0400 Subject: [PATCH] audio: Make SDL_AudioDevice::shutdown an atomic value. Just to make sure this get communicated to the audio thread properly. --- src/audio/SDL_audio.c | 6 +++--- src/audio/SDL_sysaudio.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index eb1dd5e92e8e1..b7dab5c947642 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -103,7 +103,7 @@ static const AudioBootStrap *const bootstrap[] = { &ESD_bootstrap, #endif #if SDL_AUDIO_DRIVER_NACL - &NACLAUD_bootstrap, + &NACLAUD_bootstrap, #endif #if SDL_AUDIO_DRIVER_NAS &NAS_bootstrap, @@ -611,7 +611,7 @@ SDL_RunAudio(void *devicep) current_audio.impl.ThreadInit(device); /* Loop, filling the audio buffers */ - while (!device->shutdown) { + while (!SDL_AtomicGet(&device->shutdown)) { /* Fill the current buffer with sound */ if (device->convert.needed) { stream = device->convert.buf; @@ -874,7 +874,7 @@ static void close_audio_device(SDL_AudioDevice * device) { device->enabled = 0; - device->shutdown = 1; + SDL_AtomicSet(&device->shutdown, 1); if (device->thread != NULL) { SDL_WaitThread(device->thread, NULL); } diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 426a190f18516..3fb4c5cb4987b 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -157,10 +157,10 @@ struct SDL_AudioDevice SDL_AudioStreamer streamer; /* 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 enabled; /* true if device is functioning and connected. */ - int shutdown; /* true if we are signaling the play thread to end. */ int paused; int opened;