2 * OpenAL cross platform audio library
3 * Copyright (C) 1999-2007 by authors.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
24 #include "alExtension.h"
30 static ALfunction function
[]= {
31 { "alEnable", (ALvoid
*) alEnable
},
32 { "alDisable", (ALvoid
*) alDisable
},
33 { "alIsEnabled", (ALvoid
*) alIsEnabled
},
34 { "alGetString", (ALvoid
*) alGetString
},
35 { "alGetBooleanv", (ALvoid
*) alGetBooleanv
},
36 { "alGetIntegerv", (ALvoid
*) alGetIntegerv
},
37 { "alGetFloatv", (ALvoid
*) alGetFloatv
},
38 { "alGetDoublev", (ALvoid
*) alGetDoublev
},
39 { "alGetBoolean", (ALvoid
*) alGetBoolean
},
40 { "alGetInteger", (ALvoid
*) alGetInteger
},
41 { "alGetFloat", (ALvoid
*) alGetFloat
},
42 { "alGetDouble", (ALvoid
*) alGetDouble
},
43 { "alGetError", (ALvoid
*) alGetError
},
44 { "alIsExtensionPresent", (ALvoid
*) alIsExtensionPresent
},
45 { "alGetProcAddress", (ALvoid
*) alGetProcAddress
},
46 { "alGetEnumValue", (ALvoid
*) alGetEnumValue
},
47 { "alListenerf", (ALvoid
*) alListenerf
},
48 { "alListener3f", (ALvoid
*) alListener3f
},
49 { "alListenerfv", (ALvoid
*) alListenerfv
},
50 { "alListeneri", (ALvoid
*) alListeneri
},
51 { "alListener3i", (ALvoid
*) alListener3i
},
52 { "alListeneriv", (ALvoid
*) alListeneriv
},
53 { "alGetListenerf", (ALvoid
*) alGetListenerf
},
54 { "alGetListener3f", (ALvoid
*) alGetListener3f
},
55 { "alGetListenerfv", (ALvoid
*) alGetListenerfv
},
56 { "alGetListeneri", (ALvoid
*) alGetListeneri
},
57 { "alGetListener3i", (ALvoid
*) alGetListener3i
},
58 { "alGetListeneriv", (ALvoid
*) alGetListeneriv
},
59 { "alGenSources", (ALvoid
*) alGenSources
},
60 { "alDeleteSources", (ALvoid
*) alDeleteSources
},
61 { "alIsSource", (ALvoid
*) alIsSource
},
62 { "alSourcef", (ALvoid
*) alSourcef
},
63 { "alSource3f", (ALvoid
*) alSource3f
},
64 { "alSourcefv", (ALvoid
*) alSourcefv
},
65 { "alSourcei", (ALvoid
*) alSourcei
},
66 { "alSource3i", (ALvoid
*) alSource3i
},
67 { "alSourceiv", (ALvoid
*) alSourceiv
},
68 { "alGetSourcef", (ALvoid
*) alGetSourcef
},
69 { "alGetSource3f", (ALvoid
*) alGetSource3f
},
70 { "alGetSourcefv", (ALvoid
*) alGetSourcefv
},
71 { "alGetSourcei", (ALvoid
*) alGetSourcei
},
72 { "alGetSource3i", (ALvoid
*) alGetSource3i
},
73 { "alGetSourceiv", (ALvoid
*) alGetSourceiv
},
74 { "alSourcePlayv", (ALvoid
*) alSourcePlayv
},
75 { "alSourceStopv", (ALvoid
*) alSourceStopv
},
76 { "alSourceRewindv", (ALvoid
*) alSourceRewindv
},
77 { "alSourcePausev", (ALvoid
*) alSourcePausev
},
78 { "alSourcePlay", (ALvoid
*) alSourcePlay
},
79 { "alSourceStop", (ALvoid
*) alSourceStop
},
80 { "alSourceRewind", (ALvoid
*) alSourceRewind
},
81 { "alSourcePause", (ALvoid
*) alSourcePause
},
82 { "alSourceQueueBuffers", (ALvoid
*) alSourceQueueBuffers
},
83 { "alSourceUnqueueBuffers", (ALvoid
*) alSourceUnqueueBuffers
},
84 { "alGenBuffers", (ALvoid
*) alGenBuffers
},
85 { "alDeleteBuffers", (ALvoid
*) alDeleteBuffers
},
86 { "alIsBuffer", (ALvoid
*) alIsBuffer
},
87 { "alBufferData", (ALvoid
*) alBufferData
},
88 { "alBufferf", (ALvoid
*) alBufferf
},
89 { "alBuffer3f", (ALvoid
*) alBuffer3f
},
90 { "alBufferfv", (ALvoid
*) alBufferfv
},
91 { "alBufferi", (ALvoid
*) alBufferi
},
92 { "alBuffer3i", (ALvoid
*) alBuffer3i
},
93 { "alBufferiv", (ALvoid
*) alBufferiv
},
94 { "alGetBufferf", (ALvoid
*) alGetBufferf
},
95 { "alGetBuffer3f", (ALvoid
*) alGetBuffer3f
},
96 { "alGetBufferfv", (ALvoid
*) alGetBufferfv
},
97 { "alGetBufferi", (ALvoid
*) alGetBufferi
},
98 { "alGetBuffer3i", (ALvoid
*) alGetBuffer3i
},
99 { "alGetBufferiv", (ALvoid
*) alGetBufferiv
},
100 { "alDopplerFactor", (ALvoid
*) alDopplerFactor
},
101 { "alDopplerVelocity", (ALvoid
*) alDopplerVelocity
},
102 { "alSpeedOfSound", (ALvoid
*) alSpeedOfSound
},
103 { "alDistanceModel", (ALvoid
*) alDistanceModel
},
104 { NULL
, (ALvoid
*) NULL
} };
106 static ALenums enumeration
[]={
108 { (ALchar
*)"AL_INVALID", AL_INVALID
},
109 { (ALchar
*)"AL_NONE", AL_NONE
},
110 { (ALchar
*)"AL_FALSE", AL_FALSE
},
111 { (ALchar
*)"AL_TRUE", AL_TRUE
},
113 // Source and Listener Properties
114 { (ALchar
*)"AL_SOURCE_RELATIVE", AL_SOURCE_RELATIVE
},
115 { (ALchar
*)"AL_CONE_INNER_ANGLE", AL_CONE_INNER_ANGLE
},
116 { (ALchar
*)"AL_CONE_OUTER_ANGLE", AL_CONE_OUTER_ANGLE
},
117 { (ALchar
*)"AL_PITCH", AL_PITCH
},
118 { (ALchar
*)"AL_POSITION", AL_POSITION
},
119 { (ALchar
*)"AL_DIRECTION", AL_DIRECTION
},
120 { (ALchar
*)"AL_VELOCITY", AL_VELOCITY
},
121 { (ALchar
*)"AL_LOOPING", AL_LOOPING
},
122 { (ALchar
*)"AL_BUFFER", AL_BUFFER
},
123 { (ALchar
*)"AL_GAIN", AL_GAIN
},
124 { (ALchar
*)"AL_MIN_GAIN", AL_MIN_GAIN
},
125 { (ALchar
*)"AL_MAX_GAIN", AL_MAX_GAIN
},
126 { (ALchar
*)"AL_ORIENTATION", AL_ORIENTATION
},
127 { (ALchar
*)"AL_REFERENCE_DISTANCE", AL_REFERENCE_DISTANCE
},
128 { (ALchar
*)"AL_ROLLOFF_FACTOR", AL_ROLLOFF_FACTOR
},
129 { (ALchar
*)"AL_CONE_OUTER_GAIN", AL_CONE_OUTER_GAIN
},
130 { (ALchar
*)"AL_MAX_DISTANCE", AL_MAX_DISTANCE
},
131 { (ALchar
*)"AL_SEC_OFFSET", AL_SEC_OFFSET
},
132 { (ALchar
*)"AL_SAMPLE_OFFSET", AL_SAMPLE_OFFSET
},
133 { (ALchar
*)"AL_BYTE_OFFSET", AL_BYTE_OFFSET
},
134 { (ALchar
*)"AL_SOURCE_TYPE", AL_SOURCE_TYPE
},
135 { (ALchar
*)"AL_STATIC", AL_STATIC
},
136 { (ALchar
*)"AL_STREAMING", AL_STREAMING
},
137 { (ALchar
*)"AL_UNDETERMINED", AL_UNDETERMINED
},
139 // Source State information
140 { (ALchar
*)"AL_SOURCE_STATE", AL_SOURCE_STATE
},
141 { (ALchar
*)"AL_INITIAL", AL_INITIAL
},
142 { (ALchar
*)"AL_PLAYING", AL_PLAYING
},
143 { (ALchar
*)"AL_PAUSED", AL_PAUSED
},
144 { (ALchar
*)"AL_STOPPED", AL_STOPPED
},
147 { (ALchar
*)"AL_BUFFERS_QUEUED", AL_BUFFERS_QUEUED
},
148 { (ALchar
*)"AL_BUFFERS_PROCESSED", AL_BUFFERS_PROCESSED
},
151 { (ALchar
*)"AL_FORMAT_MONO8", AL_FORMAT_MONO8
},
152 { (ALchar
*)"AL_FORMAT_MONO16", AL_FORMAT_MONO16
},
153 { (ALchar
*)"AL_FORMAT_MONO_FLOAT32", AL_FORMAT_MONO_FLOAT32
},
154 { (ALchar
*)"AL_FORMAT_STEREO8", AL_FORMAT_STEREO8
},
155 { (ALchar
*)"AL_FORMAT_STEREO16", AL_FORMAT_STEREO16
},
156 { (ALchar
*)"AL_FORMAT_STEREO_FLOAT32", AL_FORMAT_STEREO_FLOAT32
},
157 { (ALchar
*)"AL_FORMAT_MONO_IMA4", AL_FORMAT_MONO_IMA4
},
158 { (ALchar
*)"AL_FORMAT_STEREO_IMA4", AL_FORMAT_STEREO_IMA4
},
159 { (ALchar
*)"AL_FORMAT_QUAD8", AL_FORMAT_QUAD8
},
160 { (ALchar
*)"AL_FORMAT_QUAD16", AL_FORMAT_QUAD16
},
161 { (ALchar
*)"AL_FORMAT_QUAD32", AL_FORMAT_QUAD32
},
162 { (ALchar
*)"AL_FORMAT_51CHN8", AL_FORMAT_51CHN8
},
163 { (ALchar
*)"AL_FORMAT_51CHN16", AL_FORMAT_51CHN16
},
164 { (ALchar
*)"AL_FORMAT_51CHN32", AL_FORMAT_51CHN32
},
165 { (ALchar
*)"AL_FORMAT_61CHN8", AL_FORMAT_61CHN8
},
166 { (ALchar
*)"AL_FORMAT_61CHN16", AL_FORMAT_61CHN16
},
167 { (ALchar
*)"AL_FORMAT_61CHN32", AL_FORMAT_61CHN32
},
168 { (ALchar
*)"AL_FORMAT_71CHN8", AL_FORMAT_71CHN8
},
169 { (ALchar
*)"AL_FORMAT_71CHN16", AL_FORMAT_71CHN16
},
170 { (ALchar
*)"AL_FORMAT_71CHN32", AL_FORMAT_71CHN32
},
171 { (ALchar
*)"AL_FORMAT_REAR8", AL_FORMAT_REAR8
},
172 { (ALchar
*)"AL_FORMAT_REAR16", AL_FORMAT_REAR16
},
173 { (ALchar
*)"AL_FORMAT_REAR32", AL_FORMAT_REAR32
},
176 { (ALchar
*)"AL_FREQUENCY", AL_FREQUENCY
},
177 { (ALchar
*)"AL_BITS", AL_BITS
},
178 { (ALchar
*)"AL_CHANNELS", AL_CHANNELS
},
179 { (ALchar
*)"AL_SIZE", AL_SIZE
},
181 // Buffer States (not supported yet)
182 { (ALchar
*)"AL_UNUSED", AL_UNUSED
},
183 { (ALchar
*)"AL_PENDING", AL_PENDING
},
184 { (ALchar
*)"AL_PROCESSED", AL_PROCESSED
},
187 { (ALchar
*)"AL_NO_ERROR", AL_NO_ERROR
},
188 { (ALchar
*)"AL_INVALID_NAME", AL_INVALID_NAME
},
189 { (ALchar
*)"AL_INVALID_ENUM", AL_INVALID_ENUM
},
190 { (ALchar
*)"AL_INVALID_VALUE", AL_INVALID_VALUE
},
191 { (ALchar
*)"AL_INVALID_OPERATION", AL_INVALID_OPERATION
},
192 { (ALchar
*)"AL_OUT_OF_MEMORY", AL_OUT_OF_MEMORY
},
195 { (ALchar
*)"AL_VENDOR", AL_VENDOR
},
196 { (ALchar
*)"AL_VERSION", AL_VERSION
},
197 { (ALchar
*)"AL_RENDERER", AL_RENDERER
},
198 { (ALchar
*)"AL_EXTENSIONS", AL_EXTENSIONS
},
201 { (ALchar
*)"AL_DOPPLER_FACTOR", AL_DOPPLER_FACTOR
},
202 { (ALchar
*)"AL_DOPPLER_VELOCITY", AL_DOPPLER_VELOCITY
},
203 { (ALchar
*)"AL_DISTANCE_MODEL", AL_DISTANCE_MODEL
},
204 { (ALchar
*)"AL_SPEED_OF_SOUND", AL_SPEED_OF_SOUND
},
207 { (ALchar
*)"AL_INVERSE_DISTANCE", AL_INVERSE_DISTANCE
},
208 { (ALchar
*)"AL_INVERSE_DISTANCE_CLAMPED", AL_INVERSE_DISTANCE_CLAMPED
},
209 { (ALchar
*)"AL_LINEAR_DISTANCE", AL_LINEAR_DISTANCE
},
210 { (ALchar
*)"AL_LINEAR_DISTANCE_CLAMPED", AL_LINEAR_DISTANCE_CLAMPED
},
211 { (ALchar
*)"AL_EXPONENT_DISTANCE", AL_EXPONENT_DISTANCE
},
212 { (ALchar
*)"AL_EXPONENT_DISTANCE_CLAMPED", AL_EXPONENT_DISTANCE_CLAMPED
},
215 { (ALchar
*)NULL
, (ALenum
) 0 } };
219 ALAPI ALboolean ALAPIENTRY
alIsExtensionPresent(const ALchar
*extName
)
221 ALboolean bIsSupported
= AL_FALSE
;
222 ALCcontext
*pContext
;
227 alSetError(AL_INVALID_VALUE
);
231 pContext
= alcGetCurrentContext();
234 alSetError(AL_INVALID_OPERATION
);
238 ext
= strdup(extName
);
241 *ptr
= (char)toupper(*ptr
);
244 SuspendContext(pContext
);
246 ptr
= pContext
->ExtensionList
;
247 while((ptr
=strstr(ptr
, ext
)) != NULL
)
249 if(ptr
== pContext
->ExtensionList
|| ptr
[-1] == ' ')
251 char e
= ptr
[strlen(ext
)];
252 if(e
== ' ' || e
== 0)
254 bIsSupported
= AL_TRUE
;
261 ProcessContext(pContext
);
268 ALAPI ALvoid
* ALAPIENTRY
alGetProcAddress(const ALchar
*funcName
)
272 while(function
[i
].funcName
&&
273 strcmp((char*)function
[i
].funcName
, (char*)funcName
) != 0)
276 return function
[i
].address
;
279 /* NOTE: This function must be able to run without a context! */
280 ALAPI ALenum ALAPIENTRY
alGetEnumValue(const ALchar
*enumName
)
284 while(enumeration
[i
].enumName
&&
285 strcmp(enumeration
[i
].enumName
, enumName
) != 0)
288 return enumeration
[i
].value
;