SDL 2.0
testaudioinfo.c File Reference
#include <stdio.h>
#include "SDL.h"
+ Include dependency graph for testaudioinfo.c:

Go to the source code of this file.

Functions

static void print_devices (int iscapture)
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 41 of file testaudioinfo.c.

42{
43 int n;
44
45 /* Enable standard application logging */
47
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());
51 return (1);
52 }
53
54 /* Print available audio drivers */
56 if (n == 0) {
57 SDL_Log("No built-in audio drivers\n\n");
58 } else {
59 int i;
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));
63 }
64 SDL_Log("Select a driver with the SDL_AUDIODRIVER environment variable.\n");
65 }
66
67 SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
68
71
72 SDL_Quit();
73 return 0;
74}
#define SDL_INIT_AUDIO
Definition: SDL.h:78
#define SDL_GetError
#define SDL_GetNumAudioDrivers
#define SDL_GetCurrentAudioDriver
#define SDL_LogSetPriority
#define SDL_LogError
#define SDL_Quit
#define SDL_Init
#define SDL_GetAudioDriver
#define SDL_Log
@ SDL_LOG_PRIORITY_INFO
Definition: SDL_log.h:106
@ SDL_LOG_CATEGORY_APPLICATION
Definition: SDL_log.h:66
GLdouble n
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
static void print_devices(int iscapture)
Definition: testaudioinfo.c:16

References i, print_devices(), SDL_GetAudioDriver, SDL_GetCurrentAudioDriver, SDL_GetError, SDL_GetNumAudioDrivers, SDL_Init, SDL_INIT_AUDIO, SDL_Log, SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, SDL_LogError, SDL_LogSetPriority, and SDL_Quit.

◆ print_devices()

static void print_devices ( int  iscapture)
static

Definition at line 16 of file testaudioinfo.c.

17{
18 const char *typestr = ((iscapture) ? "capture" : "output");
19 int n = SDL_GetNumAudioDevices(iscapture);
20
21 SDL_Log("Found %d %s device%s:\n", n, typestr, n != 1 ? "s" : "");
22
23 if (n == -1)
24 SDL_Log(" Driver can't detect specific %s devices.\n\n", typestr);
25 else if (n == 0)
26 SDL_Log(" No %s devices found.\n\n", typestr);
27 else {
28 int i;
29 for (i = 0; i < n; i++) {
30 const char *name = SDL_GetAudioDeviceName(i, iscapture);
31 if (name != NULL)
32 SDL_Log(" %d: %s\n", i, name);
33 else
34 SDL_Log(" %d Error: %s\n", i, SDL_GetError());
35 }
36 SDL_Log("\n");
37 }
38}
#define SDL_GetAudioDeviceName
#define SDL_GetNumAudioDevices
GLuint const GLchar * name
#define NULL
Definition: begin_code.h:167

References i, NULL, SDL_GetAudioDeviceName, SDL_GetError, SDL_GetNumAudioDevices, and SDL_Log.

Referenced by main().