test/testaudioinfo.c
changeset 2049 5f6550e5184f
child 2060 866052b01ee5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/testaudioinfo.c	Tue Oct 17 09:15:21 2006 +0000
     1.3 @@ -0,0 +1,53 @@
     1.4 +#include "SDL.h"
     1.5 +
     1.6 +static void print_devices(int iscapture)
     1.7 +{
     1.8 +    const char *typestr = ((iscapture) ? "capture" : "output");
     1.9 +    int n = SDL_GetNumAudioDevices(iscapture);
    1.10 +
    1.11 +    printf("%s devices:\n", typestr);
    1.12 +
    1.13 +    if (n == -1)
    1.14 +        printf("  Driver can't detect specific devices.\n\n", typestr);
    1.15 +    else if (n == 0)
    1.16 +        printf("  No %s devices found.\n\n", typestr);
    1.17 +    else
    1.18 +    {
    1.19 +        int i;
    1.20 +        for (i = 0; i < n; i++) {
    1.21 +            printf("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
    1.22 +        }
    1.23 +        printf("\n");
    1.24 +    }
    1.25 +}
    1.26 +
    1.27 +int main(int argc, char **argv)
    1.28 +{
    1.29 +    /* Print available audio drivers */
    1.30 +    int n = SDL_GetNumAudioDrivers();
    1.31 +    if (n == 0) {
    1.32 +        printf("No built-in audio drivers\n\n");
    1.33 +    } else {
    1.34 +        int i;
    1.35 +        printf("Built-in audio drivers:\n");
    1.36 +        for (i = 0; i < n; ++i) {
    1.37 +            printf("  %s\n", SDL_GetAudioDriver(i));
    1.38 +        }
    1.39 +        printf("\n");
    1.40 +    }
    1.41 +
    1.42 +    /* Load the SDL library */
    1.43 +    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
    1.44 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    1.45 +        return (1);
    1.46 +    }
    1.47 +
    1.48 +    printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
    1.49 +
    1.50 +    print_devices(0);
    1.51 +    print_devices(1);
    1.52 +
    1.53 +    SDL_Quit();
    1.54 +    return 0;
    1.55 +}
    1.56 +