vbscript: Added interp_xor implementation.
[wine] / dlls / openal32 / openal.c
1 /*
2  * OpenAL32.dll thunk. Wraps Win32 OpenAL function calls around a native
3  * implementation.
4  *
5  * Copyright 2007 Nick Burns (adger44@hotmail.com)
6  * Copyright 2007,2009 Chris Robinson
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #include "config.h"
24
25 #include <stdarg.h>
26 #include <string.h>
27
28 #ifdef HAVE_AL_AL_H
29 #include <AL/al.h>
30 #include <AL/alc.h>
31 #elif defined(HAVE_OPENAL_AL_H)
32 #include <OpenAL/al.h>
33 #include <OpenAL/alc.h>
34 #endif
35
36 #include "windef.h"
37 #include "winbase.h"
38 #include "wine/debug.h"
39
40 WINE_DEFAULT_DEBUG_CHANNEL(openal32);
41
42 static ALCboolean  (ALC_APIENTRY*alcSetThreadContext)(ALCcontext *context);
43 static ALCcontext* (ALC_APIENTRY*alcGetThreadContext)(ALCvoid);
44
45 static ALboolean loaded_procs;
46
47 static ALvoid (AL_APIENTRY*alBufferDataStatic)(const ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq);
48 static ALvoid (AL_APIENTRY*alGenFilters)(ALsizei n, ALuint* filters);
49 static ALvoid (AL_APIENTRY*alDeleteFilters)(ALsizei n, const ALuint* filters);
50 static ALboolean (AL_APIENTRY*alIsFilter)(ALuint fid);
51 static ALvoid (AL_APIENTRY*alFilterf)(ALuint fid, ALenum param, ALfloat value);
52 static ALvoid (AL_APIENTRY*alFilterfv)(ALuint fid, ALenum param, const ALfloat* values);
53 static ALvoid (AL_APIENTRY*alFilteri)(ALuint fid, ALenum param, ALint value);
54 static ALvoid (AL_APIENTRY*alFilteriv)(ALuint fid, ALenum param, const ALint* values);
55 static ALvoid (AL_APIENTRY*alGetFilterf)(ALuint fid, ALenum param, ALfloat* value);
56 static ALvoid (AL_APIENTRY*alGetFilterfv)(ALuint fid, ALenum param, ALfloat* values);
57 static ALvoid (AL_APIENTRY*alGetFilteri)(ALuint fid, ALenum param, ALint* value);
58 static ALvoid (AL_APIENTRY*alGetFilteriv)(ALuint fid, ALenum param, ALint* values);
59 static ALvoid (AL_APIENTRY*alGenEffects)(ALsizei n, ALuint* effects);
60 static ALvoid (AL_APIENTRY*alDeleteEffects)(ALsizei n, const ALuint* effects);
61 static ALboolean (AL_APIENTRY*alIsEffect)(ALuint eid);
62 static ALvoid (AL_APIENTRY*alEffectf)(ALuint eid, ALenum param, ALfloat value);
63 static ALvoid (AL_APIENTRY*alEffectfv)(ALuint eid, ALenum param, const ALfloat* values);
64 static ALvoid (AL_APIENTRY*alEffecti)(ALuint eid, ALenum param, ALint value);
65 static ALvoid (AL_APIENTRY*alEffectiv)(ALuint eid, ALenum param, const ALint* values);
66 static ALvoid (AL_APIENTRY*alGetEffectf)(ALuint eid, ALenum param, ALfloat* value);
67 static ALvoid (AL_APIENTRY*alGetEffectfv)(ALuint eid, ALenum param, ALfloat* values);
68 static ALvoid (AL_APIENTRY*alGetEffecti)(ALuint eid, ALenum param, ALint* value);
69 static ALvoid (AL_APIENTRY*alGetEffectiv)(ALuint eid, ALenum param, ALint* values);
70 static ALvoid (AL_APIENTRY*alGenAuxiliaryEffectSlots)(ALsizei n, ALuint* slots);
71 static ALvoid (AL_APIENTRY*alDeleteAuxiliaryEffectSlots)(ALsizei n, const ALuint* slots);
72 static ALboolean (AL_APIENTRY*alIsAuxiliaryEffectSlot)(ALuint sid);
73 static ALvoid (AL_APIENTRY*alAuxiliaryEffectSlotf)(ALuint sid, ALenum param, ALfloat value);
74 static ALvoid (AL_APIENTRY*alAuxiliaryEffectSlotfv)(ALuint sid, ALenum param, const ALfloat* values);
75 static ALvoid (AL_APIENTRY*alAuxiliaryEffectSloti)(ALuint sid, ALenum param, ALint value);
76 static ALvoid (AL_APIENTRY*alAuxiliaryEffectSlotiv)(ALuint sid, ALenum param, const ALint* values);
77 static ALvoid (AL_APIENTRY*alGetAuxiliaryEffectSlotf)(ALuint sid, ALenum param, ALfloat* value);
78 static ALvoid (AL_APIENTRY*alGetAuxiliaryEffectSlotfv)(ALuint sid, ALenum param, ALfloat* values);
79 static ALvoid (AL_APIENTRY*alGetAuxiliaryEffectSloti)(ALuint sid, ALenum param, ALint* value);
80 static ALvoid (AL_APIENTRY*alGetAuxiliaryEffectSlotiv)(ALuint sid, ALenum param, ALint* values);
81
82 extern ALCvoid* CDECL wine_alcGetProcAddress(ALCdevice *, const ALCchar *);
83 extern ALvoid*  CDECL wine_alGetProcAddress(const ALchar*);
84
85 static CRITICAL_SECTION openal_cs;
86 static CRITICAL_SECTION_DEBUG openal_cs_debug =
87 {
88     0, 0, &openal_cs,
89     {&openal_cs_debug.ProcessLocksList,
90     &openal_cs_debug.ProcessLocksList},
91     0, 0, {(DWORD_PTR)(__FILE__ ": openal_cs")}
92 };
93 static CRITICAL_SECTION openal_cs = {&openal_cs_debug, -1, 0, 0, 0, 0};
94
95 /***********************************************************************
96  *           OpenAL initialisation routine
97  */
98 BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
99 {
100     switch(reason)
101     {
102     case DLL_PROCESS_ATTACH:
103         DisableThreadLibraryCalls(hinst);
104 #define LOADFUNC(x) x = alcGetProcAddress(NULL, #x)
105         LOADFUNC(alcSetThreadContext);
106         LOADFUNC(alcGetThreadContext);
107 #undef LOADFUNC
108         break;
109     }
110
111     return TRUE;
112 }
113
114
115 static void LoadProcs(void)
116 {
117 #define LOADFUNC(x) x = alGetProcAddress(#x)
118     LOADFUNC(alBufferDataStatic);
119     LOADFUNC(alGenFilters);
120     LOADFUNC(alDeleteFilters);
121     LOADFUNC(alIsFilter);
122     LOADFUNC(alFilterf);
123     LOADFUNC(alFilterfv);
124     LOADFUNC(alFilteri);
125     LOADFUNC(alFilteriv);
126     LOADFUNC(alGetFilterf);
127     LOADFUNC(alGetFilterfv);
128     LOADFUNC(alGetFilteri);
129     LOADFUNC(alGetFilteriv);
130     LOADFUNC(alGenEffects);
131     LOADFUNC(alDeleteEffects);
132     LOADFUNC(alIsEffect);
133     LOADFUNC(alEffectf);
134     LOADFUNC(alEffectfv);
135     LOADFUNC(alEffecti);
136     LOADFUNC(alEffectiv);
137     LOADFUNC(alGetEffectf);
138     LOADFUNC(alGetEffectfv);
139     LOADFUNC(alGetEffecti);
140     LOADFUNC(alGetEffectiv);
141     LOADFUNC(alGenAuxiliaryEffectSlots);
142     LOADFUNC(alDeleteAuxiliaryEffectSlots);
143     LOADFUNC(alIsAuxiliaryEffectSlot);
144     LOADFUNC(alAuxiliaryEffectSlotf);
145     LOADFUNC(alAuxiliaryEffectSlotfv);
146     LOADFUNC(alAuxiliaryEffectSloti);
147     LOADFUNC(alAuxiliaryEffectSlotiv);
148     LOADFUNC(alGetAuxiliaryEffectSlotf);
149     LOADFUNC(alGetAuxiliaryEffectSlotfv);
150     LOADFUNC(alGetAuxiliaryEffectSloti);
151     LOADFUNC(alGetAuxiliaryEffectSlotiv);
152 #undef LOADFUNC
153 }
154
155 /***********************************************************************
156  *           OpenAL thunk routines
157  */
158
159 /* OpenAL ALC 1.0 functions */
160 ALCcontext* CDECL wine_alcCreateContext(ALCdevice *device, const ALCint* attrlist)
161 {
162     return alcCreateContext(device, attrlist);
163 }
164
165 ALCboolean CDECL wine_alcMakeContextCurrent(ALCcontext *context)
166 {
167     EnterCriticalSection(&openal_cs);
168     if(alcMakeContextCurrent(context) == ALC_FALSE)
169     {
170         WARN("Failed to make context %p current\n", context);
171         LeaveCriticalSection(&openal_cs);
172         return ALC_FALSE;
173     }
174
175     if(context && !loaded_procs)
176     {
177         loaded_procs = AL_TRUE;
178         LoadProcs();
179     }
180     LeaveCriticalSection(&openal_cs);
181
182     return ALC_TRUE;
183 }
184
185 ALvoid CDECL wine_alcProcessContext(ALCcontext *context)
186 {
187     alcProcessContext(context);
188 }
189
190 ALvoid CDECL wine_alcSuspendContext(ALCcontext *context)
191 {
192     alcSuspendContext(context);
193 }
194
195 ALvoid CDECL wine_alcDestroyContext(ALCcontext *context)
196 {
197     alcDestroyContext(context);
198 }
199
200 ALCcontext* CDECL wine_alcGetCurrentContext(ALCvoid)
201 {
202     return alcGetCurrentContext();
203 }
204
205 ALCdevice* CDECL wine_alcGetContextsDevice(ALCcontext *context)
206 {
207     return alcGetContextsDevice(context);
208 }
209
210 ALCdevice* CDECL wine_alcOpenDevice(const ALCchar *devicename)
211 {
212     if(devicename != NULL && (strcmp(devicename, "DirectSound3D") == 0 ||
213                               strcmp(devicename, "DirectSound") == 0 ||
214                               strcmp(devicename, "Generic Hardware") == 0 ||
215                               strcmp(devicename, "Generic Software") == 0)) {
216         devicename = NULL;
217     }
218     return alcOpenDevice(devicename);
219 }
220
221 ALCboolean CDECL wine_alcCloseDevice(ALCdevice *device)
222 {
223     return alcCloseDevice(device);
224 }
225
226 ALCenum CDECL wine_alcGetError(ALCdevice *device)
227 {
228     return alcGetError(device);
229 }
230
231 ALCboolean CDECL wine_alcIsExtensionPresent(ALCdevice *device, const ALCchar *extname)
232 {
233     return alcIsExtensionPresent(device, extname);
234 }
235
236 ALCenum CDECL wine_alcGetEnumValue(ALCdevice *device, const ALCchar *enumname)
237 {
238     return alcGetEnumValue(device, enumname);
239 }
240
241 const ALCchar* CDECL wine_alcGetString(ALCdevice *device, ALCenum param)
242 {
243     return alcGetString(device, param);
244 }
245
246 ALvoid CDECL wine_alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest)
247 {
248     alcGetIntegerv(device, param, size, dest);
249 }
250
251
252 /* OpenAL 1.0 functions */
253 ALvoid CDECL wine_alEnable(ALenum capability)
254 {
255     alEnable(capability);
256 }
257
258 ALvoid CDECL wine_alDisable(ALenum capability)
259 {
260     alDisable(capability);
261 }
262
263 ALboolean CDECL wine_alIsEnabled(ALenum capability)
264 {
265     return alIsEnabled(capability);
266 }
267
268 const ALchar* CDECL wine_alGetString(ALenum param)
269 {
270     return alGetString(param);
271 }
272
273 ALvoid CDECL wine_alGetBooleanv(ALenum param, ALboolean* data)
274 {
275     alGetBooleanv(param, data);
276 }
277
278 ALvoid CDECL wine_alGetIntegerv(ALenum param, ALint* data)
279 {
280     alGetIntegerv(param, data);
281 }
282
283 ALvoid CDECL wine_alGetFloatv(ALenum param, ALfloat* data)
284 {
285     alGetFloatv(param, data);
286 }
287
288 ALvoid CDECL wine_alGetDoublev(ALenum param, ALdouble* data)
289 {
290     alGetDoublev(param, data);
291 }
292
293 ALboolean CDECL wine_alGetBoolean(ALenum param)
294 {
295     return alGetBoolean(param);
296 }
297
298 ALint CDECL wine_alGetInteger(ALenum param)
299 {
300     return alGetInteger(param);
301 }
302
303 ALfloat CDECL wine_alGetFloat(ALenum param)
304 {
305     return alGetFloat(param);
306 }
307
308 ALdouble CDECL wine_alGetDouble(ALenum param)
309 {
310     return alGetDouble(param);
311 }
312
313 ALenum CDECL wine_alGetError(ALvoid)
314 {
315     return alGetError();
316 }
317
318 ALboolean CDECL wine_alIsExtensionPresent(const ALchar* extname)
319 {
320     return alIsExtensionPresent(extname);
321 }
322
323 ALenum CDECL wine_alGetEnumValue(const ALchar* ename)
324 {
325     return alGetEnumValue(ename);
326 }
327
328 ALvoid CDECL wine_alListenerf(ALenum param, ALfloat value)
329 {
330     alListenerf(param, value);
331 }
332
333 ALvoid CDECL wine_alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)
334 {
335     alListener3f(param, value1, value2, value3);
336 }
337
338 ALvoid CDECL wine_alListenerfv(ALenum param, const ALfloat* values)
339 {
340     alListenerfv(param, values);
341 }
342
343 ALvoid CDECL wine_alListeneri(ALenum param, ALint value)
344 {
345     alListeneri(param, value);
346 }
347
348 ALvoid CDECL wine_alGetListenerf(ALenum param, ALfloat* value)
349 {
350     alGetListenerf(param, value);
351 }
352
353 ALvoid CDECL wine_alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3)
354 {
355     alGetListener3f(param, value1, value2, value3);
356 }
357
358 ALvoid CDECL wine_alGetListenerfv(ALenum param, ALfloat* values)
359 {
360     alGetListenerfv(param, values);
361 }
362
363 ALvoid CDECL wine_alGetListeneri(ALenum param, ALint* value)
364 {
365     alGetListeneri(param, value);
366 }
367
368 ALvoid CDECL wine_alGetListeneriv(ALenum param, ALint* values)
369 {
370     alGetListeneriv(param, values);
371 }
372
373 ALvoid CDECL wine_alGenSources(ALsizei n, ALuint* sources)
374 {
375     alGenSources(n, sources);
376 }
377
378 ALvoid CDECL wine_alDeleteSources(ALsizei n, const ALuint* sources)
379 {
380     alDeleteSources(n, sources);
381 }
382
383 ALboolean CDECL wine_alIsSource(ALuint sid)
384 {
385     return alIsSource(sid);
386 }
387
388 ALvoid CDECL wine_alSourcef(ALuint sid, ALenum param, ALfloat value)
389 {
390     alSourcef(sid, param, value);
391 }
392
393 ALvoid CDECL wine_alSource3f(ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)
394 {
395     alSource3f(sid, param, value1, value2, value3);
396 }
397
398 ALvoid CDECL wine_alSourcefv(ALuint sid, ALenum param, const ALfloat* values)
399 {
400     alSourcefv(sid, param, values);
401 }
402
403 ALvoid CDECL wine_alSourcei(ALuint sid, ALenum param, ALint value)
404 {
405     alSourcei(sid, param, value);
406 }
407
408 ALvoid CDECL wine_alGetSourcef(ALuint sid, ALenum param, ALfloat* value)
409 {
410     alGetSourcef(sid, param, value);
411 }
412
413 ALvoid CDECL wine_alGetSource3f(ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3)
414 {
415     alGetSource3f(sid, param, value1, value2, value3);
416 }
417
418 ALvoid CDECL wine_alGetSourcefv(ALuint sid, ALenum param, ALfloat* values)
419 {
420     alGetSourcefv(sid, param, values);
421 }
422
423 ALvoid CDECL wine_alGetSourcei(ALuint sid, ALenum param, ALint* value)
424 {
425     alGetSourcei(sid, param, value);
426 }
427
428 ALvoid CDECL wine_alGetSourceiv(ALuint sid, ALenum param, ALint* values)
429 {
430     alGetSourceiv(sid, param, values);
431 }
432
433 ALvoid CDECL wine_alSourcePlayv(ALsizei ns, const ALuint *sids)
434 {
435     alSourcePlayv(ns, sids);
436 }
437
438 ALvoid CDECL wine_alSourceStopv(ALsizei ns, const ALuint *sids)
439 {
440     alSourceStopv(ns, sids);
441 }
442
443 ALvoid CDECL wine_alSourceRewindv(ALsizei ns, const ALuint *sids)
444 {
445     alSourceRewindv(ns, sids);
446 }
447
448 ALvoid CDECL wine_alSourcePausev(ALsizei ns, const ALuint *sids)
449 {
450     alSourcePausev(ns, sids);
451 }
452
453 ALvoid CDECL wine_alSourcePlay(ALuint sid)
454 {
455     alSourcePlay(sid);
456 }
457
458 ALvoid CDECL wine_alSourceStop(ALuint sid)
459 {
460     alSourceStop(sid);
461 }
462
463 ALvoid CDECL wine_alSourceRewind(ALuint sid)
464 {
465     alSourceRewind(sid);
466 }
467
468 ALvoid CDECL wine_alSourcePause(ALuint sid)
469 {
470     alSourcePause(sid);
471 }
472
473 ALvoid CDECL wine_alSourceQueueBuffers(ALuint sid, ALsizei numEntries, const ALuint *bids)
474 {
475     alSourceQueueBuffers(sid, numEntries, bids);
476 }
477
478 ALvoid CDECL wine_alSourceUnqueueBuffers(ALuint sid, ALsizei numEntries, ALuint *bids)
479 {
480     alSourceUnqueueBuffers(sid, numEntries, bids);
481 }
482
483 ALvoid CDECL wine_alGenBuffers(ALsizei n, ALuint* buffers)
484 {
485     alGenBuffers(n, buffers);
486 }
487
488 ALvoid CDECL wine_alDeleteBuffers(ALsizei n, const ALuint* buffers)
489 {
490     alDeleteBuffers(n, buffers);
491 }
492
493 ALboolean CDECL wine_alIsBuffer(ALuint bid)
494 {
495     return alIsBuffer(bid);
496 }
497
498 ALvoid CDECL wine_alBufferData(ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq)
499 {
500     alBufferData(bid, format, data, size, freq);
501 }
502
503 static ALvoid CDECL wine_alBufferDataStatic(const ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq)
504 {
505     alBufferDataStatic(bid, format, data, size, freq);
506 }
507
508 ALvoid CDECL wine_alGetBufferf(ALuint bid, ALenum param, ALfloat* value)
509 {
510     alGetBufferf(bid, param, value);
511 }
512
513 ALvoid CDECL wine_alGetBufferfv(ALuint bid, ALenum param, ALfloat* values)
514 {
515     alGetBufferfv(bid, param, values);
516 }
517
518 ALvoid CDECL wine_alGetBufferi(ALuint bid, ALenum param, ALint* value)
519 {
520     alGetBufferi(bid, param, value);
521 }
522
523 ALvoid CDECL wine_alGetBufferiv(ALuint bid, ALenum param, ALint* values)
524 {
525     alGetBufferiv(bid, param, values);
526 }
527
528 ALvoid CDECL wine_alDopplerFactor(ALfloat value)
529 {
530     alDopplerFactor(value);
531 }
532
533 ALvoid CDECL wine_alDopplerVelocity(ALfloat value)
534 {
535     alDopplerVelocity(value);
536 }
537
538 ALvoid CDECL wine_alDistanceModel(ALenum distanceModel)
539 {
540     alDistanceModel(distanceModel);
541 }
542
543
544 /* OpenAL ALC 1.1 functions */
545 ALCdevice* CDECL wine_alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize)
546 {
547      return alcCaptureOpenDevice(devicename, frequency, format, buffersize);
548 }
549
550 ALCboolean CDECL wine_alcCaptureCloseDevice(ALCdevice *device)
551 {
552     return alcCaptureCloseDevice(device);
553 }
554
555 ALCvoid CDECL wine_alcCaptureStart(ALCdevice *device)
556 {
557     alcCaptureStart(device);
558 }
559
560 ALCvoid CDECL wine_alcCaptureStop(ALCdevice *device)
561 {
562     alcCaptureStop(device);
563 }
564
565 ALCvoid CDECL wine_alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples)
566 {
567     alcCaptureSamples(device, buffer, samples);
568 }
569
570 /* OpenAL 1.1 functions */
571 ALvoid CDECL wine_alListener3i(ALenum param, ALint value1, ALint value2, ALint value3)
572 {
573     alListener3i(param, value1, value2, value3);
574 }
575
576 ALvoid CDECL wine_alListeneriv(ALenum param, const ALint* values)
577 {
578     alListeneriv(param, values);
579 }
580
581 ALvoid CDECL wine_alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3)
582 {
583     alGetListener3i(param, value1, value2, value3);
584 }
585
586 ALvoid CDECL wine_alSource3i(ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3)
587 {
588     alSource3i(sid, param, value1, value2, value3);
589 }
590
591 ALvoid CDECL wine_alSourceiv(ALuint sid, ALenum param, const ALint* values)
592 {
593     alSourceiv(sid, param, values);
594 }
595
596 ALvoid CDECL wine_alGetSource3i(ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3)
597 {
598     alGetSource3i(sid, param, value1, value2, value3);
599 }
600
601 ALvoid CDECL wine_alBufferf(ALuint bid, ALenum param, ALfloat value)
602 {
603     alBufferf(bid, param, value);
604 }
605
606 ALvoid CDECL wine_alBuffer3f(ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)
607 {
608     alBuffer3f(bid, param, value1, value2, value3);
609 }
610
611 ALvoid CDECL wine_alBufferfv(ALuint bid, ALenum param, const ALfloat* values)
612 {
613     alBufferfv(bid, param, values);
614 }
615
616 ALvoid CDECL wine_alBufferi(ALuint bid, ALenum param, ALint value)
617 {
618     alBufferi(bid, param, value);
619 }
620
621 ALvoid CDECL wine_alBuffer3i(ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3)
622 {
623     alBuffer3i(bid, param, value1, value2, value3);
624 }
625
626 ALvoid CDECL wine_alBufferiv(ALuint bid, ALenum param, const ALint* values)
627 {
628     alBufferiv(bid, param, values);
629 }
630
631 ALvoid CDECL wine_alGetBuffer3f(ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3)
632 {
633     alGetBuffer3f(bid, param, value1, value2, value3);
634 }
635
636 ALvoid CDECL wine_alGetBuffer3i(ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3)
637 {
638     alGetBuffer3i(bid, param, value1, value2, value3);
639 }
640
641 ALvoid CDECL wine_alSpeedOfSound(ALfloat value)
642 {
643     alSpeedOfSound(value);
644 }
645
646 /* OpenAL EFX extension functions */
647 static ALvoid CDECL wine_alGenFilters(ALsizei n, ALuint* filters)
648 {
649     alGenFilters(n, filters);
650 }
651
652 static ALvoid CDECL wine_alDeleteFilters(ALsizei n, const ALuint* filters)
653 {
654     alDeleteFilters(n, filters);
655 }
656
657 static ALboolean CDECL wine_alIsFilter(ALuint fid)
658 {
659     return alIsFilter(fid);
660 }
661
662 static ALvoid CDECL wine_alFilterf(ALuint fid, ALenum param, ALfloat value)
663 {
664     alFilterf(fid, param, value);
665 }
666
667 static ALvoid CDECL wine_alFilterfv(ALuint fid, ALenum param, const ALfloat* values)
668 {
669     alFilterfv(fid, param, values);
670 }
671
672 static ALvoid CDECL wine_alFilteri(ALuint fid, ALenum param, ALint value)
673 {
674     alFilteri(fid, param, value);
675 }
676
677 static ALvoid CDECL wine_alFilteriv(ALuint fid, ALenum param, const ALint* values)
678 {
679     alFilteriv(fid, param, values);
680 }
681
682 static ALvoid CDECL wine_alGetFilterf(ALuint fid, ALenum param, ALfloat* value)
683 {
684     alGetFilterf(fid, param, value);
685 }
686
687 static ALvoid CDECL wine_alGetFilterfv(ALuint fid, ALenum param, ALfloat* values)
688 {
689     alGetFilterfv(fid, param, values);
690 }
691
692 static ALvoid CDECL wine_alGetFilteri(ALuint fid, ALenum param, ALint* value)
693 {
694     alGetFilteri(fid, param, value);
695 }
696
697 static ALvoid CDECL wine_alGetFilteriv(ALuint fid, ALenum param, ALint* values)
698 {
699     alGetFilteriv(fid, param, values);
700 }
701
702
703 static ALvoid CDECL wine_alGenEffects(ALsizei n, ALuint* effects)
704 {
705     alGenEffects(n, effects);
706 }
707
708 static ALvoid CDECL wine_alDeleteEffects(ALsizei n, const ALuint* effects)
709 {
710     alDeleteEffects(n, effects);
711 }
712
713 static ALboolean CDECL wine_alIsEffect(ALuint eid)
714 {
715     return alIsEffect(eid);
716 }
717
718 static ALvoid CDECL wine_alEffectf(ALuint eid, ALenum param, ALfloat value)
719 {
720     alEffectf(eid, param, value);
721 }
722
723 static ALvoid CDECL wine_alEffectfv(ALuint eid, ALenum param, const ALfloat* values)
724 {
725     alEffectfv(eid, param, values);
726 }
727
728 static ALvoid CDECL wine_alEffecti(ALuint eid, ALenum param, ALint value)
729 {
730     alEffecti(eid, param, value);
731 }
732
733 static ALvoid CDECL wine_alEffectiv(ALuint eid, ALenum param, const ALint* values)
734 {
735     alEffectiv(eid, param, values);
736 }
737
738 static ALvoid CDECL wine_alGetEffectf(ALuint eid, ALenum param, ALfloat* value)
739 {
740     alGetEffectf(eid, param, value);
741 }
742
743 static ALvoid CDECL wine_alGetEffectfv(ALuint eid, ALenum param, ALfloat* values)
744 {
745     alGetEffectfv(eid, param, values);
746 }
747
748 static ALvoid CDECL wine_alGetEffecti(ALuint eid, ALenum param, ALint* value)
749 {
750     alGetEffecti(eid, param, value);
751 }
752
753 static ALvoid CDECL wine_alGetEffectiv(ALuint eid, ALenum param, ALint* values)
754 {
755     alGetEffectiv(eid, param, values);
756 }
757
758
759 static ALvoid CDECL wine_alGenAuxiliaryEffectSlots(ALsizei n, ALuint* slots)
760 {
761     alGenAuxiliaryEffectSlots(n, slots);
762 }
763
764 static ALvoid CDECL wine_alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint* slots)
765 {
766     alDeleteAuxiliaryEffectSlots(n, slots);
767 }
768
769 static ALboolean CDECL wine_alIsAuxiliaryEffectSlot(ALuint sid)
770 {
771     return alIsAuxiliaryEffectSlot(sid);
772 }
773
774 static ALvoid CDECL wine_alAuxiliaryEffectSlotf(ALuint sid, ALenum param, ALfloat value)
775 {
776     alAuxiliaryEffectSlotf(sid, param, value);
777 }
778
779 static ALvoid CDECL wine_alAuxiliaryEffectSlotfv(ALuint sid, ALenum param, const ALfloat* values)
780 {
781     alAuxiliaryEffectSlotfv(sid, param, values);
782 }
783
784 static ALvoid CDECL wine_alAuxiliaryEffectSloti(ALuint sid, ALenum param, ALint value)
785 {
786     alAuxiliaryEffectSloti(sid, param, value);
787 }
788
789 static ALvoid CDECL wine_alAuxiliaryEffectSlotiv(ALuint sid, ALenum param, const ALint* values)
790 {
791     alAuxiliaryEffectSlotiv(sid, param, values);
792 }
793
794 static ALvoid CDECL wine_alGetAuxiliaryEffectSlotf(ALuint sid, ALenum param, ALfloat* value)
795 {
796     alGetAuxiliaryEffectSlotf(sid, param, value);
797 }
798
799 static ALvoid CDECL wine_alGetAuxiliaryEffectSlotfv(ALuint sid, ALenum param, ALfloat* values)
800 {
801     alGetAuxiliaryEffectSlotfv(sid, param, values);
802 }
803
804 static ALvoid CDECL wine_alGetAuxiliaryEffectSloti(ALuint sid, ALenum param, ALint* value)
805 {
806     alGetAuxiliaryEffectSloti(sid, param, value);
807 }
808
809 static ALvoid CDECL wine_alGetAuxiliaryEffectSlotiv(ALuint sid, ALenum param, ALint* values)
810 {
811     alGetAuxiliaryEffectSlotiv(sid, param, values);
812 }
813
814
815 /* Thread-local context functions */
816 static ALCboolean CDECL wine_alcSetThreadContext(ALCcontext *context)
817 {
818     EnterCriticalSection(&openal_cs);
819     if(alcSetThreadContext(context) == ALC_FALSE)
820     {
821         WARN("Failed to make context %p current\n", context);
822         LeaveCriticalSection(&openal_cs);
823         return ALC_FALSE;
824     }
825
826     if(context && !loaded_procs)
827     {
828         loaded_procs = AL_TRUE;
829         LoadProcs();
830     }
831     LeaveCriticalSection(&openal_cs);
832
833     return ALC_TRUE;
834 }
835
836 static ALCcontext* CDECL wine_alcGetThreadContext(ALCvoid)
837 {
838     return alcGetThreadContext();
839 }
840
841 struct FuncList {
842     const char *name;
843     void *proc;
844 };
845
846 static const struct FuncList ALCFuncs[] = {
847     { "alcCreateContext",           wine_alcCreateContext        },
848     { "alcMakeContextCurrent",      wine_alcMakeContextCurrent   },
849     { "alcProcessContext",          wine_alcProcessContext       },
850     { "alcSuspendContext",          wine_alcSuspendContext       },
851     { "alcDestroyContext",          wine_alcDestroyContext       },
852     { "alcGetCurrentContext",       wine_alcGetCurrentContext    },
853     { "alcGetContextsDevice",       wine_alcGetContextsDevice    },
854     { "alcOpenDevice",              wine_alcOpenDevice           },
855     { "alcCloseDevice",             wine_alcCloseDevice          },
856     { "alcGetError",                wine_alcGetError             },
857     { "alcIsExtensionPresent",      wine_alcIsExtensionPresent   },
858     { "alcGetProcAddress",          wine_alcGetProcAddress       },
859     { "alcGetEnumValue",            wine_alcGetEnumValue         },
860     { "alcGetString",               wine_alcGetString            },
861     { "alcGetIntegerv",             wine_alcGetIntegerv          },
862     { "alcCaptureOpenDevice",       wine_alcCaptureOpenDevice    },
863     { "alcCaptureCloseDevice",      wine_alcCaptureCloseDevice   },
864     { "alcCaptureStart",            wine_alcCaptureStart         },
865     { "alcCaptureStop",             wine_alcCaptureStop          },
866     { "alcCaptureSamples",          wine_alcCaptureSamples       },
867     { "alcSetThreadContext",        wine_alcSetThreadContext     },
868     { "alcGetThreadContext",        wine_alcGetThreadContext     },
869     { NULL,                         NULL                         }
870 };
871 static const struct FuncList ALFuncs[] = {
872     { "alEnable",                   wine_alEnable                },
873     { "alDisable",                  wine_alDisable               },
874     { "alIsEnabled",                wine_alIsEnabled             },
875     { "alGetString",                wine_alGetString             },
876     { "alGetBooleanv",              wine_alGetBooleanv           },
877     { "alGetIntegerv",              wine_alGetIntegerv           },
878     { "alGetFloatv",                wine_alGetFloatv             },
879     { "alGetDoublev",               wine_alGetDoublev            },
880     { "alGetBoolean",               wine_alGetBoolean            },
881     { "alGetInteger",               wine_alGetInteger            },
882     { "alGetFloat",                 wine_alGetFloat              },
883     { "alGetDouble",                wine_alGetDouble             },
884     { "alGetError",                 wine_alGetError              },
885     { "alIsExtensionPresent",       wine_alIsExtensionPresent    },
886     { "alGetProcAddress",           wine_alGetProcAddress        },
887     { "alGetEnumValue",             wine_alGetEnumValue          },
888     { "alListenerf",                wine_alListenerf             },
889     { "alListener3f",               wine_alListener3f            },
890     { "alListenerfv",               wine_alListenerfv            },
891     { "alListeneri",                wine_alListeneri             },
892     { "alListener3i",               wine_alListener3i            },
893     { "alListeneriv",               wine_alListeneriv            },
894     { "alGetListenerf",             wine_alGetListenerf          },
895     { "alGetListener3f",            wine_alGetListener3f         },
896     { "alGetListenerfv",            wine_alGetListenerfv         },
897     { "alGetListeneri",             wine_alGetListeneri          },
898     { "alGetListener3i",            wine_alGetListener3i         },
899     { "alGetListeneriv",            wine_alGetListeneriv         },
900     { "alGenSources",               wine_alGenSources            },
901     { "alDeleteSources",            wine_alDeleteSources         },
902     { "alIsSource",                 wine_alIsSource              },
903     { "alSourcef",                  wine_alSourcef               },
904     { "alSource3f",                 wine_alSource3f              },
905     { "alSourcefv",                 wine_alSourcefv              },
906     { "alSourcei",                  wine_alSourcei               },
907     { "alSource3i",                 wine_alSource3i              },
908     { "alSourceiv",                 wine_alSourceiv              },
909     { "alGetSourcef",               wine_alGetSourcef            },
910     { "alGetSource3f",              wine_alGetSource3f           },
911     { "alGetSourcefv",              wine_alGetSourcefv           },
912     { "alGetSourcei",               wine_alGetSourcei            },
913     { "alGetSource3i",              wine_alGetSource3i           },
914     { "alGetSourceiv",              wine_alGetSourceiv           },
915     { "alSourcePlayv",              wine_alSourcePlayv           },
916     { "alSourceStopv",              wine_alSourceStopv           },
917     { "alSourceRewindv",            wine_alSourceRewindv         },
918     { "alSourcePausev",             wine_alSourcePausev          },
919     { "alSourcePlay",               wine_alSourcePlay            },
920     { "alSourceStop",               wine_alSourceStop            },
921     { "alSourceRewind",             wine_alSourceRewind          },
922     { "alSourcePause",              wine_alSourcePause           },
923     { "alSourceQueueBuffers",       wine_alSourceQueueBuffers    },
924     { "alSourceUnqueueBuffers",     wine_alSourceUnqueueBuffers  },
925     { "alGenBuffers",               wine_alGenBuffers            },
926     { "alDeleteBuffers",            wine_alDeleteBuffers         },
927     { "alIsBuffer",                 wine_alIsBuffer              },
928     { "alBufferData",               wine_alBufferData            },
929     { "alBufferDataStatic",         wine_alBufferDataStatic      },
930     { "alBufferf",                  wine_alBufferf               },
931     { "alBuffer3f",                 wine_alBuffer3f              },
932     { "alBufferfv",                 wine_alBufferfv              },
933     { "alBufferi",                  wine_alBufferi               },
934     { "alBuffer3i",                 wine_alBuffer3i              },
935     { "alBufferiv",                 wine_alBufferiv              },
936     { "alGetBufferf",               wine_alGetBufferf            },
937     { "alGetBuffer3f",              wine_alGetBuffer3f           },
938     { "alGetBufferfv",              wine_alGetBufferfv           },
939     { "alGetBufferi",               wine_alGetBufferi            },
940     { "alGetBuffer3i",              wine_alGetBuffer3i           },
941     { "alGetBufferiv",              wine_alGetBufferiv           },
942     { "alDopplerFactor",            wine_alDopplerFactor         },
943     { "alDopplerVelocity",          wine_alDopplerVelocity       },
944     { "alSpeedOfSound",             wine_alSpeedOfSound          },
945     { "alDistanceModel",            wine_alDistanceModel         },
946
947     { "alGenFilters",               wine_alGenFilters            },
948     { "alDeleteFilters",            wine_alDeleteFilters         },
949     { "alIsFilter",                 wine_alIsFilter              },
950     { "alFilterf",                  wine_alFilterf               },
951     { "alFilterfv",                 wine_alFilterfv              },
952     { "alFilteri",                  wine_alFilteri               },
953     { "alFilteriv",                 wine_alFilteriv              },
954     { "alGetFilterf",               wine_alGetFilterf            },
955     { "alGetFilterfv",              wine_alGetFilterfv           },
956     { "alGetFilteri",               wine_alGetFilteri            },
957     { "alGetFilteriv",              wine_alGetFilteriv           },
958
959     { "alGenEffects",               wine_alGenEffects            },
960     { "alDeleteEffects",            wine_alDeleteEffects         },
961     { "alIsEffect",                 wine_alIsEffect              },
962     { "alEffectf",                  wine_alEffectf               },
963     { "alEffectfv",                 wine_alEffectfv              },
964     { "alEffecti",                  wine_alEffecti               },
965     { "alEffectiv",                 wine_alEffectiv              },
966     { "alGetEffectf",               wine_alGetEffectf            },
967     { "alGetEffectfv",              wine_alGetEffectfv           },
968     { "alGetEffecti",               wine_alGetEffecti            },
969     { "alGetEffectiv",              wine_alGetEffectiv           },
970
971     { "alGenAuxiliaryEffectSlots",  wine_alGenAuxiliaryEffectSlots},
972     { "alDeleteAuxiliaryEffectSlots",wine_alDeleteAuxiliaryEffectSlots},
973     { "alIsAuxiliaryEffectSlot",    wine_alIsAuxiliaryEffectSlot },
974     { "alAuxiliaryEffectSlotf",     wine_alAuxiliaryEffectSlotf  },
975     { "alAuxiliaryEffectSlotfv",    wine_alAuxiliaryEffectSlotfv },
976     { "alAuxiliaryEffectSloti",     wine_alAuxiliaryEffectSloti  },
977     { "alAuxiliaryEffectSlotiv",    wine_alAuxiliaryEffectSlotiv },
978     { "alGetAuxiliaryEffectSlotf",  wine_alGetAuxiliaryEffectSlotf},
979     { "alGetAuxiliaryEffectSlotfv", wine_alGetAuxiliaryEffectSlotfv},
980     { "alGetAuxiliaryEffectSloti",  wine_alGetAuxiliaryEffectSloti},
981     { "alGetAuxiliaryEffectSlotiv", wine_alGetAuxiliaryEffectSlotiv},
982
983     { NULL,                         NULL                         }
984 };
985
986
987 ALCvoid* CDECL wine_alcGetProcAddress(ALCdevice *device, const ALCchar *funcname)
988 {
989     void *proc;
990     int i;
991
992     /* Make sure the host implementation has the requested function */
993     proc = alcGetProcAddress(device, funcname);
994     if(!proc)
995         return NULL;
996
997     for(i = 0;ALCFuncs[i].name;i++)
998     {
999         if(strcmp(funcname, ALCFuncs[i].name) == 0)
1000             return ALCFuncs[i].proc;
1001     }
1002     FIXME("Could not find function in list: %s\n", funcname);
1003     return NULL;
1004 }
1005
1006
1007 ALvoid* CDECL wine_alGetProcAddress(const ALchar* funcname)
1008 {
1009     void *proc;
1010     int i;
1011
1012     /* Make sure the host implementation has the requested function. This will
1013      * also set the last AL error properly if the function should not be
1014      * returned (eg. no current context). */
1015     proc = alGetProcAddress(funcname);
1016     if(!proc)
1017         return NULL;
1018
1019     for(i = 0;ALFuncs[i].name;i++)
1020     {
1021         if(strcmp(funcname, ALFuncs[i].name) == 0)
1022             return ALFuncs[i].proc;
1023     }
1024     FIXME("Could not find function in list: %s\n", funcname);
1025     return NULL;
1026 }