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!
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@3795
     8
    printf("%s devices:\n", typestr);
icculus@3795
     9
icculus@3795
    10
    if (n == -1)
icculus@3795
    11
        printf("  Driver can't detect specific devices.\n\n", typestr);
icculus@3795
    12
    else if (n == 0)
icculus@3795
    13
        printf("  No %s devices found.\n\n", typestr);
icculus@3789
    14
    else
icculus@3789
    15
    {
icculus@3789
    16
        int i;
icculus@3789
    17
        for (i = 0; i < n; i++) {
icculus@3792
    18
            printf("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
icculus@3789
    19
        }
icculus@3789
    20
        printf("\n");
icculus@3789
    21
    }
icculus@3789
    22
}
icculus@3789
    23
icculus@3789
    24
int main(int argc, char **argv)
icculus@3789
    25
{
icculus@3789
    26
    /* Print available audio drivers */
icculus@3789
    27
    int n = SDL_GetNumAudioDrivers();
icculus@3789
    28
    if (n == 0) {
icculus@3789
    29
        printf("No built-in audio drivers\n\n");
icculus@3789
    30
    } else {
icculus@3789
    31
        printf("Built-in audio drivers:\n");
icculus@3789
    32
        int i;
icculus@3789
    33
        for (i = 0; i < n; ++i) {
icculus@3789
    34
            printf("  %s\n", SDL_GetAudioDriver(i));
icculus@3789
    35
        }
icculus@3789
    36
        printf("\n");
icculus@3789
    37
    }
icculus@3789
    38
icculus@3789
    39
    /* Load the SDL library */
icculus@3789
    40
    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
icculus@3789
    41
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
icculus@3789
    42
        return (1);
icculus@3789
    43
    }
icculus@3789
    44
icculus@3789
    45
    printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
icculus@3789
    46
icculus@3789
    47
    print_devices(0);
icculus@3789
    48
    print_devices(1);
icculus@3789
    49
icculus@3789
    50
    SDL_Quit();
icculus@3789
    51
    return 0;
icculus@3789
    52
}
icculus@3789
    53