]> git.mxchange.org Git - flightgear.git/blob - tests/al-info.c
Modified Files:
[flightgear.git] / tests / al-info.c
1
2 #include <stdio.h>
3
4 #ifdef __APPLE__
5 # include <OpenAL/al.h>
6 # include <OpenAL/alc.h>
7 #else
8 # include <AL/al.h>
9 # include <AL/alc.h>
10 # ifndef __CYGWIN__
11 #  include <AL/alext.h>
12 # endif
13 #endif
14
15 #ifndef AL_VERSION_1_1
16 # ifdef __APPLE__
17 #  include <OpenAL/altypes.h>
18 #  include <OpenAL/alctypes.h>
19 #else
20 #  include <AL/altypes.h>
21 #  include <AL/alctypes.h>
22 # endif
23 #endif
24
25 #define MAX_DATA        16
26
27 int main()
28 {
29    ALCint i,j;
30    ALCint data[MAX_DATA];
31    ALCdevice *device = NULL;
32    ALCcontext *context = NULL;
33    const unsigned char *s;
34    ALCenum error;
35
36    device = alcOpenDevice(NULL);
37    if (device == NULL)
38    {
39       printf("No default audio device available.\n");
40       return -1;
41    }
42    context = alcCreateContext(device, NULL);
43    if (context == NULL)
44    {
45       printf("Could not create a valid context.\n");
46       return -2;
47    }
48    alcMakeContextCurrent(context);
49
50    s = alGetString(AL_VENDOR);
51    printf("AL_VENDOR = \"%s\"\n", s);
52
53    s = alGetString(AL_RENDERER);
54    printf("AL_RENDERER = \"%s\"\n", s);
55
56    s = alGetString(AL_VERSION);
57    printf("AL_VERSION = \"%s\"\n", s);
58
59    s = alGetString(AL_EXTENSIONS);
60    printf("AL_EXTENSIONS = \"%s\"\n", s);
61
62    alcGetError(device);
63
64    printf("\n");
65    if (alcIsExtensionPresent(NULL, (unsigned char *)"ALC_ENUMERATION_EXT") == AL_TRUE)
66    {
67       s = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
68       printf("ALC_DEVICE_SPECIFIER = \"%s\"\n", s);
69    }
70
71    alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, data);
72    printf("ALC_MAJOR_VERSION = %i\n", *data);
73    alcGetIntegerv(device, ALC_MINOR_VERSION, 1, data);
74    printf("ALC_MINOR_VERSION = %i\n", *data);
75
76    s = alcGetString(device, ALC_EXTENSIONS);
77    printf("ALC_EXTENSIONS = \"%s\"\n", s);
78
79    if ((error = alcGetError(device)))
80    {
81       printf("Error #%i occured\n", error);
82       return error;
83    }
84
85    s = alcGetString(device, ALC_DEFAULT_DEVICE_SPECIFIER);
86    printf("ALC_DEFAULT_DEVICE_SPECIFIER = \"%s\"\n", s);
87
88    if ((error = alcGetError(device)))
89    {
90       printf("Error #%i occured\n", error);
91       return error;
92    }
93
94 #if 0
95    alcGetIntegerv(device, ALC_ATTRIBUTES_SIZE, 1, &i);
96    printf("ALC attributes(%i): ", i);
97
98    alcGetIntegerv(device, ALC_ALL_ATTRIBUTES, i, data);
99    for (j=0; j<i; j++)
100    {
101       printf("%i ", data[j]);
102    }
103    printf("\n");
104
105    if ((error = alcGetError(device)))
106    {
107       printf("Error #%i occured\n", error);
108       return error;
109    }
110 #endif
111
112    alcCloseDevice(device);
113
114    return 0;
115 }