test/testaudioinfo.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 11 Jan 2009 04:05:28 +0000
changeset 3017 3272431eeee2
parent 2060 866052b01ee5
child 3338 9de326b3099c
permissions -rw-r--r--
Added testresample.c
     1 #include "SDL.h"
     2 
     3 static void
     4 print_devices(int iscapture)
     5 {
     6     const char *typestr = ((iscapture) ? "capture" : "output");
     7     int n = SDL_GetNumAudioDevices(iscapture);
     8 
     9     printf("%s devices:\n", typestr);
    10 
    11     if (n == -1)
    12         printf("  Driver can't detect specific devices.\n\n", typestr);
    13     else if (n == 0)
    14         printf("  No %s devices found.\n\n", typestr);
    15     else {
    16         int i;
    17         for (i = 0; i < n; i++) {
    18             printf("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
    19         }
    20         printf("\n");
    21     }
    22 }
    23 
    24 int
    25 main(int argc, char **argv)
    26 {
    27     /* Print available audio drivers */
    28     int n = SDL_GetNumAudioDrivers();
    29     if (n == 0) {
    30         printf("No built-in audio drivers\n\n");
    31     } else {
    32         int i;
    33         printf("Built-in audio drivers:\n");
    34         for (i = 0; i < n; ++i) {
    35             printf("  %s\n", SDL_GetAudioDriver(i));
    36         }
    37         printf("\n");
    38     }
    39 
    40     /* Load the SDL library */
    41     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
    42         fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    43         return (1);
    44     }
    45 
    46     printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
    47 
    48     print_devices(0);
    49     print_devices(1);
    50 
    51     SDL_Quit();
    52     return 0;
    53 }