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 10226 656799817375
parent 10225 874c22f118c2
child 10227 f912cd5baa5d
testaudiocapture: Make a simple green/red window when recording/playing.
test/testaudiocapture.c
--- a/test/testaudiocapture.c	Tue Aug 02 15:06:40 2016 -0400
+++ b/test/testaudiocapture.c	Tue Aug 02 19:17:51 2016 -0400
@@ -17,6 +17,12 @@
 
 #define CAPTURE_SECONDS 5
 
+#define DO_VIDEO defined(__ANDROID__) || defined(__IPHONEOS__) || defined(__EMSCRIPTEN__)
+#if DO_VIDEO
+static SDL_Window *window = NULL;
+static SDL_Renderer *renderer = NULL;
+#endif
+
 static SDL_AudioSpec spec;
 static Uint8 *sound = NULL;     /* Pointer to wave data */
 static Uint32 soundlen = 0;     /* Length of wave data */
@@ -68,6 +74,16 @@
         }
     }
 
+    #if DO_VIDEO
+    if (spec.callback == capture_callback) {
+        SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
+    } else {
+        SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
+    }
+    SDL_RenderClear(renderer);
+    SDL_RenderPresent(renderer);
+    #endif
+
     if ((!please_quit) && (processed >= soundlen)) {
         processed = 0;
         if (spec.callback == capture_callback) {
@@ -123,8 +139,12 @@
     }
 
     /* Android apparently needs a window...? */
-    #ifdef __ANDROID__  
-    SDL_CreateWindow("testaudiocapture", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0);
+    #if DO_VIDEO
+    window = SDL_CreateWindow("testaudiocapture", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, SDL_WINDOW_FULLSCREEN_DESKTOP);
+    renderer = SDL_CreateRenderer(window, -1, 0);
+    SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
+    SDL_RenderClear(renderer);
+    SDL_RenderPresent(renderer);
     #endif
 
     SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());