openal.c 31.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
 * OpenAL32.dll thunk. Wraps Win32 OpenAL function calls around a native
 * implementation.
 *
 * Copyright 2007 Nick Burns (adger44@hotmail.com)
 * Copyright 2007,2009 Chris Robinson
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include "config.h"

#include <stdarg.h>
#include <string.h>

28 29 30
#ifdef HAVE_AL_AL_H
#include <AL/al.h>
#include <AL/alc.h>
31 32 33
#elif defined(HAVE_OPENAL_AL_H)
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
34 35
#endif

36 37 38 39
#include "windef.h"
#include "winbase.h"
#include "wine/debug.h"

40 41
WINE_DEFAULT_DEBUG_CHANNEL(openal32);

42 43 44
static ALCboolean  (ALC_APIENTRY*alcSetThreadContext)(ALCcontext *context);
static ALCcontext* (ALC_APIENTRY*alcGetThreadContext)(ALCvoid);

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
static ALboolean loaded_procs;

static ALvoid (AL_APIENTRY*alBufferDataStatic)(const ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq);
static ALvoid (AL_APIENTRY*alGenFilters)(ALsizei n, ALuint* filters);
static ALvoid (AL_APIENTRY*alDeleteFilters)(ALsizei n, const ALuint* filters);
static ALboolean (AL_APIENTRY*alIsFilter)(ALuint fid);
static ALvoid (AL_APIENTRY*alFilterf)(ALuint fid, ALenum param, ALfloat value);
static ALvoid (AL_APIENTRY*alFilterfv)(ALuint fid, ALenum param, const ALfloat* values);
static ALvoid (AL_APIENTRY*alFilteri)(ALuint fid, ALenum param, ALint value);
static ALvoid (AL_APIENTRY*alFilteriv)(ALuint fid, ALenum param, const ALint* values);
static ALvoid (AL_APIENTRY*alGetFilterf)(ALuint fid, ALenum param, ALfloat* value);
static ALvoid (AL_APIENTRY*alGetFilterfv)(ALuint fid, ALenum param, ALfloat* values);
static ALvoid (AL_APIENTRY*alGetFilteri)(ALuint fid, ALenum param, ALint* value);
static ALvoid (AL_APIENTRY*alGetFilteriv)(ALuint fid, ALenum param, ALint* values);
static ALvoid (AL_APIENTRY*alGenEffects)(ALsizei n, ALuint* effects);
static ALvoid (AL_APIENTRY*alDeleteEffects)(ALsizei n, const ALuint* effects);
static ALboolean (AL_APIENTRY*alIsEffect)(ALuint eid);
static ALvoid (AL_APIENTRY*alEffectf)(ALuint eid, ALenum param, ALfloat value);
static ALvoid (AL_APIENTRY*alEffectfv)(ALuint eid, ALenum param, const ALfloat* values);
static ALvoid (AL_APIENTRY*alEffecti)(ALuint eid, ALenum param, ALint value);
static ALvoid (AL_APIENTRY*alEffectiv)(ALuint eid, ALenum param, const ALint* values);
static ALvoid (AL_APIENTRY*alGetEffectf)(ALuint eid, ALenum param, ALfloat* value);
static ALvoid (AL_APIENTRY*alGetEffectfv)(ALuint eid, ALenum param, ALfloat* values);
static ALvoid (AL_APIENTRY*alGetEffecti)(ALuint eid, ALenum param, ALint* value);
static ALvoid (AL_APIENTRY*alGetEffectiv)(ALuint eid, ALenum param, ALint* values);
static ALvoid (AL_APIENTRY*alGenAuxiliaryEffectSlots)(ALsizei n, ALuint* slots);
static ALvoid (AL_APIENTRY*alDeleteAuxiliaryEffectSlots)(ALsizei n, const ALuint* slots);
static ALboolean (AL_APIENTRY*alIsAuxiliaryEffectSlot)(ALuint sid);
static ALvoid (AL_APIENTRY*alAuxiliaryEffectSlotf)(ALuint sid, ALenum param, ALfloat value);
static ALvoid (AL_APIENTRY*alAuxiliaryEffectSlotfv)(ALuint sid, ALenum param, const ALfloat* values);
static ALvoid (AL_APIENTRY*alAuxiliaryEffectSloti)(ALuint sid, ALenum param, ALint value);
static ALvoid (AL_APIENTRY*alAuxiliaryEffectSlotiv)(ALuint sid, ALenum param, const ALint* values);
static ALvoid (AL_APIENTRY*alGetAuxiliaryEffectSlotf)(ALuint sid, ALenum param, ALfloat* value);
static ALvoid (AL_APIENTRY*alGetAuxiliaryEffectSlotfv)(ALuint sid, ALenum param, ALfloat* values);
static ALvoid (AL_APIENTRY*alGetAuxiliaryEffectSloti)(ALuint sid, ALenum param, ALint* value);
static ALvoid (AL_APIENTRY*alGetAuxiliaryEffectSlotiv)(ALuint sid, ALenum param, ALint* values);
81

82 83
extern ALCvoid* CDECL wine_alcGetProcAddress(ALCdevice *, const ALCchar *);
extern ALvoid*  CDECL wine_alGetProcAddress(const ALchar*);
84

85
static CRITICAL_SECTION openal_cs;
86 87 88 89 90 91 92
static CRITICAL_SECTION_DEBUG openal_cs_debug =
{
    0, 0, &openal_cs,
    {&openal_cs_debug.ProcessLocksList,
    &openal_cs_debug.ProcessLocksList},
    0, 0, {(DWORD_PTR)(__FILE__ ": openal_cs")}
};
93
static CRITICAL_SECTION openal_cs = {&openal_cs_debug, -1, 0, 0, 0, 0};
94

95 96 97 98 99 100 101
/***********************************************************************
 *           OpenAL initialisation routine
 */
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
{
    switch(reason)
    {
102 103
    case DLL_WINE_PREATTACH:
        return FALSE;    /* prefer native version */
104 105
    case DLL_PROCESS_ATTACH:
        DisableThreadLibraryCalls(hinst);
106 107 108 109
#define LOADFUNC(x) x = alcGetProcAddress(NULL, #x)
        LOADFUNC(alcSetThreadContext);
        LOADFUNC(alcGetThreadContext);
#undef LOADFUNC
110
        break;
111
    case DLL_PROCESS_DETACH:
112
        if (reserved) break;
113
        DeleteCriticalSection(&openal_cs);
114 115 116 117
    }

    return TRUE;
}
118 119


120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
static void LoadProcs(void)
{
#define LOADFUNC(x) x = alGetProcAddress(#x)
    LOADFUNC(alBufferDataStatic);
    LOADFUNC(alGenFilters);
    LOADFUNC(alDeleteFilters);
    LOADFUNC(alIsFilter);
    LOADFUNC(alFilterf);
    LOADFUNC(alFilterfv);
    LOADFUNC(alFilteri);
    LOADFUNC(alFilteriv);
    LOADFUNC(alGetFilterf);
    LOADFUNC(alGetFilterfv);
    LOADFUNC(alGetFilteri);
    LOADFUNC(alGetFilteriv);
    LOADFUNC(alGenEffects);
    LOADFUNC(alDeleteEffects);
    LOADFUNC(alIsEffect);
    LOADFUNC(alEffectf);
    LOADFUNC(alEffectfv);
    LOADFUNC(alEffecti);
    LOADFUNC(alEffectiv);
    LOADFUNC(alGetEffectf);
    LOADFUNC(alGetEffectfv);
    LOADFUNC(alGetEffecti);
    LOADFUNC(alGetEffectiv);
    LOADFUNC(alGenAuxiliaryEffectSlots);
    LOADFUNC(alDeleteAuxiliaryEffectSlots);
    LOADFUNC(alIsAuxiliaryEffectSlot);
    LOADFUNC(alAuxiliaryEffectSlotf);
    LOADFUNC(alAuxiliaryEffectSlotfv);
    LOADFUNC(alAuxiliaryEffectSloti);
    LOADFUNC(alAuxiliaryEffectSlotiv);
    LOADFUNC(alGetAuxiliaryEffectSlotf);
    LOADFUNC(alGetAuxiliaryEffectSlotfv);
    LOADFUNC(alGetAuxiliaryEffectSloti);
    LOADFUNC(alGetAuxiliaryEffectSlotiv);
#undef LOADFUNC
}

160 161 162 163 164 165 166
/***********************************************************************
 *           OpenAL thunk routines
 */

/* OpenAL ALC 1.0 functions */
ALCcontext* CDECL wine_alcCreateContext(ALCdevice *device, const ALCint* attrlist)
{
167
    return alcCreateContext(device, attrlist);
168 169 170 171
}

ALCboolean CDECL wine_alcMakeContextCurrent(ALCcontext *context)
{
172
    EnterCriticalSection(&openal_cs);
173
    if(alcMakeContextCurrent(context) == ALC_FALSE)
174
    {
175
        WARN("Failed to make context %p current\n", context);
176 177 178 179
        LeaveCriticalSection(&openal_cs);
        return ALC_FALSE;
    }

180
    if(context && !loaded_procs)
181
    {
182
        loaded_procs = AL_TRUE;
183
        LoadProcs();
184
    }
185 186 187
    LeaveCriticalSection(&openal_cs);

    return ALC_TRUE;
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
}

ALvoid CDECL wine_alcProcessContext(ALCcontext *context)
{
    alcProcessContext(context);
}

ALvoid CDECL wine_alcSuspendContext(ALCcontext *context)
{
    alcSuspendContext(context);
}

ALvoid CDECL wine_alcDestroyContext(ALCcontext *context)
{
    alcDestroyContext(context);
}

ALCcontext* CDECL wine_alcGetCurrentContext(ALCvoid)
{
207
    return alcGetCurrentContext();
208 209 210 211 212 213 214 215 216
}

ALCdevice* CDECL wine_alcGetContextsDevice(ALCcontext *context)
{
    return alcGetContextsDevice(context);
}

ALCdevice* CDECL wine_alcOpenDevice(const ALCchar *devicename)
{
217 218 219 220 221 222
    if(devicename != NULL && (strcmp(devicename, "DirectSound3D") == 0 ||
                              strcmp(devicename, "DirectSound") == 0 ||
                              strcmp(devicename, "Generic Hardware") == 0 ||
                              strcmp(devicename, "Generic Software") == 0)) {
        devicename = NULL;
    }
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
    return alcOpenDevice(devicename);
}

ALCboolean CDECL wine_alcCloseDevice(ALCdevice *device)
{
    return alcCloseDevice(device);
}

ALCenum CDECL wine_alcGetError(ALCdevice *device)
{
    return alcGetError(device);
}

ALCboolean CDECL wine_alcIsExtensionPresent(ALCdevice *device, const ALCchar *extname)
{
    return alcIsExtensionPresent(device, extname);
}

ALCenum CDECL wine_alcGetEnumValue(ALCdevice *device, const ALCchar *enumname)
{
    return alcGetEnumValue(device, enumname);
}

const ALCchar* CDECL wine_alcGetString(ALCdevice *device, ALCenum param)
{
    return alcGetString(device, param);
}

ALvoid CDECL wine_alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest)
{
253
    alcGetIntegerv(device, param, size, dest);
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
}


/* OpenAL 1.0 functions */
ALvoid CDECL wine_alEnable(ALenum capability)
{
    alEnable(capability);
}

ALvoid CDECL wine_alDisable(ALenum capability)
{
    alDisable(capability);
}

ALboolean CDECL wine_alIsEnabled(ALenum capability)
{
    return alIsEnabled(capability);
}

const ALchar* CDECL wine_alGetString(ALenum param)
{
    return alGetString(param);
}

ALvoid CDECL wine_alGetBooleanv(ALenum param, ALboolean* data)
{
    alGetBooleanv(param, data);
}

ALvoid CDECL wine_alGetIntegerv(ALenum param, ALint* data)
{
    alGetIntegerv(param, data);
}

ALvoid CDECL wine_alGetFloatv(ALenum param, ALfloat* data)
{
    alGetFloatv(param, data);
}

ALvoid CDECL wine_alGetDoublev(ALenum param, ALdouble* data)
{
    alGetDoublev(param, data);
}

ALboolean CDECL wine_alGetBoolean(ALenum param)
{
    return alGetBoolean(param);
}

ALint CDECL wine_alGetInteger(ALenum param)
{
    return alGetInteger(param);
}

ALfloat CDECL wine_alGetFloat(ALenum param)
{
    return alGetFloat(param);
}

ALdouble CDECL wine_alGetDouble(ALenum param)
{
    return alGetDouble(param);
}

ALenum CDECL wine_alGetError(ALvoid)
{
    return alGetError();
}

ALboolean CDECL wine_alIsExtensionPresent(const ALchar* extname)
{
    return alIsExtensionPresent(extname);
}

ALenum CDECL wine_alGetEnumValue(const ALchar* ename)
{
    return alGetEnumValue(ename);
}

ALvoid CDECL wine_alListenerf(ALenum param, ALfloat value)
{
    alListenerf(param, value);
}

ALvoid CDECL wine_alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)
{
    alListener3f(param, value1, value2, value3);
}

ALvoid CDECL wine_alListenerfv(ALenum param, const ALfloat* values)
{
    alListenerfv(param, values);
}

ALvoid CDECL wine_alListeneri(ALenum param, ALint value)
{
    alListeneri(param, value);
}

ALvoid CDECL wine_alGetListenerf(ALenum param, ALfloat* value)
{
    alGetListenerf(param, value);
}

ALvoid CDECL wine_alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3)
{
    alGetListener3f(param, value1, value2, value3);
}

ALvoid CDECL wine_alGetListenerfv(ALenum param, ALfloat* values)
{
    alGetListenerfv(param, values);
}

ALvoid CDECL wine_alGetListeneri(ALenum param, ALint* value)
{
    alGetListeneri(param, value);
}

ALvoid CDECL wine_alGetListeneriv(ALenum param, ALint* values)
{
    alGetListeneriv(param, values);
}

ALvoid CDECL wine_alGenSources(ALsizei n, ALuint* sources)
{
    alGenSources(n, sources);
}

ALvoid CDECL wine_alDeleteSources(ALsizei n, const ALuint* sources)
{
    alDeleteSources(n, sources);
}

ALboolean CDECL wine_alIsSource(ALuint sid)
{
    return alIsSource(sid);
}

ALvoid CDECL wine_alSourcef(ALuint sid, ALenum param, ALfloat value)
{
    alSourcef(sid, param, value);
}

ALvoid CDECL wine_alSource3f(ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)
{
    alSource3f(sid, param, value1, value2, value3);
}

ALvoid CDECL wine_alSourcefv(ALuint sid, ALenum param, const ALfloat* values)
{
    alSourcefv(sid, param, values);
}

ALvoid CDECL wine_alSourcei(ALuint sid, ALenum param, ALint value)
{
    alSourcei(sid, param, value);
}

ALvoid CDECL wine_alGetSourcef(ALuint sid, ALenum param, ALfloat* value)
{
    alGetSourcef(sid, param, value);
}

ALvoid CDECL wine_alGetSource3f(ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3)
{
    alGetSource3f(sid, param, value1, value2, value3);
}

ALvoid CDECL wine_alGetSourcefv(ALuint sid, ALenum param, ALfloat* values)
{
    alGetSourcefv(sid, param, values);
}

ALvoid CDECL wine_alGetSourcei(ALuint sid, ALenum param, ALint* value)
{
    alGetSourcei(sid, param, value);
}

ALvoid CDECL wine_alGetSourceiv(ALuint sid, ALenum param, ALint* values)
{
    alGetSourceiv(sid, param, values);
}

ALvoid CDECL wine_alSourcePlayv(ALsizei ns, const ALuint *sids)
{
    alSourcePlayv(ns, sids);
}

ALvoid CDECL wine_alSourceStopv(ALsizei ns, const ALuint *sids)
{
    alSourceStopv(ns, sids);
}

ALvoid CDECL wine_alSourceRewindv(ALsizei ns, const ALuint *sids)
{
    alSourceRewindv(ns, sids);
}

ALvoid CDECL wine_alSourcePausev(ALsizei ns, const ALuint *sids)
{
    alSourcePausev(ns, sids);
}

ALvoid CDECL wine_alSourcePlay(ALuint sid)
{
    alSourcePlay(sid);
}

ALvoid CDECL wine_alSourceStop(ALuint sid)
{
    alSourceStop(sid);
}

ALvoid CDECL wine_alSourceRewind(ALuint sid)
{
    alSourceRewind(sid);
}

ALvoid CDECL wine_alSourcePause(ALuint sid)
{
    alSourcePause(sid);
}

ALvoid CDECL wine_alSourceQueueBuffers(ALuint sid, ALsizei numEntries, const ALuint *bids)
{
    alSourceQueueBuffers(sid, numEntries, bids);
}

ALvoid CDECL wine_alSourceUnqueueBuffers(ALuint sid, ALsizei numEntries, ALuint *bids)
{
    alSourceUnqueueBuffers(sid, numEntries, bids);
}

ALvoid CDECL wine_alGenBuffers(ALsizei n, ALuint* buffers)
{
    alGenBuffers(n, buffers);
}

ALvoid CDECL wine_alDeleteBuffers(ALsizei n, const ALuint* buffers)
{
    alDeleteBuffers(n, buffers);
}

ALboolean CDECL wine_alIsBuffer(ALuint bid)
{
    return alIsBuffer(bid);
}

ALvoid CDECL wine_alBufferData(ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq)
{
    alBufferData(bid, format, data, size, freq);
}

508
static ALvoid CDECL wine_alBufferDataStatic(const ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq)
509
{
510
    alBufferDataStatic(bid, format, data, size, freq);
511 512
}

513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650
ALvoid CDECL wine_alGetBufferf(ALuint bid, ALenum param, ALfloat* value)
{
    alGetBufferf(bid, param, value);
}

ALvoid CDECL wine_alGetBufferfv(ALuint bid, ALenum param, ALfloat* values)
{
    alGetBufferfv(bid, param, values);
}

ALvoid CDECL wine_alGetBufferi(ALuint bid, ALenum param, ALint* value)
{
    alGetBufferi(bid, param, value);
}

ALvoid CDECL wine_alGetBufferiv(ALuint bid, ALenum param, ALint* values)
{
    alGetBufferiv(bid, param, values);
}

ALvoid CDECL wine_alDopplerFactor(ALfloat value)
{
    alDopplerFactor(value);
}

ALvoid CDECL wine_alDopplerVelocity(ALfloat value)
{
    alDopplerVelocity(value);
}

ALvoid CDECL wine_alDistanceModel(ALenum distanceModel)
{
    alDistanceModel(distanceModel);
}


/* OpenAL ALC 1.1 functions */
ALCdevice* CDECL wine_alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize)
{
     return alcCaptureOpenDevice(devicename, frequency, format, buffersize);
}

ALCboolean CDECL wine_alcCaptureCloseDevice(ALCdevice *device)
{
    return alcCaptureCloseDevice(device);
}

ALCvoid CDECL wine_alcCaptureStart(ALCdevice *device)
{
    alcCaptureStart(device);
}

ALCvoid CDECL wine_alcCaptureStop(ALCdevice *device)
{
    alcCaptureStop(device);
}

ALCvoid CDECL wine_alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples)
{
    alcCaptureSamples(device, buffer, samples);
}

/* OpenAL 1.1 functions */
ALvoid CDECL wine_alListener3i(ALenum param, ALint value1, ALint value2, ALint value3)
{
    alListener3i(param, value1, value2, value3);
}

ALvoid CDECL wine_alListeneriv(ALenum param, const ALint* values)
{
    alListeneriv(param, values);
}

ALvoid CDECL wine_alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3)
{
    alGetListener3i(param, value1, value2, value3);
}

ALvoid CDECL wine_alSource3i(ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3)
{
    alSource3i(sid, param, value1, value2, value3);
}

ALvoid CDECL wine_alSourceiv(ALuint sid, ALenum param, const ALint* values)
{
    alSourceiv(sid, param, values);
}

ALvoid CDECL wine_alGetSource3i(ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3)
{
    alGetSource3i(sid, param, value1, value2, value3);
}

ALvoid CDECL wine_alBufferf(ALuint bid, ALenum param, ALfloat value)
{
    alBufferf(bid, param, value);
}

ALvoid CDECL wine_alBuffer3f(ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)
{
    alBuffer3f(bid, param, value1, value2, value3);
}

ALvoid CDECL wine_alBufferfv(ALuint bid, ALenum param, const ALfloat* values)
{
    alBufferfv(bid, param, values);
}

ALvoid CDECL wine_alBufferi(ALuint bid, ALenum param, ALint value)
{
    alBufferi(bid, param, value);
}

ALvoid CDECL wine_alBuffer3i(ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3)
{
    alBuffer3i(bid, param, value1, value2, value3);
}

ALvoid CDECL wine_alBufferiv(ALuint bid, ALenum param, const ALint* values)
{
    alBufferiv(bid, param, values);
}

ALvoid CDECL wine_alGetBuffer3f(ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3)
{
    alGetBuffer3f(bid, param, value1, value2, value3);
}

ALvoid CDECL wine_alGetBuffer3i(ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3)
{
    alGetBuffer3i(bid, param, value1, value2, value3);
}

ALvoid CDECL wine_alSpeedOfSound(ALfloat value)
{
    alSpeedOfSound(value);
}

651
/* OpenAL EFX extension functions */
652
static ALvoid CDECL wine_alGenFilters(ALsizei n, ALuint* filters)
653
{
654
    alGenFilters(n, filters);
655 656
}

657
static ALvoid CDECL wine_alDeleteFilters(ALsizei n, const ALuint* filters)
658
{
659
    alDeleteFilters(n, filters);
660 661
}

662
static ALboolean CDECL wine_alIsFilter(ALuint fid)
663
{
664
    return alIsFilter(fid);
665 666
}

667
static ALvoid CDECL wine_alFilterf(ALuint fid, ALenum param, ALfloat value)
668
{
669
    alFilterf(fid, param, value);
670 671
}

672
static ALvoid CDECL wine_alFilterfv(ALuint fid, ALenum param, const ALfloat* values)
673
{
674
    alFilterfv(fid, param, values);
675 676
}

677
static ALvoid CDECL wine_alFilteri(ALuint fid, ALenum param, ALint value)
678
{
679
    alFilteri(fid, param, value);
680 681
}

682
static ALvoid CDECL wine_alFilteriv(ALuint fid, ALenum param, const ALint* values)
683
{
684
    alFilteriv(fid, param, values);
685 686
}

687
static ALvoid CDECL wine_alGetFilterf(ALuint fid, ALenum param, ALfloat* value)
688
{
689
    alGetFilterf(fid, param, value);
690 691
}

692
static ALvoid CDECL wine_alGetFilterfv(ALuint fid, ALenum param, ALfloat* values)
693
{
694
    alGetFilterfv(fid, param, values);
695 696
}

697
static ALvoid CDECL wine_alGetFilteri(ALuint fid, ALenum param, ALint* value)
698
{
699
    alGetFilteri(fid, param, value);
700 701
}

702
static ALvoid CDECL wine_alGetFilteriv(ALuint fid, ALenum param, ALint* values)
703
{
704
    alGetFilteriv(fid, param, values);
705 706 707
}


708
static ALvoid CDECL wine_alGenEffects(ALsizei n, ALuint* effects)
709
{
710
    alGenEffects(n, effects);
711 712
}

713
static ALvoid CDECL wine_alDeleteEffects(ALsizei n, const ALuint* effects)
714
{
715
    alDeleteEffects(n, effects);
716 717
}

718
static ALboolean CDECL wine_alIsEffect(ALuint eid)
719
{
720
    return alIsEffect(eid);
721 722
}

723
static ALvoid CDECL wine_alEffectf(ALuint eid, ALenum param, ALfloat value)
724
{
725
    alEffectf(eid, param, value);
726 727
}

728
static ALvoid CDECL wine_alEffectfv(ALuint eid, ALenum param, const ALfloat* values)
729
{
730
    alEffectfv(eid, param, values);
731 732
}

733
static ALvoid CDECL wine_alEffecti(ALuint eid, ALenum param, ALint value)
734
{
735
    alEffecti(eid, param, value);
736 737
}

738
static ALvoid CDECL wine_alEffectiv(ALuint eid, ALenum param, const ALint* values)
739
{
740
    alEffectiv(eid, param, values);
741 742
}

743
static ALvoid CDECL wine_alGetEffectf(ALuint eid, ALenum param, ALfloat* value)
744
{
745
    alGetEffectf(eid, param, value);
746 747
}

748
static ALvoid CDECL wine_alGetEffectfv(ALuint eid, ALenum param, ALfloat* values)
749
{
750
    alGetEffectfv(eid, param, values);
751 752
}

753
static ALvoid CDECL wine_alGetEffecti(ALuint eid, ALenum param, ALint* value)
754
{
755
    alGetEffecti(eid, param, value);
756 757
}

758
static ALvoid CDECL wine_alGetEffectiv(ALuint eid, ALenum param, ALint* values)
759
{
760
    alGetEffectiv(eid, param, values);
761 762 763
}


764
static ALvoid CDECL wine_alGenAuxiliaryEffectSlots(ALsizei n, ALuint* slots)
765
{
766
    alGenAuxiliaryEffectSlots(n, slots);
767 768
}

769
static ALvoid CDECL wine_alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint* slots)
770
{
771
    alDeleteAuxiliaryEffectSlots(n, slots);
772 773
}

774
static ALboolean CDECL wine_alIsAuxiliaryEffectSlot(ALuint sid)
775
{
776
    return alIsAuxiliaryEffectSlot(sid);
777 778
}

779
static ALvoid CDECL wine_alAuxiliaryEffectSlotf(ALuint sid, ALenum param, ALfloat value)
780
{
781
    alAuxiliaryEffectSlotf(sid, param, value);
782 783
}

784
static ALvoid CDECL wine_alAuxiliaryEffectSlotfv(ALuint sid, ALenum param, const ALfloat* values)
785
{
786
    alAuxiliaryEffectSlotfv(sid, param, values);
787 788
}

789
static ALvoid CDECL wine_alAuxiliaryEffectSloti(ALuint sid, ALenum param, ALint value)
790
{
791
    alAuxiliaryEffectSloti(sid, param, value);
792 793
}

794
static ALvoid CDECL wine_alAuxiliaryEffectSlotiv(ALuint sid, ALenum param, const ALint* values)
795
{
796
    alAuxiliaryEffectSlotiv(sid, param, values);
797 798
}

799
static ALvoid CDECL wine_alGetAuxiliaryEffectSlotf(ALuint sid, ALenum param, ALfloat* value)
800
{
801
    alGetAuxiliaryEffectSlotf(sid, param, value);
802 803
}

804
static ALvoid CDECL wine_alGetAuxiliaryEffectSlotfv(ALuint sid, ALenum param, ALfloat* values)
805
{
806
    alGetAuxiliaryEffectSlotfv(sid, param, values);
807 808
}

809
static ALvoid CDECL wine_alGetAuxiliaryEffectSloti(ALuint sid, ALenum param, ALint* value)
810
{
811
    alGetAuxiliaryEffectSloti(sid, param, value);
812 813
}

814
static ALvoid CDECL wine_alGetAuxiliaryEffectSlotiv(ALuint sid, ALenum param, ALint* values)
815
{
816
    alGetAuxiliaryEffectSlotiv(sid, param, values);
817 818 819
}


820
/* Thread-local context functions */
821
static ALCboolean CDECL wine_alcSetThreadContext(ALCcontext *context)
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840
{
    EnterCriticalSection(&openal_cs);
    if(alcSetThreadContext(context) == ALC_FALSE)
    {
        WARN("Failed to make context %p current\n", context);
        LeaveCriticalSection(&openal_cs);
        return ALC_FALSE;
    }

    if(context && !loaded_procs)
    {
        loaded_procs = AL_TRUE;
        LoadProcs();
    }
    LeaveCriticalSection(&openal_cs);

    return ALC_TRUE;
}

841
static ALCcontext* CDECL wine_alcGetThreadContext(ALCvoid)
842 843 844 845
{
    return alcGetThreadContext();
}

846 847 848 849
struct FuncList {
    const char *name;
    void *proc;
};
850

851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871
static const struct FuncList ALCFuncs[] = {
    { "alcCreateContext",           wine_alcCreateContext        },
    { "alcMakeContextCurrent",      wine_alcMakeContextCurrent   },
    { "alcProcessContext",          wine_alcProcessContext       },
    { "alcSuspendContext",          wine_alcSuspendContext       },
    { "alcDestroyContext",          wine_alcDestroyContext       },
    { "alcGetCurrentContext",       wine_alcGetCurrentContext    },
    { "alcGetContextsDevice",       wine_alcGetContextsDevice    },
    { "alcOpenDevice",              wine_alcOpenDevice           },
    { "alcCloseDevice",             wine_alcCloseDevice          },
    { "alcGetError",                wine_alcGetError             },
    { "alcIsExtensionPresent",      wine_alcIsExtensionPresent   },
    { "alcGetProcAddress",          wine_alcGetProcAddress       },
    { "alcGetEnumValue",            wine_alcGetEnumValue         },
    { "alcGetString",               wine_alcGetString            },
    { "alcGetIntegerv",             wine_alcGetIntegerv          },
    { "alcCaptureOpenDevice",       wine_alcCaptureOpenDevice    },
    { "alcCaptureCloseDevice",      wine_alcCaptureCloseDevice   },
    { "alcCaptureStart",            wine_alcCaptureStart         },
    { "alcCaptureStop",             wine_alcCaptureStop          },
    { "alcCaptureSamples",          wine_alcCaptureSamples       },
872 873
    { "alcSetThreadContext",        wine_alcSetThreadContext     },
    { "alcGetThreadContext",        wine_alcGetThreadContext     },
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933
    { NULL,                         NULL                         }
};
static const struct FuncList ALFuncs[] = {
    { "alEnable",                   wine_alEnable                },
    { "alDisable",                  wine_alDisable               },
    { "alIsEnabled",                wine_alIsEnabled             },
    { "alGetString",                wine_alGetString             },
    { "alGetBooleanv",              wine_alGetBooleanv           },
    { "alGetIntegerv",              wine_alGetIntegerv           },
    { "alGetFloatv",                wine_alGetFloatv             },
    { "alGetDoublev",               wine_alGetDoublev            },
    { "alGetBoolean",               wine_alGetBoolean            },
    { "alGetInteger",               wine_alGetInteger            },
    { "alGetFloat",                 wine_alGetFloat              },
    { "alGetDouble",                wine_alGetDouble             },
    { "alGetError",                 wine_alGetError              },
    { "alIsExtensionPresent",       wine_alIsExtensionPresent    },
    { "alGetProcAddress",           wine_alGetProcAddress        },
    { "alGetEnumValue",             wine_alGetEnumValue          },
    { "alListenerf",                wine_alListenerf             },
    { "alListener3f",               wine_alListener3f            },
    { "alListenerfv",               wine_alListenerfv            },
    { "alListeneri",                wine_alListeneri             },
    { "alListener3i",               wine_alListener3i            },
    { "alListeneriv",               wine_alListeneriv            },
    { "alGetListenerf",             wine_alGetListenerf          },
    { "alGetListener3f",            wine_alGetListener3f         },
    { "alGetListenerfv",            wine_alGetListenerfv         },
    { "alGetListeneri",             wine_alGetListeneri          },
    { "alGetListener3i",            wine_alGetListener3i         },
    { "alGetListeneriv",            wine_alGetListeneriv         },
    { "alGenSources",               wine_alGenSources            },
    { "alDeleteSources",            wine_alDeleteSources         },
    { "alIsSource",                 wine_alIsSource              },
    { "alSourcef",                  wine_alSourcef               },
    { "alSource3f",                 wine_alSource3f              },
    { "alSourcefv",                 wine_alSourcefv              },
    { "alSourcei",                  wine_alSourcei               },
    { "alSource3i",                 wine_alSource3i              },
    { "alSourceiv",                 wine_alSourceiv              },
    { "alGetSourcef",               wine_alGetSourcef            },
    { "alGetSource3f",              wine_alGetSource3f           },
    { "alGetSourcefv",              wine_alGetSourcefv           },
    { "alGetSourcei",               wine_alGetSourcei            },
    { "alGetSource3i",              wine_alGetSource3i           },
    { "alGetSourceiv",              wine_alGetSourceiv           },
    { "alSourcePlayv",              wine_alSourcePlayv           },
    { "alSourceStopv",              wine_alSourceStopv           },
    { "alSourceRewindv",            wine_alSourceRewindv         },
    { "alSourcePausev",             wine_alSourcePausev          },
    { "alSourcePlay",               wine_alSourcePlay            },
    { "alSourceStop",               wine_alSourceStop            },
    { "alSourceRewind",             wine_alSourceRewind          },
    { "alSourcePause",              wine_alSourcePause           },
    { "alSourceQueueBuffers",       wine_alSourceQueueBuffers    },
    { "alSourceUnqueueBuffers",     wine_alSourceUnqueueBuffers  },
    { "alGenBuffers",               wine_alGenBuffers            },
    { "alDeleteBuffers",            wine_alDeleteBuffers         },
    { "alIsBuffer",                 wine_alIsBuffer              },
    { "alBufferData",               wine_alBufferData            },
934
    { "alBufferDataStatic",         wine_alBufferDataStatic      },
935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950
    { "alBufferf",                  wine_alBufferf               },
    { "alBuffer3f",                 wine_alBuffer3f              },
    { "alBufferfv",                 wine_alBufferfv              },
    { "alBufferi",                  wine_alBufferi               },
    { "alBuffer3i",                 wine_alBuffer3i              },
    { "alBufferiv",                 wine_alBufferiv              },
    { "alGetBufferf",               wine_alGetBufferf            },
    { "alGetBuffer3f",              wine_alGetBuffer3f           },
    { "alGetBufferfv",              wine_alGetBufferfv           },
    { "alGetBufferi",               wine_alGetBufferi            },
    { "alGetBuffer3i",              wine_alGetBuffer3i           },
    { "alGetBufferiv",              wine_alGetBufferiv           },
    { "alDopplerFactor",            wine_alDopplerFactor         },
    { "alDopplerVelocity",          wine_alDopplerVelocity       },
    { "alSpeedOfSound",             wine_alSpeedOfSound          },
    { "alDistanceModel",            wine_alDistanceModel         },
951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987

    { "alGenFilters",               wine_alGenFilters            },
    { "alDeleteFilters",            wine_alDeleteFilters         },
    { "alIsFilter",                 wine_alIsFilter              },
    { "alFilterf",                  wine_alFilterf               },
    { "alFilterfv",                 wine_alFilterfv              },
    { "alFilteri",                  wine_alFilteri               },
    { "alFilteriv",                 wine_alFilteriv              },
    { "alGetFilterf",               wine_alGetFilterf            },
    { "alGetFilterfv",              wine_alGetFilterfv           },
    { "alGetFilteri",               wine_alGetFilteri            },
    { "alGetFilteriv",              wine_alGetFilteriv           },

    { "alGenEffects",               wine_alGenEffects            },
    { "alDeleteEffects",            wine_alDeleteEffects         },
    { "alIsEffect",                 wine_alIsEffect              },
    { "alEffectf",                  wine_alEffectf               },
    { "alEffectfv",                 wine_alEffectfv              },
    { "alEffecti",                  wine_alEffecti               },
    { "alEffectiv",                 wine_alEffectiv              },
    { "alGetEffectf",               wine_alGetEffectf            },
    { "alGetEffectfv",              wine_alGetEffectfv           },
    { "alGetEffecti",               wine_alGetEffecti            },
    { "alGetEffectiv",              wine_alGetEffectiv           },

    { "alGenAuxiliaryEffectSlots",  wine_alGenAuxiliaryEffectSlots},
    { "alDeleteAuxiliaryEffectSlots",wine_alDeleteAuxiliaryEffectSlots},
    { "alIsAuxiliaryEffectSlot",    wine_alIsAuxiliaryEffectSlot },
    { "alAuxiliaryEffectSlotf",     wine_alAuxiliaryEffectSlotf  },
    { "alAuxiliaryEffectSlotfv",    wine_alAuxiliaryEffectSlotfv },
    { "alAuxiliaryEffectSloti",     wine_alAuxiliaryEffectSloti  },
    { "alAuxiliaryEffectSlotiv",    wine_alAuxiliaryEffectSlotiv },
    { "alGetAuxiliaryEffectSlotf",  wine_alGetAuxiliaryEffectSlotf},
    { "alGetAuxiliaryEffectSlotfv", wine_alGetAuxiliaryEffectSlotfv},
    { "alGetAuxiliaryEffectSloti",  wine_alGetAuxiliaryEffectSloti},
    { "alGetAuxiliaryEffectSlotiv", wine_alGetAuxiliaryEffectSlotiv},

988 989
    { NULL,                         NULL                         }
};
990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031


ALCvoid* CDECL wine_alcGetProcAddress(ALCdevice *device, const ALCchar *funcname)
{
    void *proc;
    int i;

    /* Make sure the host implementation has the requested function */
    proc = alcGetProcAddress(device, funcname);
    if(!proc)
        return NULL;

    for(i = 0;ALCFuncs[i].name;i++)
    {
        if(strcmp(funcname, ALCFuncs[i].name) == 0)
            return ALCFuncs[i].proc;
    }
    FIXME("Could not find function in list: %s\n", funcname);
    return NULL;
}


ALvoid* CDECL wine_alGetProcAddress(const ALchar* funcname)
{
    void *proc;
    int i;

    /* Make sure the host implementation has the requested function. This will
     * also set the last AL error properly if the function should not be
     * returned (eg. no current context). */
    proc = alGetProcAddress(funcname);
    if(!proc)
        return NULL;

    for(i = 0;ALFuncs[i].name;i++)
    {
        if(strcmp(funcname, ALFuncs[i].name) == 0)
            return ALFuncs[i].proc;
    }
    FIXME("Could not find function in list: %s\n", funcname);
    return NULL;
}