testaudiocapture: Make a simple green/red window when recording/playing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
diff --git a/test/testaudiocapture.c b/test/testaudiocapture.c
index 30742f9..7faeb82 100644
--- a/test/testaudiocapture.c
+++ b/test/testaudiocapture.c
@@ -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 @@ loop()
}
}
+ #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 @@ main(int argc, char **argv)
}
/* 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());