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