Make a function static
[openal-soft.git] / OpenAL32 / alExtension.c
blob0febf22595e941379698e729fd6d717dbe9b70f5
1 /**
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
21 #include "config.h"
23 #include <stdlib.h>
24 #include <string.h>
25 #include <ctype.h>
27 #include "alError.h"
28 #include "alMain.h"
29 #include "alFilter.h"
30 #include "alEffect.h"
31 #include "alAuxEffectSlot.h"
32 #include "alDatabuffer.h"
33 #include "alSource.h"
34 #include "alBuffer.h"
35 #include "AL/al.h"
36 #include "AL/alc.h"
38 typedef struct ALenums {
39 const ALchar *enumName;
40 ALenum value;
41 } ALenums;
44 static const ALenums enumeration[] = {
45 // Types
46 { "AL_INVALID", AL_INVALID },
47 { "AL_NONE", AL_NONE },
48 { "AL_FALSE", AL_FALSE },
49 { "AL_TRUE", AL_TRUE },
51 // Source and Listener Properties
52 { "AL_SOURCE_RELATIVE", AL_SOURCE_RELATIVE },
53 { "AL_CONE_INNER_ANGLE", AL_CONE_INNER_ANGLE },
54 { "AL_CONE_OUTER_ANGLE", AL_CONE_OUTER_ANGLE },
55 { "AL_PITCH", AL_PITCH },
56 { "AL_POSITION", AL_POSITION },
57 { "AL_DIRECTION", AL_DIRECTION },
58 { "AL_VELOCITY", AL_VELOCITY },
59 { "AL_LOOPING", AL_LOOPING },
60 { "AL_BUFFER", AL_BUFFER },
61 { "AL_GAIN", AL_GAIN },
62 { "AL_MIN_GAIN", AL_MIN_GAIN },
63 { "AL_MAX_GAIN", AL_MAX_GAIN },
64 { "AL_ORIENTATION", AL_ORIENTATION },
65 { "AL_REFERENCE_DISTANCE", AL_REFERENCE_DISTANCE },
66 { "AL_ROLLOFF_FACTOR", AL_ROLLOFF_FACTOR },
67 { "AL_CONE_OUTER_GAIN", AL_CONE_OUTER_GAIN },
68 { "AL_MAX_DISTANCE", AL_MAX_DISTANCE },
69 { "AL_SEC_OFFSET", AL_SEC_OFFSET },
70 { "AL_SAMPLE_OFFSET", AL_SAMPLE_OFFSET },
71 { "AL_SAMPLE_RW_OFFSETS_SOFT", AL_SAMPLE_RW_OFFSETS_SOFT },
72 { "AL_BYTE_OFFSET", AL_BYTE_OFFSET },
73 { "AL_BYTE_RW_OFFSETS_SOFT", AL_BYTE_RW_OFFSETS_SOFT },
74 { "AL_SOURCE_TYPE", AL_SOURCE_TYPE },
75 { "AL_STATIC", AL_STATIC },
76 { "AL_STREAMING", AL_STREAMING },
77 { "AL_UNDETERMINED", AL_UNDETERMINED },
78 { "AL_METERS_PER_UNIT", AL_METERS_PER_UNIT },
80 // Source EFX Properties
81 { "AL_DIRECT_FILTER", AL_DIRECT_FILTER },
82 { "AL_AUXILIARY_SEND_FILTER", AL_AUXILIARY_SEND_FILTER },
83 { "AL_AIR_ABSORPTION_FACTOR", AL_AIR_ABSORPTION_FACTOR },
84 { "AL_ROOM_ROLLOFF_FACTOR", AL_ROOM_ROLLOFF_FACTOR },
85 { "AL_CONE_OUTER_GAINHF", AL_CONE_OUTER_GAINHF },
86 { "AL_DIRECT_FILTER_GAINHF_AUTO", AL_DIRECT_FILTER_GAINHF_AUTO },
87 { "AL_AUXILIARY_SEND_FILTER_GAIN_AUTO", AL_AUXILIARY_SEND_FILTER_GAIN_AUTO },
88 { "AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO", AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO},
90 // Source State information
91 { "AL_SOURCE_STATE", AL_SOURCE_STATE },
92 { "AL_INITIAL", AL_INITIAL },
93 { "AL_PLAYING", AL_PLAYING },
94 { "AL_PAUSED", AL_PAUSED },
95 { "AL_STOPPED", AL_STOPPED },
97 // Queue information
98 { "AL_BUFFERS_QUEUED", AL_BUFFERS_QUEUED },
99 { "AL_BUFFERS_PROCESSED", AL_BUFFERS_PROCESSED },
101 // Buffer Formats
102 { "AL_FORMAT_MONO8", AL_FORMAT_MONO8 },
103 { "AL_FORMAT_MONO16", AL_FORMAT_MONO16 },
104 { "AL_FORMAT_MONO_FLOAT32", AL_FORMAT_MONO_FLOAT32 },
105 { "AL_FORMAT_MONO_DOUBLE_EXT", AL_FORMAT_MONO_DOUBLE_EXT },
106 { "AL_FORMAT_STEREO8", AL_FORMAT_STEREO8 },
107 { "AL_FORMAT_STEREO16", AL_FORMAT_STEREO16 },
108 { "AL_FORMAT_STEREO_FLOAT32", AL_FORMAT_STEREO_FLOAT32 },
109 { "AL_FORMAT_STEREO_DOUBLE_EXT", AL_FORMAT_STEREO_DOUBLE_EXT },
110 { "AL_FORMAT_MONO_IMA4", AL_FORMAT_MONO_IMA4 },
111 { "AL_FORMAT_STEREO_IMA4", AL_FORMAT_STEREO_IMA4 },
112 { "AL_FORMAT_QUAD8_LOKI", AL_FORMAT_QUAD8_LOKI },
113 { "AL_FORMAT_QUAD16_LOKI", AL_FORMAT_QUAD16_LOKI },
114 { "AL_FORMAT_QUAD8", AL_FORMAT_QUAD8 },
115 { "AL_FORMAT_QUAD16", AL_FORMAT_QUAD16 },
116 { "AL_FORMAT_QUAD32", AL_FORMAT_QUAD32 },
117 { "AL_FORMAT_51CHN8", AL_FORMAT_51CHN8 },
118 { "AL_FORMAT_51CHN16", AL_FORMAT_51CHN16 },
119 { "AL_FORMAT_51CHN32", AL_FORMAT_51CHN32 },
120 { "AL_FORMAT_61CHN8", AL_FORMAT_61CHN8 },
121 { "AL_FORMAT_61CHN16", AL_FORMAT_61CHN16 },
122 { "AL_FORMAT_61CHN32", AL_FORMAT_61CHN32 },
123 { "AL_FORMAT_71CHN8", AL_FORMAT_71CHN8 },
124 { "AL_FORMAT_71CHN16", AL_FORMAT_71CHN16 },
125 { "AL_FORMAT_71CHN32", AL_FORMAT_71CHN32 },
126 { "AL_FORMAT_REAR8", AL_FORMAT_REAR8 },
127 { "AL_FORMAT_REAR16", AL_FORMAT_REAR16 },
128 { "AL_FORMAT_REAR32", AL_FORMAT_REAR32 },
129 { "AL_FORMAT_MONO_MULAW", AL_FORMAT_MONO_MULAW },
130 { "AL_FORMAT_MONO_MULAW_EXT", AL_FORMAT_MONO_MULAW },
131 { "AL_FORMAT_STEREO_MULAW", AL_FORMAT_STEREO_MULAW },
132 { "AL_FORMAT_STEREO_MULAW_EXT", AL_FORMAT_STEREO_MULAW },
133 { "AL_FORMAT_QUAD_MULAW", AL_FORMAT_QUAD_MULAW },
134 { "AL_FORMAT_51CHN_MULAW", AL_FORMAT_51CHN_MULAW },
135 { "AL_FORMAT_61CHN_MULAW", AL_FORMAT_61CHN_MULAW },
136 { "AL_FORMAT_71CHN_MULAW", AL_FORMAT_71CHN_MULAW },
137 { "AL_FORMAT_REAR_MULAW", AL_FORMAT_REAR_MULAW },
139 // Buffer attributes
140 { "AL_FREQUENCY", AL_FREQUENCY },
141 { "AL_BITS", AL_BITS },
142 { "AL_CHANNELS", AL_CHANNELS },
143 { "AL_SIZE", AL_SIZE },
145 // Buffer States (not supported yet)
146 { "AL_UNUSED", AL_UNUSED },
147 { "AL_PENDING", AL_PENDING },
148 { "AL_PROCESSED", AL_PROCESSED },
150 // AL Error Messages
151 { "AL_NO_ERROR", AL_NO_ERROR },
152 { "AL_INVALID_NAME", AL_INVALID_NAME },
153 { "AL_INVALID_ENUM", AL_INVALID_ENUM },
154 { "AL_INVALID_VALUE", AL_INVALID_VALUE },
155 { "AL_INVALID_OPERATION", AL_INVALID_OPERATION },
156 { "AL_OUT_OF_MEMORY", AL_OUT_OF_MEMORY },
158 // Context strings
159 { "AL_VENDOR", AL_VENDOR },
160 { "AL_VERSION", AL_VERSION },
161 { "AL_RENDERER", AL_RENDERER },
162 { "AL_EXTENSIONS", AL_EXTENSIONS },
164 // Global states
165 { "AL_DOPPLER_FACTOR", AL_DOPPLER_FACTOR },
166 { "AL_DOPPLER_VELOCITY", AL_DOPPLER_VELOCITY },
167 { "AL_DISTANCE_MODEL", AL_DISTANCE_MODEL },
168 { "AL_SPEED_OF_SOUND", AL_SPEED_OF_SOUND },
169 { "AL_SOURCE_DISTANCE_MODEL", AL_SOURCE_DISTANCE_MODEL },
171 // Distance Models
172 { "AL_INVERSE_DISTANCE", AL_INVERSE_DISTANCE },
173 { "AL_INVERSE_DISTANCE_CLAMPED", AL_INVERSE_DISTANCE_CLAMPED },
174 { "AL_LINEAR_DISTANCE", AL_LINEAR_DISTANCE },
175 { "AL_LINEAR_DISTANCE_CLAMPED", AL_LINEAR_DISTANCE_CLAMPED },
176 { "AL_EXPONENT_DISTANCE", AL_EXPONENT_DISTANCE },
177 { "AL_EXPONENT_DISTANCE_CLAMPED", AL_EXPONENT_DISTANCE_CLAMPED },
179 // Filter types
180 { "AL_FILTER_TYPE", AL_FILTER_TYPE },
181 { "AL_FILTER_NULL", AL_FILTER_NULL },
182 { "AL_FILTER_LOWPASS", AL_FILTER_LOWPASS },
183 #if 0
184 { "AL_FILTER_HIGHPASS", AL_FILTER_HIGHPASS },
185 { "AL_FILTER_BANDPASS", AL_FILTER_BANDPASS },
186 #endif
188 // Filter params
189 { "AL_LOWPASS_GAIN", AL_LOWPASS_GAIN },
190 { "AL_LOWPASS_GAINHF", AL_LOWPASS_GAINHF },
192 // Effect types
193 { "AL_EFFECT_TYPE", AL_EFFECT_TYPE },
194 { "AL_EFFECT_NULL", AL_EFFECT_NULL },
195 { "AL_EFFECT_REVERB", AL_EFFECT_REVERB },
196 { "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB },
197 #if 0
198 { "AL_EFFECT_CHORUS", AL_EFFECT_CHORUS },
199 { "AL_EFFECT_DISTORTION", AL_EFFECT_DISTORTION },
200 #endif
201 { "AL_EFFECT_ECHO", AL_EFFECT_ECHO },
202 #if 0
203 { "AL_EFFECT_FLANGER", AL_EFFECT_FLANGER },
204 { "AL_EFFECT_FREQUENCY_SHIFTER", AL_EFFECT_FREQUENCY_SHIFTER },
205 { "AL_EFFECT_VOCAL_MORPHER", AL_EFFECT_VOCAL_MORPHER },
206 { "AL_EFFECT_PITCH_SHIFTER", AL_EFFECT_PITCH_SHIFTER },
207 #endif
208 { "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR },
209 #if 0
210 { "AL_EFFECT_AUTOWAH", AL_EFFECT_AUTOWAH },
211 { "AL_EFFECT_COMPRESSOR", AL_EFFECT_COMPRESSOR },
212 { "AL_EFFECT_EQUALIZER", AL_EFFECT_EQUALIZER },
213 #endif
215 // Reverb params
216 { "AL_REVERB_DENSITY", AL_REVERB_DENSITY },
217 { "AL_REVERB_DIFFUSION", AL_REVERB_DIFFUSION },
218 { "AL_REVERB_GAIN", AL_REVERB_GAIN },
219 { "AL_REVERB_GAINHF", AL_REVERB_GAINHF },
220 { "AL_REVERB_DECAY_TIME", AL_REVERB_DECAY_TIME },
221 { "AL_REVERB_DECAY_HFRATIO", AL_REVERB_DECAY_HFRATIO },
222 { "AL_REVERB_REFLECTIONS_GAIN", AL_REVERB_REFLECTIONS_GAIN },
223 { "AL_REVERB_REFLECTIONS_DELAY", AL_REVERB_REFLECTIONS_DELAY },
224 { "AL_REVERB_LATE_REVERB_GAIN", AL_REVERB_LATE_REVERB_GAIN },
225 { "AL_REVERB_LATE_REVERB_DELAY", AL_REVERB_LATE_REVERB_DELAY },
226 { "AL_REVERB_AIR_ABSORPTION_GAINHF", AL_REVERB_AIR_ABSORPTION_GAINHF },
227 { "AL_REVERB_ROOM_ROLLOFF_FACTOR", AL_REVERB_ROOM_ROLLOFF_FACTOR },
228 { "AL_REVERB_DECAY_HFLIMIT", AL_REVERB_DECAY_HFLIMIT },
230 // EAX Reverb params
231 { "AL_EAXREVERB_DENSITY", AL_EAXREVERB_DENSITY },
232 { "AL_EAXREVERB_DIFFUSION", AL_EAXREVERB_DIFFUSION },
233 { "AL_EAXREVERB_GAIN", AL_EAXREVERB_GAIN },
234 { "AL_EAXREVERB_GAINHF", AL_EAXREVERB_GAINHF },
235 { "AL_EAXREVERB_GAINLF", AL_EAXREVERB_GAINLF },
236 { "AL_EAXREVERB_DECAY_TIME", AL_EAXREVERB_DECAY_TIME },
237 { "AL_EAXREVERB_DECAY_HFRATIO", AL_EAXREVERB_DECAY_HFRATIO },
238 { "AL_EAXREVERB_DECAY_LFRATIO", AL_EAXREVERB_DECAY_LFRATIO },
239 { "AL_EAXREVERB_REFLECTIONS_GAIN", AL_EAXREVERB_REFLECTIONS_GAIN },
240 { "AL_EAXREVERB_REFLECTIONS_DELAY", AL_EAXREVERB_REFLECTIONS_DELAY },
241 { "AL_EAXREVERB_REFLECTIONS_PAN", AL_EAXREVERB_REFLECTIONS_PAN },
242 { "AL_EAXREVERB_LATE_REVERB_GAIN", AL_EAXREVERB_LATE_REVERB_GAIN },
243 { "AL_EAXREVERB_LATE_REVERB_DELAY", AL_EAXREVERB_LATE_REVERB_DELAY },
244 { "AL_EAXREVERB_LATE_REVERB_PAN", AL_EAXREVERB_LATE_REVERB_PAN },
245 { "AL_EAXREVERB_ECHO_TIME", AL_EAXREVERB_ECHO_TIME },
246 { "AL_EAXREVERB_ECHO_DEPTH", AL_EAXREVERB_ECHO_DEPTH },
247 { "AL_EAXREVERB_MODULATION_TIME", AL_EAXREVERB_MODULATION_TIME },
248 { "AL_EAXREVERB_MODULATION_DEPTH", AL_EAXREVERB_MODULATION_DEPTH },
249 { "AL_EAXREVERB_AIR_ABSORPTION_GAINHF", AL_EAXREVERB_AIR_ABSORPTION_GAINHF },
250 { "AL_EAXREVERB_HFREFERENCE", AL_EAXREVERB_HFREFERENCE },
251 { "AL_EAXREVERB_LFREFERENCE", AL_EAXREVERB_LFREFERENCE },
252 { "AL_EAXREVERB_ROOM_ROLLOFF_FACTOR", AL_EAXREVERB_ROOM_ROLLOFF_FACTOR },
253 { "AL_EAXREVERB_DECAY_HFLIMIT", AL_EAXREVERB_DECAY_HFLIMIT },
255 // Echo params
256 { "AL_ECHO_DELAY", AL_ECHO_DELAY },
257 { "AL_ECHO_LRDELAY", AL_ECHO_LRDELAY },
258 { "AL_ECHO_DAMPING", AL_ECHO_DAMPING },
259 { "AL_ECHO_FEEDBACK", AL_ECHO_FEEDBACK },
260 { "AL_ECHO_SPREAD", AL_ECHO_SPREAD },
262 // Ring Modulator params
263 { "AL_RING_MODULATOR_FREQUENCY", AL_RING_MODULATOR_FREQUENCY },
264 { "AL_RING_MODULATOR_HIGHPASS_CUTOFF", AL_RING_MODULATOR_HIGHPASS_CUTOFF },
265 { "AL_RING_MODULATOR_WAVEFORM", AL_RING_MODULATOR_WAVEFORM },
268 // Default
269 { NULL, (ALenum)0 }
274 AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extName)
276 ALboolean bIsSupported = AL_FALSE;
277 ALCcontext *pContext;
278 const char *ptr;
279 size_t len;
281 pContext = GetContextSuspended();
282 if(!pContext) return AL_FALSE;
284 if(!extName)
286 alSetError(pContext, AL_INVALID_VALUE);
287 ProcessContext(pContext);
288 return AL_FALSE;
291 len = strlen(extName);
292 ptr = pContext->ExtensionList;
293 while(ptr && *ptr)
295 if(strncasecmp(ptr, extName, len) == 0 &&
296 (ptr[len] == '\0' || isspace(ptr[len])))
298 bIsSupported = AL_TRUE;
299 break;
301 if((ptr=strchr(ptr, ' ')) != NULL)
303 do {
304 ++ptr;
305 } while(isspace(*ptr));
309 ProcessContext(pContext);
311 return bIsSupported;
315 AL_API ALvoid* AL_APIENTRY alGetProcAddress(const ALchar *funcName)
317 if(!funcName)
318 return NULL;
319 return alcGetProcAddress(NULL, funcName);
322 AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *enumName)
324 ALsizei i = 0;
326 while(enumeration[i].enumName &&
327 strcmp(enumeration[i].enumName, enumName) != 0)
328 i++;
330 return enumeration[i].value;