test/testmultiaudio.c
changeset 10003 d91a2c45825e
parent 9998 f67cf37e9cd4
child 10737 3406a0f8b041
     1.1 --- a/test/testmultiaudio.c	Sat Jan 02 12:17:33 2016 -0800
     1.2 +++ b/test/testmultiaudio.c	Sun Jan 03 06:50:50 2016 -0500
     1.3 @@ -25,7 +25,7 @@
     1.4  {
     1.5      SDL_AudioDeviceID dev;
     1.6      int soundpos;
     1.7 -    volatile int done;
     1.8 +    SDL_atomic_t done;
     1.9  } callback_data;
    1.10  
    1.11  callback_data cbd[64];
    1.12 @@ -46,14 +46,14 @@
    1.13      if (len > 0) {
    1.14          stream += cpy;
    1.15          SDL_memset(stream, spec.silence, len);
    1.16 -        cbd->done++;
    1.17 +        SDL_AtomicSet(&cbd->done, 1);
    1.18      }
    1.19  }
    1.20  
    1.21  void
    1.22  loop()
    1.23  {
    1.24 -    if(cbd[0].done) {
    1.25 +    if (SDL_AtomicGet(&cbd[0].done)) {
    1.26  #ifdef __EMSCRIPTEN__
    1.27          emscripten_cancel_main_loop();
    1.28  #endif
    1.29 @@ -100,8 +100,7 @@
    1.30  #ifdef __EMSCRIPTEN__
    1.31              emscripten_set_main_loop(loop, 0, 1);
    1.32  #else
    1.33 -            while (!cbd[0].done)
    1.34 -            {
    1.35 +            while (!SDL_AtomicGet(&cbd[0].done)) {
    1.36                  #ifdef __ANDROID__                
    1.37                  /* Empty queue, some application events would prevent pause. */
    1.38                  while (SDL_PollEvent(&event)){}
    1.39 @@ -136,7 +135,7 @@
    1.40      while (keep_going) {
    1.41          keep_going = 0;
    1.42          for (i = 0; i < devcount; i++) {
    1.43 -            if ((cbd[i].dev) && (!cbd[i].done)) {
    1.44 +            if ((cbd[i].dev) && (!SDL_AtomicGet(&cbd[i].done))) {
    1.45                  keep_going = 1;
    1.46              }
    1.47          }