view OpenAL32/alExtension.c @ 17:fdf84bc57e67

forgetting send.c
author Robert McIntyre <rlm@mit.edu>
date Thu, 03 Nov 2011 12:12:05 -0700
parents f9476ff7637e
children
line wrap: on
line source
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.
8 *
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.
13 *
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
19 */
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 "alSource.h"
33 #include "alBuffer.h"
34 #include "AL/al.h"
35 #include "AL/alc.h"
37 typedef struct ALenums {
38 const ALchar *enumName;
39 ALenum value;
40 } ALenums;
43 static const ALenums enumeration[] = {
44 // Types
45 { "AL_INVALID", AL_INVALID },
46 { "AL_NONE", AL_NONE },
47 { "AL_FALSE", AL_FALSE },
48 { "AL_TRUE", AL_TRUE },
50 // Source and Listener Properties
51 { "AL_SOURCE_RELATIVE", AL_SOURCE_RELATIVE },
52 { "AL_CONE_INNER_ANGLE", AL_CONE_INNER_ANGLE },
53 { "AL_CONE_OUTER_ANGLE", AL_CONE_OUTER_ANGLE },
54 { "AL_PITCH", AL_PITCH },
55 { "AL_POSITION", AL_POSITION },
56 { "AL_DIRECTION", AL_DIRECTION },
57 { "AL_VELOCITY", AL_VELOCITY },
58 { "AL_LOOPING", AL_LOOPING },
59 { "AL_BUFFER", AL_BUFFER },
60 { "AL_GAIN", AL_GAIN },
61 { "AL_MIN_GAIN", AL_MIN_GAIN },
62 { "AL_MAX_GAIN", AL_MAX_GAIN },
63 { "AL_ORIENTATION", AL_ORIENTATION },
64 { "AL_REFERENCE_DISTANCE", AL_REFERENCE_DISTANCE },
65 { "AL_ROLLOFF_FACTOR", AL_ROLLOFF_FACTOR },
66 { "AL_CONE_OUTER_GAIN", AL_CONE_OUTER_GAIN },
67 { "AL_MAX_DISTANCE", AL_MAX_DISTANCE },
68 { "AL_SEC_OFFSET", AL_SEC_OFFSET },
69 { "AL_SAMPLE_OFFSET", AL_SAMPLE_OFFSET },
70 { "AL_SAMPLE_RW_OFFSETS_SOFT", AL_SAMPLE_RW_OFFSETS_SOFT },
71 { "AL_BYTE_OFFSET", AL_BYTE_OFFSET },
72 { "AL_BYTE_RW_OFFSETS_SOFT", AL_BYTE_RW_OFFSETS_SOFT },
73 { "AL_SOURCE_TYPE", AL_SOURCE_TYPE },
74 { "AL_STATIC", AL_STATIC },
75 { "AL_STREAMING", AL_STREAMING },
76 { "AL_UNDETERMINED", AL_UNDETERMINED },
77 { "AL_METERS_PER_UNIT", AL_METERS_PER_UNIT },
78 { "AL_VIRTUAL_CHANNELS_SOFT", AL_VIRTUAL_CHANNELS_SOFT },
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 // Internal Buffer Formats
140 { "AL_MONO8", AL_MONO8 },
141 { "AL_MONO16", AL_MONO16 },
142 { "AL_MONO32F", AL_MONO32F },
143 { "AL_STEREO8", AL_STEREO8 },
144 { "AL_STEREO16", AL_STEREO16 },
145 { "AL_STEREO32F", AL_STEREO32F },
146 { "AL_QUAD8", AL_QUAD8 },
147 { "AL_QUAD16", AL_QUAD16 },
148 { "AL_QUAD32F", AL_QUAD32F },
149 { "AL_REAR8", AL_REAR8 },
150 { "AL_REAR16", AL_REAR16 },
151 { "AL_REAR32F", AL_REAR32F },
152 { "AL_5POINT1_8", AL_5POINT1_8 },
153 { "AL_5POINT1_16", AL_5POINT1_16 },
154 { "AL_5POINT1_32F", AL_5POINT1_32F },
155 { "AL_6POINT1_8", AL_6POINT1_8 },
156 { "AL_6POINT1_16", AL_6POINT1_16 },
157 { "AL_6POINT1_32F", AL_6POINT1_32F },
158 { "AL_7POINT1_8", AL_7POINT1_8 },
159 { "AL_7POINT1_16", AL_7POINT1_16 },
160 { "AL_7POINT1_32F", AL_7POINT1_32F },
162 // Buffer Channel Configurations
163 { "AL_MONO", AL_MONO },
164 { "AL_STEREO", AL_STEREO },
165 { "AL_QUAD", AL_QUAD },
166 { "AL_REAR", AL_REAR },
167 { "AL_5POINT1", AL_5POINT1 },
168 { "AL_6POINT1", AL_6POINT1 },
169 { "AL_7POINT1", AL_7POINT1 },
171 // Buffer Sample Types
172 { "AL_BYTE", AL_BYTE },
173 { "AL_UNSIGNED_BYTE", AL_UNSIGNED_BYTE },
174 { "AL_SHORT", AL_SHORT },
175 { "AL_UNSIGNED_SHORT", AL_UNSIGNED_SHORT },
176 { "AL_INT", AL_INT },
177 { "AL_UNSIGNED_INT", AL_UNSIGNED_INT },
178 { "AL_FLOAT", AL_FLOAT },
179 { "AL_DOUBLE", AL_DOUBLE },
180 { "AL_MULAW", AL_MULAW },
181 { "AL_IMA4", AL_IMA4 },
182 { "AL_BYTE3", AL_BYTE3 },
183 { "AL_UNSIGNED_BYTE3", AL_UNSIGNED_BYTE3 },
185 // Buffer attributes
186 { "AL_FREQUENCY", AL_FREQUENCY },
187 { "AL_BITS", AL_BITS },
188 { "AL_CHANNELS", AL_CHANNELS },
189 { "AL_SIZE", AL_SIZE },
191 // Buffer States (not supported yet)
192 { "AL_UNUSED", AL_UNUSED },
193 { "AL_PENDING", AL_PENDING },
194 { "AL_PROCESSED", AL_PROCESSED },
196 // AL Error Messages
197 { "AL_NO_ERROR", AL_NO_ERROR },
198 { "AL_INVALID_NAME", AL_INVALID_NAME },
199 { "AL_INVALID_ENUM", AL_INVALID_ENUM },
200 { "AL_INVALID_VALUE", AL_INVALID_VALUE },
201 { "AL_INVALID_OPERATION", AL_INVALID_OPERATION },
202 { "AL_OUT_OF_MEMORY", AL_OUT_OF_MEMORY },
204 // Context strings
205 { "AL_VENDOR", AL_VENDOR },
206 { "AL_VERSION", AL_VERSION },
207 { "AL_RENDERER", AL_RENDERER },
208 { "AL_EXTENSIONS", AL_EXTENSIONS },
210 // Global states
211 { "AL_DOPPLER_FACTOR", AL_DOPPLER_FACTOR },
212 { "AL_DOPPLER_VELOCITY", AL_DOPPLER_VELOCITY },
213 { "AL_DISTANCE_MODEL", AL_DISTANCE_MODEL },
214 { "AL_SPEED_OF_SOUND", AL_SPEED_OF_SOUND },
215 { "AL_SOURCE_DISTANCE_MODEL", AL_SOURCE_DISTANCE_MODEL },
216 { "AL_DEFERRED_UPDATES_SOFT", AL_DEFERRED_UPDATES_SOFT },
218 // Distance Models
219 { "AL_INVERSE_DISTANCE", AL_INVERSE_DISTANCE },
220 { "AL_INVERSE_DISTANCE_CLAMPED", AL_INVERSE_DISTANCE_CLAMPED },
221 { "AL_LINEAR_DISTANCE", AL_LINEAR_DISTANCE },
222 { "AL_LINEAR_DISTANCE_CLAMPED", AL_LINEAR_DISTANCE_CLAMPED },
223 { "AL_EXPONENT_DISTANCE", AL_EXPONENT_DISTANCE },
224 { "AL_EXPONENT_DISTANCE_CLAMPED", AL_EXPONENT_DISTANCE_CLAMPED },
226 // Filter types
227 { "AL_FILTER_TYPE", AL_FILTER_TYPE },
228 { "AL_FILTER_NULL", AL_FILTER_NULL },
229 { "AL_FILTER_LOWPASS", AL_FILTER_LOWPASS },
230 #if 0
231 { "AL_FILTER_HIGHPASS", AL_FILTER_HIGHPASS },
232 { "AL_FILTER_BANDPASS", AL_FILTER_BANDPASS },
233 #endif
235 // Filter params
236 { "AL_LOWPASS_GAIN", AL_LOWPASS_GAIN },
237 { "AL_LOWPASS_GAINHF", AL_LOWPASS_GAINHF },
239 // Effect types
240 { "AL_EFFECT_TYPE", AL_EFFECT_TYPE },
241 { "AL_EFFECT_NULL", AL_EFFECT_NULL },
242 { "AL_EFFECT_REVERB", AL_EFFECT_REVERB },
243 { "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB },
244 #if 0
245 { "AL_EFFECT_CHORUS", AL_EFFECT_CHORUS },
246 { "AL_EFFECT_DISTORTION", AL_EFFECT_DISTORTION },
247 #endif
248 { "AL_EFFECT_ECHO", AL_EFFECT_ECHO },
249 #if 0
250 { "AL_EFFECT_FLANGER", AL_EFFECT_FLANGER },
251 { "AL_EFFECT_FREQUENCY_SHIFTER", AL_EFFECT_FREQUENCY_SHIFTER },
252 { "AL_EFFECT_VOCAL_MORPHER", AL_EFFECT_VOCAL_MORPHER },
253 { "AL_EFFECT_PITCH_SHIFTER", AL_EFFECT_PITCH_SHIFTER },
254 #endif
255 { "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR },
256 #if 0
257 { "AL_EFFECT_AUTOWAH", AL_EFFECT_AUTOWAH },
258 { "AL_EFFECT_COMPRESSOR", AL_EFFECT_COMPRESSOR },
259 { "AL_EFFECT_EQUALIZER", AL_EFFECT_EQUALIZER },
260 #endif
261 { "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT",AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT},
262 { "AL_EFFECT_DEDICATED_DIALOGUE", AL_EFFECT_DEDICATED_DIALOGUE },
264 // Reverb params
265 { "AL_REVERB_DENSITY", AL_REVERB_DENSITY },
266 { "AL_REVERB_DIFFUSION", AL_REVERB_DIFFUSION },
267 { "AL_REVERB_GAIN", AL_REVERB_GAIN },
268 { "AL_REVERB_GAINHF", AL_REVERB_GAINHF },
269 { "AL_REVERB_DECAY_TIME", AL_REVERB_DECAY_TIME },
270 { "AL_REVERB_DECAY_HFRATIO", AL_REVERB_DECAY_HFRATIO },
271 { "AL_REVERB_REFLECTIONS_GAIN", AL_REVERB_REFLECTIONS_GAIN },
272 { "AL_REVERB_REFLECTIONS_DELAY", AL_REVERB_REFLECTIONS_DELAY },
273 { "AL_REVERB_LATE_REVERB_GAIN", AL_REVERB_LATE_REVERB_GAIN },
274 { "AL_REVERB_LATE_REVERB_DELAY", AL_REVERB_LATE_REVERB_DELAY },
275 { "AL_REVERB_AIR_ABSORPTION_GAINHF", AL_REVERB_AIR_ABSORPTION_GAINHF },
276 { "AL_REVERB_ROOM_ROLLOFF_FACTOR", AL_REVERB_ROOM_ROLLOFF_FACTOR },
277 { "AL_REVERB_DECAY_HFLIMIT", AL_REVERB_DECAY_HFLIMIT },
279 // EAX Reverb params
280 { "AL_EAXREVERB_DENSITY", AL_EAXREVERB_DENSITY },
281 { "AL_EAXREVERB_DIFFUSION", AL_EAXREVERB_DIFFUSION },
282 { "AL_EAXREVERB_GAIN", AL_EAXREVERB_GAIN },
283 { "AL_EAXREVERB_GAINHF", AL_EAXREVERB_GAINHF },
284 { "AL_EAXREVERB_GAINLF", AL_EAXREVERB_GAINLF },
285 { "AL_EAXREVERB_DECAY_TIME", AL_EAXREVERB_DECAY_TIME },
286 { "AL_EAXREVERB_DECAY_HFRATIO", AL_EAXREVERB_DECAY_HFRATIO },
287 { "AL_EAXREVERB_DECAY_LFRATIO", AL_EAXREVERB_DECAY_LFRATIO },
288 { "AL_EAXREVERB_REFLECTIONS_GAIN", AL_EAXREVERB_REFLECTIONS_GAIN },
289 { "AL_EAXREVERB_REFLECTIONS_DELAY", AL_EAXREVERB_REFLECTIONS_DELAY },
290 { "AL_EAXREVERB_REFLECTIONS_PAN", AL_EAXREVERB_REFLECTIONS_PAN },
291 { "AL_EAXREVERB_LATE_REVERB_GAIN", AL_EAXREVERB_LATE_REVERB_GAIN },
292 { "AL_EAXREVERB_LATE_REVERB_DELAY", AL_EAXREVERB_LATE_REVERB_DELAY },
293 { "AL_EAXREVERB_LATE_REVERB_PAN", AL_EAXREVERB_LATE_REVERB_PAN },
294 { "AL_EAXREVERB_ECHO_TIME", AL_EAXREVERB_ECHO_TIME },
295 { "AL_EAXREVERB_ECHO_DEPTH", AL_EAXREVERB_ECHO_DEPTH },
296 { "AL_EAXREVERB_MODULATION_TIME", AL_EAXREVERB_MODULATION_TIME },
297 { "AL_EAXREVERB_MODULATION_DEPTH", AL_EAXREVERB_MODULATION_DEPTH },
298 { "AL_EAXREVERB_AIR_ABSORPTION_GAINHF", AL_EAXREVERB_AIR_ABSORPTION_GAINHF },
299 { "AL_EAXREVERB_HFREFERENCE", AL_EAXREVERB_HFREFERENCE },
300 { "AL_EAXREVERB_LFREFERENCE", AL_EAXREVERB_LFREFERENCE },
301 { "AL_EAXREVERB_ROOM_ROLLOFF_FACTOR", AL_EAXREVERB_ROOM_ROLLOFF_FACTOR },
302 { "AL_EAXREVERB_DECAY_HFLIMIT", AL_EAXREVERB_DECAY_HFLIMIT },
304 // Echo params
305 { "AL_ECHO_DELAY", AL_ECHO_DELAY },
306 { "AL_ECHO_LRDELAY", AL_ECHO_LRDELAY },
307 { "AL_ECHO_DAMPING", AL_ECHO_DAMPING },
308 { "AL_ECHO_FEEDBACK", AL_ECHO_FEEDBACK },
309 { "AL_ECHO_SPREAD", AL_ECHO_SPREAD },
311 // Ring Modulator params
312 { "AL_RING_MODULATOR_FREQUENCY", AL_RING_MODULATOR_FREQUENCY },
313 { "AL_RING_MODULATOR_HIGHPASS_CUTOFF", AL_RING_MODULATOR_HIGHPASS_CUTOFF },
314 { "AL_RING_MODULATOR_WAVEFORM", AL_RING_MODULATOR_WAVEFORM },
316 // Dedicated Dialogue/LFE params
317 { "AL_DEDICATED_GAIN", AL_DEDICATED_GAIN },
320 // Default
321 { NULL, (ALenum)0 }
322 };
325 const struct EffectList EffectList[] = {
326 { "eaxreverb", EAXREVERB, "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB },
327 { "reverb", REVERB, "AL_EFFECT_REVERB", AL_EFFECT_REVERB },
328 { "echo", ECHO, "AL_EFFECT_ECHO", AL_EFFECT_ECHO },
329 { "modulator", MODULATOR, "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR },
330 { "dedicated", DEDICATED, "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT", AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT },
331 { "dedicated", DEDICATED, "AL_EFFECT_DEDICATED_DIALOGUE", AL_EFFECT_DEDICATED_DIALOGUE },
332 { NULL, 0, NULL, (ALenum)0 }
333 };
336 AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extName)
337 {
338 ALboolean bIsSupported = AL_FALSE;
339 ALCcontext *Context;
340 const char *ptr;
341 size_t len;
343 Context = GetLockedContext();
344 if(!Context) return AL_FALSE;
346 if(!extName)
347 alSetError(Context, AL_INVALID_VALUE);
348 else
349 {
350 len = strlen(extName);
351 ptr = Context->ExtensionList;
352 while(ptr && *ptr)
353 {
354 if(strncasecmp(ptr, extName, len) == 0 &&
355 (ptr[len] == '\0' || isspace(ptr[len])))
356 {
357 bIsSupported = AL_TRUE;
358 break;
359 }
360 if((ptr=strchr(ptr, ' ')) != NULL)
361 {
362 do {
363 ++ptr;
364 } while(isspace(*ptr));
365 }
366 }
367 }
369 UnlockContext(Context);
371 return bIsSupported;
372 }
375 AL_API ALvoid* AL_APIENTRY alGetProcAddress(const ALchar *funcName)
376 {
377 if(!funcName)
378 return NULL;
379 return alcGetProcAddress(NULL, funcName);
380 }
382 AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *enumName)
383 {
384 ALsizei i;
386 for(i = 0;EffectList[i].ename;i++)
387 {
388 if(DisabledEffects[EffectList[i].type] &&
389 strcmp(EffectList[i].ename, enumName) == 0)
390 return (ALenum)0;
391 }
393 i = 0;
394 while(enumeration[i].enumName &&
395 strcmp(enumeration[i].enumName, enumName) != 0)
396 i++;
398 return enumeration[i].value;
399 }