test/loopwave.c
changeset 9278 8900afb78a19
parent 8837 3fa15ed506f3
child 9280 f33128b58c5d
     1.1 --- a/test/loopwave.c	Sat Dec 13 02:33:52 2014 -0500
     1.2 +++ b/test/loopwave.c	Thu Dec 18 00:19:52 2014 -0500
     1.3 @@ -24,6 +24,10 @@
     1.4  #include <signal.h>
     1.5  #endif
     1.6  
     1.7 +#ifdef __EMSCRIPTEN__
     1.8 +#include <emscripten/emscripten.h>
     1.9 +#endif
    1.10 +
    1.11  #include "SDL.h"
    1.12  #include "SDL_audio.h"
    1.13  
    1.14 @@ -75,6 +79,13 @@
    1.15      done = 1;
    1.16  }
    1.17  
    1.18 +void
    1.19 +loop()
    1.20 +{
    1.21 +    if(done || (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING))
    1.22 +        emscripten_cancel_main_loop();
    1.23 +}
    1.24 +
    1.25  int
    1.26  main(int argc, char *argv[])
    1.27  {
    1.28 @@ -131,8 +142,13 @@
    1.29  
    1.30      /* Let the audio run */
    1.31      SDL_PauseAudio(0);
    1.32 +
    1.33 +#ifdef __EMSCRIPTEN__
    1.34 +    emscripten_set_main_loop(loop, 0, 1);
    1.35 +#else
    1.36      while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING))
    1.37          SDL_Delay(1000);
    1.38 +#endif
    1.39  
    1.40      /* Clean up on signal */
    1.41      SDL_CloseAudio();