test/testaudioinfo.c
author Alex Szpakowski <slime73@gmail.com>
Wed, 06 May 2015 12:54:51 -0300
changeset 9589 a583c42c51d7
parent 8149 681eb46b8ac4
child 9619 b94b6d0bff0f
permissions -rw-r--r--
Fixed SDL_GL_GetAttribute queries for framebuffer component sizes in Core Profile OpenGL contexts.

Fixes bugzilla #2060.
slouken@5535
     1
/*
slouken@8149
     2
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
slouken@5535
     3
slouken@5535
     4
  This software is provided 'as-is', without any express or implied
slouken@5535
     5
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     6
  arising from the use of this software.
slouken@5535
     7
slouken@5535
     8
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
     9
  including commercial applications, and to alter it and redistribute it
slouken@5535
    10
  freely.
slouken@5535
    11
*/
slouken@3338
    12
#include <stdio.h>
icculus@2049
    13
#include "SDL.h"
icculus@2049
    14
slouken@2060
    15
static void
slouken@2060
    16
print_devices(int iscapture)
icculus@2049
    17
{
icculus@2049
    18
    const char *typestr = ((iscapture) ? "capture" : "output");
icculus@2049
    19
    int n = SDL_GetNumAudioDevices(iscapture);
icculus@2049
    20
aschiffler@7639
    21
    SDL_Log("%s devices:\n", typestr);
icculus@2049
    22
icculus@2049
    23
    if (n == -1)
aschiffler@7639
    24
        SDL_Log("  Driver can't detect specific %s devices.\n\n", typestr);
icculus@2049
    25
    else if (n == 0)
aschiffler@7639
    26
        SDL_Log("  No %s devices found.\n\n", typestr);
slouken@2060
    27
    else {
icculus@2049
    28
        int i;
icculus@2049
    29
        for (i = 0; i < n; i++) {
aschiffler@7639
    30
            SDL_Log("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
icculus@2049
    31
        }
aschiffler@7639
    32
        SDL_Log("\n");
icculus@2049
    33
    }
icculus@2049
    34
}
icculus@2049
    35
slouken@2060
    36
int
slouken@2060
    37
main(int argc, char **argv)
icculus@2049
    38
{
icculus@7034
    39
    int n;
icculus@7034
    40
aschiffler@7639
    41
    /* Enable standard application logging */
aschiffler@7639
    42
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
aschiffler@7639
    43
icculus@3635
    44
    /* Load the SDL library */
icculus@3635
    45
    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
aschiffler@7639
    46
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
icculus@3635
    47
        return (1);
icculus@3635
    48
    }
icculus@3635
    49
icculus@2049
    50
    /* Print available audio drivers */
icculus@7034
    51
    n = SDL_GetNumAudioDrivers();
icculus@2049
    52
    if (n == 0) {
aschiffler@7639
    53
        SDL_Log("No built-in audio drivers\n\n");
icculus@2049
    54
    } else {
icculus@2049
    55
        int i;
aschiffler@7639
    56
        SDL_Log("Built-in audio drivers:\n");
icculus@2049
    57
        for (i = 0; i < n; ++i) {
aschiffler@7639
    58
            SDL_Log("  %s\n", SDL_GetAudioDriver(i));
icculus@2049
    59
        }
aschiffler@7639
    60
        SDL_Log("\n");
icculus@2049
    61
    }
icculus@2049
    62
aschiffler@7639
    63
    SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
icculus@2049
    64
icculus@2049
    65
    print_devices(0);
icculus@2049
    66
    print_devices(1);
icculus@2049
    67
icculus@2049
    68
    SDL_Quit();
icculus@2049
    69
    return 0;
icculus@2049
    70
}