test/testaudioinfo.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 04 Oct 2006 06:00:10 +0000
branchSDL-ryan-multiple-audio-device
changeset 3795 589bc3d060cd
parent 3792 866c310e2cb5
child 3836 7dc7327cd626
permissions -rw-r--r--
More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
     1 #include "SDL.h"
     2 
     3 static void print_devices(int iscapture)
     4 {
     5     const char *typestr = ((iscapture) ? "capture" : "output");
     6     int n = SDL_GetNumAudioDevices(iscapture);
     7 
     8     printf("%s devices:\n", typestr);
     9 
    10     if (n == -1)
    11         printf("  Driver can't detect specific devices.\n\n", typestr);
    12     else if (n == 0)
    13         printf("  No %s devices found.\n\n", typestr);
    14     else
    15     {
    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 main(int argc, char **argv)
    25 {
    26     /* Print available audio drivers */
    27     int n = SDL_GetNumAudioDrivers();
    28     if (n == 0) {
    29         printf("No built-in audio drivers\n\n");
    30     } else {
    31         printf("Built-in audio drivers:\n");
    32         int i;
    33         for (i = 0; i < n; ++i) {
    34             printf("  %s\n", SDL_GetAudioDriver(i));
    35         }
    36         printf("\n");
    37     }
    38 
    39     /* Load the SDL library */
    40     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
    41         fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    42         return (1);
    43     }
    44 
    45     printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
    46 
    47     print_devices(0);
    48     print_devices(1);
    49 
    50     SDL_Quit();
    51     return 0;
    52 }
    53