test/testaudiocapture.c
changeset 10263 ec1844380edb
parent 10261 e8facf18d5bd
child 10272 2b8bb76140a5
     1.1 --- a/test/testaudiocapture.c	Sat Aug 06 02:47:27 2016 -0400
     1.2 +++ b/test/testaudiocapture.c	Sat Aug 06 02:48:00 2016 -0400
     1.3 @@ -21,12 +21,6 @@
     1.4  static SDL_AudioDeviceID devid_in = 0;
     1.5  static SDL_AudioDeviceID devid_out = 0;
     1.6  
     1.7 -void SDLCALL
     1.8 -capture_callback(void *arg, Uint8 * stream, int len)
     1.9 -{
    1.10 -    SDL_QueueAudio(devid_out, stream, len);
    1.11 -}
    1.12 -
    1.13  static void
    1.14  loop()
    1.15  {
    1.16 @@ -76,6 +70,18 @@
    1.17          #endif
    1.18          exit(0);
    1.19      }
    1.20 +
    1.21 +    /* Note that it would be easier to just have a one-line function that
    1.22 +        calls SDL_QueueAudio() as a capture device callback, but we're
    1.23 +        trying to test the API, so we use SDL_DequeueAudio() here. */
    1.24 +    while (SDL_TRUE) {
    1.25 +        Uint8 buf[1024];
    1.26 +        const Uint32 br = SDL_DequeueAudio(devid_in, buf, sizeof (buf));
    1.27 +        SDL_QueueAudio(devid_out, buf, br);
    1.28 +        if (br < sizeof (buf)) {
    1.29 +            break;
    1.30 +        }
    1.31 +    }
    1.32  }
    1.33  
    1.34  int
    1.35 @@ -113,7 +119,7 @@
    1.36      spec.format = AUDIO_F32SYS;
    1.37      spec.channels = 1;
    1.38      spec.samples = 1024;
    1.39 -    spec.callback = capture_callback;
    1.40 +    spec.callback = NULL;
    1.41  
    1.42      SDL_Log("Opening capture device %s%s%s...\n",
    1.43              devname ? "'" : "",
    1.44 @@ -128,7 +134,6 @@
    1.45      }
    1.46  
    1.47      SDL_Log("Opening default playback device...\n");
    1.48 -    spec.callback = NULL;
    1.49      devid_out = SDL_OpenAudioDevice(NULL, SDL_FALSE, &spec, &spec, 0);
    1.50      if (!devid_out) {
    1.51          SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for capture: %s!\n", SDL_GetError());