audio: Make SDL_AudioDevice::shutdown an atomic value.
authorRyan C. Gordon
Mon, 01 Aug 2016 11:45:45 -0400
changeset 102333fbf4a6c6101
parent 10232 4f29bb9e19c3
child 10234 d188ffeca506
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
src/audio/SDL_sysaudio.h
     1.1 --- a/src/audio/SDL_audio.c	Mon Aug 01 00:20:47 2016 -0400
     1.2 +++ b/src/audio/SDL_audio.c	Mon Aug 01 11:45:45 2016 -0400
     1.3 @@ -103,7 +103,7 @@
     1.4      &ESD_bootstrap,
     1.5  #endif
     1.6  #if SDL_AUDIO_DRIVER_NACL
     1.7 -   &NACLAUD_bootstrap,
     1.8 +    &NACLAUD_bootstrap,
     1.9  #endif
    1.10  #if SDL_AUDIO_DRIVER_NAS
    1.11      &NAS_bootstrap,
    1.12 @@ -611,7 +611,7 @@
    1.13      current_audio.impl.ThreadInit(device);
    1.14  
    1.15      /* Loop, filling the audio buffers */
    1.16 -    while (!device->shutdown) {
    1.17 +    while (!SDL_AtomicGet(&device->shutdown)) {
    1.18          /* Fill the current buffer with sound */
    1.19          if (device->convert.needed) {
    1.20              stream = device->convert.buf;
    1.21 @@ -874,7 +874,7 @@
    1.22  close_audio_device(SDL_AudioDevice * device)
    1.23  {
    1.24      device->enabled = 0;
    1.25 -    device->shutdown = 1;
    1.26 +    SDL_AtomicSet(&device->shutdown, 1);
    1.27      if (device->thread != NULL) {
    1.28          SDL_WaitThread(device->thread, NULL);
    1.29      }
     2.1 --- a/src/audio/SDL_sysaudio.h	Mon Aug 01 00:20:47 2016 -0400
     2.2 +++ b/src/audio/SDL_sysaudio.h	Mon Aug 01 11:45:45 2016 -0400
     2.3 @@ -157,10 +157,10 @@
     2.4      SDL_AudioStreamer streamer;
     2.5  
     2.6      /* Current state flags */
     2.7 -    /* !!! FIXME: should be SDL_bool */
     2.8 +    SDL_atomic_t shutdown; /* true if we are signaling the play thread to end. */
     2.9 +    /* !!! FIXME: these should be SDL_bool */
    2.10      int iscapture;
    2.11      int enabled;  /* true if device is functioning and connected. */
    2.12 -    int shutdown; /* true if we are signaling the play thread to end. */
    2.13      int paused;
    2.14      int opened;
    2.15