testaudiocapture: Make a simple green/red window when recording/playing.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 02 Aug 2016 19:17:51 -0400
changeset 10244656799817375
parent 10243 874c22f118c2
child 10245 f912cd5baa5d
testaudiocapture: Make a simple green/red window when recording/playing.
test/testaudiocapture.c
     1.1 --- a/test/testaudiocapture.c	Tue Aug 02 15:06:40 2016 -0400
     1.2 +++ b/test/testaudiocapture.c	Tue Aug 02 19:17:51 2016 -0400
     1.3 @@ -17,6 +17,12 @@
     1.4  
     1.5  #define CAPTURE_SECONDS 5
     1.6  
     1.7 +#define DO_VIDEO defined(__ANDROID__) || defined(__IPHONEOS__) || defined(__EMSCRIPTEN__)
     1.8 +#if DO_VIDEO
     1.9 +static SDL_Window *window = NULL;
    1.10 +static SDL_Renderer *renderer = NULL;
    1.11 +#endif
    1.12 +
    1.13  static SDL_AudioSpec spec;
    1.14  static Uint8 *sound = NULL;     /* Pointer to wave data */
    1.15  static Uint32 soundlen = 0;     /* Length of wave data */
    1.16 @@ -68,6 +74,16 @@
    1.17          }
    1.18      }
    1.19  
    1.20 +    #if DO_VIDEO
    1.21 +    if (spec.callback == capture_callback) {
    1.22 +        SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
    1.23 +    } else {
    1.24 +        SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
    1.25 +    }
    1.26 +    SDL_RenderClear(renderer);
    1.27 +    SDL_RenderPresent(renderer);
    1.28 +    #endif
    1.29 +
    1.30      if ((!please_quit) && (processed >= soundlen)) {
    1.31          processed = 0;
    1.32          if (spec.callback == capture_callback) {
    1.33 @@ -123,8 +139,12 @@
    1.34      }
    1.35  
    1.36      /* Android apparently needs a window...? */
    1.37 -    #ifdef __ANDROID__  
    1.38 -    SDL_CreateWindow("testaudiocapture", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0);
    1.39 +    #if DO_VIDEO
    1.40 +    window = SDL_CreateWindow("testaudiocapture", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, SDL_WINDOW_FULLSCREEN_DESKTOP);
    1.41 +    renderer = SDL_CreateRenderer(window, -1, 0);
    1.42 +    SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
    1.43 +    SDL_RenderClear(renderer);
    1.44 +    SDL_RenderPresent(renderer);
    1.45      #endif
    1.46  
    1.47      SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());