2 Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
16 print_devices(int iscapture)
18 const char *typestr = ((iscapture) ? "capture" : "output");
19 int n = SDL_GetNumAudioDevices(iscapture);
21 SDL_Log("Found %d %s device%s:\n", n, typestr, n != 1 ? "s" : "");
24 SDL_Log(" Driver can't detect specific %s devices.\n\n", typestr);
26 SDL_Log(" No %s devices found.\n\n", typestr);
29 for (i = 0; i < n; i++) {
30 const char *name = SDL_GetAudioDeviceName(i, iscapture);
32 SDL_Log(" %d: %s\n", i, name);
34 SDL_Log(" %d Error: %s\n", i, SDL_GetError());
41 main(int argc, char **argv)
45 /* Enable standard application logging */
46 SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
48 /* Load the SDL library */
49 if (SDL_Init(SDL_INIT_AUDIO) < 0) {
50 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
54 /* Print available audio drivers */
55 n = SDL_GetNumAudioDrivers();
57 SDL_Log("No built-in audio drivers\n\n");
60 SDL_Log("Built-in audio drivers:\n");
61 for (i = 0; i < n; ++i) {
62 SDL_Log(" %d: %s\n", i, SDL_GetAudioDriver(i));
64 SDL_Log("Select a driver with the SDL_AUDIODRIVER environment variable.\n");
67 SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());