annotate test/testaudioinfo.c @ 3789:e2f68b579a01 SDL-ryan-multiple-audio-device

Added testaudioinfo.c ...
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 03 Oct 2006 20:05:33 +0000
parents
children 866c310e2cb5
rev   line source
3789
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 #include "SDL.h"
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 static void print_devices(int iscapture)
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4 {
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5 const char *typestr = ((iscapture) ? "capture" : "output");
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 int n = SDL_GetNumAudioDevices(iscapture);
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 if (n == 0)
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9 printf("No %s devices.\n\n", typestr);
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10 else
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 {
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12 int i;
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 printf("%s devices:\n", typestr);
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14 for (i = 0; i < n; i++) {
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 printf(" %s\n", SDL_GetAudioDevice(i, iscapture));
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 }
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 printf("\n");
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18 }
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19 }
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21 int main(int argc, char **argv)
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22 {
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23 /* Print available audio drivers */
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24 int n = SDL_GetNumAudioDrivers();
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 if (n == 0) {
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 printf("No built-in audio drivers\n\n");
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27 } else {
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 printf("Built-in audio drivers:\n");
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 int i;
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30 for (i = 0; i < n; ++i) {
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31 printf(" %s\n", SDL_GetAudioDriver(i));
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32 }
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 printf("\n");
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34 }
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36 /* Load the SDL library */
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37 if (SDL_Init(SDL_INIT_AUDIO) < 0) {
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38 fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 return (1);
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
40 }
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
41
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42 printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
43
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44 print_devices(0);
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
45 print_devices(1);
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
47 SDL_Quit();
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
48 return 0;
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
49 }
e2f68b579a01 Added testaudioinfo.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50