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