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