test/testaudioinfo.c
author Ryan C. Gordon <icculus@icculus.org>
Tue, 03 Oct 2006 22:17:59 +0000
branchSDL-ryan-multiple-audio-device
changeset 3792 866c310e2cb5
parent 3789 e2f68b579a01
child 3795 589bc3d060cd
permissions -rw-r--r--
Changed some 1.3 audio symbol names.
     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     if (n == 0)
     9         printf("No %s devices.\n\n", typestr);
    10     else
    11     {
    12         int i;
    13         printf("%s devices:\n", typestr);
    14         for (i = 0; i < n; i++) {
    15             printf("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
    16         }
    17         printf("\n");
    18     }
    19 }
    20 
    21 int main(int argc, char **argv)
    22 {
    23     /* Print available audio drivers */
    24     int n = SDL_GetNumAudioDrivers();
    25     if (n == 0) {
    26         printf("No built-in audio drivers\n\n");
    27     } else {
    28         printf("Built-in audio drivers:\n");
    29         int i;
    30         for (i = 0; i < n; ++i) {
    31             printf("  %s\n", SDL_GetAudioDriver(i));
    32         }
    33         printf("\n");
    34     }
    35 
    36     /* Load the SDL library */
    37     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
    38         fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    39         return (1);
    40     }
    41 
    42     printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
    43 
    44     print_devices(0);
    45     print_devices(1);
    46 
    47     SDL_Quit();
    48     return 0;
    49 }
    50