SFX API Changes

DSound has since been deprecated and xaudio2 would require us to write our own 3d spatialization and mixer
Load devices the same way we load in the gfx end
setup sfx provider
run sfx devices on startup
various fixes around sfx null device
added the bitrate and samplerate globals
added the hrtf global code is in to use this but not setup yet
Adds speed of sound to the sound system
SFXAmbience now has a property for speed of sound for different mediums, can also be set directly
This commit is contained in:
marauder2k7 2026-03-13 08:05:42 +00:00
parent 54b6c3ec47
commit d56bf257c7
53 changed files with 1870 additions and 6401 deletions

View file

@ -0,0 +1,176 @@
/*
* Copyright (c) 2006, Creative Labs Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the distribution.
* * Neither the name of Creative Labs Inc. nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
// Based on Openal-soft router code.
#include "sfx/openal/LoadOAL.h"
#include "console/console.h"
#if defined(TORQUE_OS_WIN)
#include <windows.h>
#else
#include <dirent.h>
#include <sys/types.h>
#endif
LIB_HANDLE openaAlDll = NULL;
#define LOAD_REQUIRED(table, x) \
table->x = reinterpret_cast<decltype(table->x)>(reinterpret_cast<void*>( \
GET_PROC_ADDRESS(openaAlDll, #x))); \
if(!table->x) \
{ \
Con::warnf("Failed to find entry point :%s\n", #x); \
loadok = false; \
}
ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE oal)
{
if (!oal)
return AL_FALSE;
if (szOALFullPathName)
openaAlDll = LOAD_LIBRARY(szOALFullPathName);
else
{
#if defined(TORQUE_OS_WIN)
openaAlDll = LOAD_LIBRARY("openal32.dll");
#elif defined(TORQUE_OS_LINUX)
openaAlDll = LOAD_LIBRARY("libopenal.so");
#elif defined(TORQUE_OS_MAC)
openaAlDll = LOAD_LIBRARY("@rpath/libopenal.1.24.3.dylib");
#endif
}
if (!openaAlDll)
return AL_FALSE;
bool loadok = true;
LOAD_REQUIRED(oal, alcCreateContext);
LOAD_REQUIRED(oal, alcMakeContextCurrent);
LOAD_REQUIRED(oal, alcProcessContext);
LOAD_REQUIRED(oal, alcSuspendContext);
LOAD_REQUIRED(oal, alcDestroyContext);
LOAD_REQUIRED(oal, alcGetCurrentContext);
LOAD_REQUIRED(oal, alcGetContextsDevice);
LOAD_REQUIRED(oal, alcOpenDevice);
LOAD_REQUIRED(oal, alcCloseDevice);
LOAD_REQUIRED(oal, alcGetError);
LOAD_REQUIRED(oal, alcIsExtensionPresent);
LOAD_REQUIRED(oal, alcGetProcAddress);
LOAD_REQUIRED(oal, alcGetEnumValue);
LOAD_REQUIRED(oal, alcGetString);
LOAD_REQUIRED(oal, alcGetIntegerv);
LOAD_REQUIRED(oal, alcCaptureOpenDevice);
LOAD_REQUIRED(oal, alcCaptureCloseDevice);
LOAD_REQUIRED(oal, alcCaptureStart);
LOAD_REQUIRED(oal, alcCaptureStop);
LOAD_REQUIRED(oal, alcCaptureSamples);
LOAD_REQUIRED(oal, alEnable);
LOAD_REQUIRED(oal, alDisable);
LOAD_REQUIRED(oal, alIsEnabled);
LOAD_REQUIRED(oal, alGetString);
LOAD_REQUIRED(oal, alGetBooleanv);
LOAD_REQUIRED(oal, alGetIntegerv);
LOAD_REQUIRED(oal, alGetFloatv);
LOAD_REQUIRED(oal, alGetDoublev);
LOAD_REQUIRED(oal, alGetBoolean);
LOAD_REQUIRED(oal, alGetInteger);
LOAD_REQUIRED(oal, alGetFloat);
LOAD_REQUIRED(oal, alGetDouble);
LOAD_REQUIRED(oal, alGetError);
LOAD_REQUIRED(oal, alIsExtensionPresent);
LOAD_REQUIRED(oal, alGetProcAddress);
LOAD_REQUIRED(oal, alGetEnumValue);
LOAD_REQUIRED(oal, alListenerf);
LOAD_REQUIRED(oal, alListener3f);
LOAD_REQUIRED(oal, alListenerfv);
LOAD_REQUIRED(oal, alListeneri);
LOAD_REQUIRED(oal, alListener3i);
LOAD_REQUIRED(oal, alListeneriv);
LOAD_REQUIRED(oal, alGetListenerf);
LOAD_REQUIRED(oal, alGetListener3f);
LOAD_REQUIRED(oal, alGetListenerfv);
LOAD_REQUIRED(oal, alGetListeneri);
LOAD_REQUIRED(oal, alGetListener3i);
LOAD_REQUIRED(oal, alGetListeneriv);
LOAD_REQUIRED(oal, alGenSources);
LOAD_REQUIRED(oal, alDeleteSources);
LOAD_REQUIRED(oal, alIsSource);
LOAD_REQUIRED(oal, alSourcef);
LOAD_REQUIRED(oal, alSource3f);
LOAD_REQUIRED(oal, alSourcefv);
LOAD_REQUIRED(oal, alSourcei);
LOAD_REQUIRED(oal, alSource3i);
LOAD_REQUIRED(oal, alSourceiv);
LOAD_REQUIRED(oal, alGetSourcef);
LOAD_REQUIRED(oal, alGetSource3f);
LOAD_REQUIRED(oal, alGetSourcefv);
LOAD_REQUIRED(oal, alGetSourcei);
LOAD_REQUIRED(oal, alGetSource3i);
LOAD_REQUIRED(oal, alGetSourceiv);
LOAD_REQUIRED(oal, alSourcePlayv);
LOAD_REQUIRED(oal, alSourceStopv);
LOAD_REQUIRED(oal, alSourceRewindv);
LOAD_REQUIRED(oal, alSourcePausev);
LOAD_REQUIRED(oal, alSourcePlay);
LOAD_REQUIRED(oal, alSourceStop);
LOAD_REQUIRED(oal, alSourceRewind);
LOAD_REQUIRED(oal, alSourcePause);
LOAD_REQUIRED(oal, alSourceQueueBuffers);
LOAD_REQUIRED(oal, alSourceUnqueueBuffers);
LOAD_REQUIRED(oal, alGenBuffers);
LOAD_REQUIRED(oal, alDeleteBuffers);
LOAD_REQUIRED(oal, alIsBuffer);
LOAD_REQUIRED(oal, alBufferData);
LOAD_REQUIRED(oal, alDopplerFactor);
LOAD_REQUIRED(oal, alDopplerVelocity);
LOAD_REQUIRED(oal, alSpeedOfSound);
LOAD_REQUIRED(oal, alDistanceModel);
// these are optional.
LOAD_REQUIRED(oal, alBufferf);
LOAD_REQUIRED(oal, alBuffer3f);
LOAD_REQUIRED(oal, alBufferfv);
LOAD_REQUIRED(oal, alBufferi);
LOAD_REQUIRED(oal, alBuffer3i);
LOAD_REQUIRED(oal, alBufferiv);
LOAD_REQUIRED(oal, alGetBufferf);
LOAD_REQUIRED(oal, alGetBuffer3f);
LOAD_REQUIRED(oal, alGetBufferfv);
LOAD_REQUIRED(oal, alGetBufferi);
LOAD_REQUIRED(oal, alGetBuffer3i);
LOAD_REQUIRED(oal, alGetBufferiv);
return AL_TRUE;
}
ALvoid UnloadOAL10Library()
{
// Unload the dll
if (openaAlDll)
CLOSE_LIBRARY(openaAlDll);
}

View file

@ -24,26 +24,52 @@
#define _LOADOAL_H_
#ifndef _PLATFORM_H_
# include "platform/platform.h"
#include "platform/platform.h"
#endif
#if defined(TORQUE_OS_MAC)
#undef AL_ALEXT_PROTOTYPES
# include <OpenAL/al.h>
# include <OpenAL/alc.h>
#elif defined(TORQUE_OS_LINUX)
# include <AL/al.h>
# include <AL/alc.h>
# include <AL/alext.h>
# include <AL/efx.h>
# include <AL/efx-presets.h>
#else
# include <al/al.h>
# include <al/alc.h>
# include <AL/alext.h>
# include <AL/efx-presets.h>
#ifndef _TVECTOR_H_
#include "core/util/tVector.h"
#endif
#ifndef _PATH_H_
#include "core/util/path.h"
#endif
// Since openal is deprecated and we pack the lib into the mac bundle, all
// platforms now support all of these.
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alext.h>
#include <AL/efx.h>
#include <AL/efx-presets.h>
#ifndef _OPENALFNTABLE
#define _OPENALFNTABLE
#if defined(TORQUE_OS_WIN)
#include <windows.h>
#define LIB_HANDLE HINSTANCE
#define LOAD_LIBRARY(path) LoadLibraryA(path)
#define GET_PROC_ADDRESS(lib, name) GetProcAddress(lib, name)
#define CLOSE_LIBRARY(lib) FreeLibrary(lib)
#define LIB_EXTENSION L".dll"
#else
#include <dlfcn.h>
#define LIB_HANDLE void*
#define LOAD_LIBRARY(path) dlopen(path, RTLD_LAZY)
#define GET_PROC_ADDRESS(lib, name) dlsym(lib, name)
#define CLOSE_LIBRARY(lib) dlclose(lib)
#ifdef __APPLE__
#define LIB_EXTENSION ".dylib"
#else
#define LIB_EXTENSION ".so"
#endif
#endif
constexpr auto MakeALCVer(int major, int minor) noexcept -> int {
return (major << 8) | minor;
}
#ifndef ALAPIENTRY
#define ALAPIENTRY
#endif
@ -52,11 +78,6 @@
#define ALCAPIENTRY
#endif
// Open AL Function table definition
#ifndef _OPENALFNTABLE
#define _OPENALFNTABLE
// AL 1.0 did not define the ALchar and ALCchar types, so define them here
// if they don't exist
@ -68,110 +89,148 @@
#define ALCchar char
#endif
typedef struct
struct OPENALFNTABLE
{
LPALENABLE alEnable;
LPALDISABLE alDisable;
LPALISENABLED alIsEnabled;
LPALGETBOOLEAN alGetBoolean;
LPALGETINTEGER alGetInteger;
LPALGETFLOAT alGetFloat;
LPALGETDOUBLE alGetDouble;
LPALGETBOOLEANV alGetBooleanv;
LPALGETINTEGERV alGetIntegerv;
LPALGETFLOATV alGetFloatv;
LPALGETDOUBLEV alGetDoublev;
LPALGETSTRING alGetString;
LPALGETERROR alGetError;
LPALISEXTENSIONPRESENT alIsExtensionPresent;
LPALGETPROCADDRESS alGetProcAddress;
LPALGETENUMVALUE alGetEnumValue;
LPALLISTENERI alListeneri;
LPALLISTENERF alListenerf;
LPALLISTENER3F alListener3f;
LPALLISTENERFV alListenerfv;
LPALGETLISTENERI alGetListeneri;
LPALGETLISTENERF alGetListenerf;
LPALGETLISTENER3F alGetListener3f;
LPALGETLISTENERFV alGetListenerfv;
LPALGENSOURCES alGenSources;
LPALDELETESOURCES alDeleteSources;
LPALISSOURCE alIsSource;
LPALSOURCEI alSourcei;
LPALSOURCEF alSourcef;
LPALSOURCE3I alSource3i;
LPALSOURCE3F alSource3f;
LPALSOURCEFV alSourcefv;
LPALGETSOURCEI alGetSourcei;
LPALGETSOURCEF alGetSourcef;
LPALGETSOURCEFV alGetSourcefv;
LPALSOURCEPLAYV alSourcePlayv;
LPALSOURCESTOPV alSourceStopv;
LPALSOURCEPLAY alSourcePlay;
LPALSOURCEPAUSE alSourcePause;
LPALSOURCESTOP alSourceStop;
LPALSOURCEREWIND alSourceRewind;
LPALGENBUFFERS alGenBuffers;
LPALDELETEBUFFERS alDeleteBuffers;
LPALISBUFFER alIsBuffer;
LPALBUFFERDATA alBufferData;
LPALGETBUFFERI alGetBufferi;
LPALGETBUFFERF alGetBufferf;
LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers;
LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers;
LPALDISTANCEMODEL alDistanceModel;
LPALDOPPLERFACTOR alDopplerFactor;
LPALDOPPLERVELOCITY alDopplerVelocity;
LPALCGETSTRING alcGetString;
LPALCGETINTEGERV alcGetIntegerv;
LPALCOPENDEVICE alcOpenDevice;
LPALCCLOSEDEVICE alcCloseDevice;
LPALCCREATECONTEXT alcCreateContext;
LPALCMAKECONTEXTCURRENT alcMakeContextCurrent;
LPALCPROCESSCONTEXT alcProcessContext;
LPALCGETCURRENTCONTEXT alcGetCurrentContext;
LPALCGETCONTEXTSDEVICE alcGetContextsDevice;
LPALCSUSPENDCONTEXT alcSuspendContext;
LPALCDESTROYCONTEXT alcDestroyContext;
LPALCGETERROR alcGetError;
LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
LPALCGETPROCADDRESS alcGetProcAddress;
LPALCGETENUMVALUE alcGetEnumValue;
#if defined(AL_ALEXT_PROTOTYPES)
LPALGENEFFECTS alGenEffects;
LPALDELETEEFFECTS alDeleteEffects;
LPALISEFFECT alIsEffect;
LPALEFFECTI alEffecti;
LPALEFFECTIV alEffectiv;
LPALEFFECTF alEffectf;
LPALEFFECTFV alEffectfv;
LPALGETEFFECTI alGetEffecti;
LPALGETEFFECTIV alGetEffectiv;
LPALGETEFFECTF alGetEffectf;
LPALGETEFFECTFV alGetEffectfv;
LPALRELEASEALEFFECTS alReleaseEffects;
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots;
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots;
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot;
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti;
LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv;
LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf;
LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv;
LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti;
LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv;
LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf;
LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv;
LPALGENFILTERS alGenFilters;
LPALDELETEFILTERS alDeleteFilters;
LPALFILTERI alFilteri;
LPALCGETSTRINGISOFT alcGetStringiSOFT;
LPALCCREATECONTEXT alcCreateContext{ nullptr };
LPALCMAKECONTEXTCURRENT alcMakeContextCurrent{ nullptr };
LPALCPROCESSCONTEXT alcProcessContext{ nullptr };
LPALCSUSPENDCONTEXT alcSuspendContext{ nullptr };
LPALCDESTROYCONTEXT alcDestroyContext{ nullptr };
LPALCGETCURRENTCONTEXT alcGetCurrentContext{ nullptr };
LPALCGETCONTEXTSDEVICE alcGetContextsDevice{ nullptr };
LPALCOPENDEVICE alcOpenDevice{ nullptr };
LPALCCLOSEDEVICE alcCloseDevice{ nullptr };
LPALCGETERROR alcGetError{ nullptr };
LPALCISEXTENSIONPRESENT alcIsExtensionPresent{ nullptr };
LPALCGETPROCADDRESS alcGetProcAddress{ nullptr };
LPALCGETENUMVALUE alcGetEnumValue{ nullptr };
LPALCGETSTRING alcGetString{ nullptr };
LPALCGETINTEGERV alcGetIntegerv{ nullptr };
LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice{ nullptr };
LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice{ nullptr };
LPALCCAPTURESTART alcCaptureStart{ nullptr };
LPALCCAPTURESTOP alcCaptureStop{ nullptr };
LPALCCAPTURESAMPLES alcCaptureSamples{ nullptr };
PFNALCSETTHREADCONTEXTPROC alcSetThreadContext{ nullptr };
PFNALCGETTHREADCONTEXTPROC alcGetThreadContext{ nullptr };
LPALENABLE alEnable{ nullptr };
LPALDISABLE alDisable{ nullptr };
LPALISENABLED alIsEnabled{ nullptr };
LPALGETSTRING alGetString{ nullptr };
LPALGETBOOLEANV alGetBooleanv{ nullptr };
LPALGETINTEGERV alGetIntegerv{ nullptr };
LPALGETFLOATV alGetFloatv{ nullptr };
LPALGETDOUBLEV alGetDoublev{ nullptr };
LPALGETBOOLEAN alGetBoolean{ nullptr };
LPALGETINTEGER alGetInteger{ nullptr };
LPALGETFLOAT alGetFloat{ nullptr };
LPALGETDOUBLE alGetDouble{ nullptr };
LPALGETERROR alGetError{ nullptr };
LPALISEXTENSIONPRESENT alIsExtensionPresent{ nullptr };
LPALGETPROCADDRESS alGetProcAddress{ nullptr };
LPALGETENUMVALUE alGetEnumValue{ nullptr };
LPALLISTENERF alListenerf{ nullptr };
LPALLISTENER3F alListener3f{ nullptr };
LPALLISTENERFV alListenerfv{ nullptr };
LPALLISTENERI alListeneri{ nullptr };
LPALLISTENER3I alListener3i{ nullptr };
LPALLISTENERIV alListeneriv{ nullptr };
LPALGETLISTENERF alGetListenerf{ nullptr };
LPALGETLISTENER3F alGetListener3f{ nullptr };
LPALGETLISTENERFV alGetListenerfv{ nullptr };
LPALGETLISTENERI alGetListeneri{ nullptr };
LPALGETLISTENER3I alGetListener3i{ nullptr };
LPALGETLISTENERIV alGetListeneriv{ nullptr };
LPALGENSOURCES alGenSources{ nullptr };
LPALDELETESOURCES alDeleteSources{ nullptr };
LPALISSOURCE alIsSource{ nullptr };
LPALSOURCEF alSourcef{ nullptr };
LPALSOURCE3F alSource3f{ nullptr };
LPALSOURCEFV alSourcefv{ nullptr };
LPALSOURCEI alSourcei{ nullptr };
LPALSOURCE3I alSource3i{ nullptr };
LPALSOURCEIV alSourceiv{ nullptr };
LPALGETSOURCEF alGetSourcef{ nullptr };
LPALGETSOURCE3F alGetSource3f{ nullptr };
LPALGETSOURCEFV alGetSourcefv{ nullptr };
LPALGETSOURCEI alGetSourcei{ nullptr };
LPALGETSOURCE3I alGetSource3i{ nullptr };
LPALGETSOURCEIV alGetSourceiv{ nullptr };
LPALSOURCEPLAYV alSourcePlayv{ nullptr };
LPALSOURCESTOPV alSourceStopv{ nullptr };
LPALSOURCEREWINDV alSourceRewindv{ nullptr };
LPALSOURCEPAUSEV alSourcePausev{ nullptr };
LPALSOURCEPLAY alSourcePlay{ nullptr };
LPALSOURCESTOP alSourceStop{ nullptr };
LPALSOURCEREWIND alSourceRewind{ nullptr };
LPALSOURCEPAUSE alSourcePause{ nullptr };
LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers{ nullptr };
LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers{ nullptr };
LPALGENBUFFERS alGenBuffers{ nullptr };
LPALDELETEBUFFERS alDeleteBuffers{ nullptr };
LPALISBUFFER alIsBuffer{ nullptr };
LPALBUFFERF alBufferf{ nullptr };
LPALBUFFER3F alBuffer3f{ nullptr };
LPALBUFFERFV alBufferfv{ nullptr };
LPALBUFFERI alBufferi{ nullptr };
LPALBUFFER3I alBuffer3i{ nullptr };
LPALBUFFERIV alBufferiv{ nullptr };
LPALGETBUFFERF alGetBufferf{ nullptr };
LPALGETBUFFER3F alGetBuffer3f{ nullptr };
LPALGETBUFFERFV alGetBufferfv{ nullptr };
LPALGETBUFFERI alGetBufferi{ nullptr };
LPALGETBUFFER3I alGetBuffer3i{ nullptr };
LPALGETBUFFERIV alGetBufferiv{ nullptr };
LPALBUFFERDATA alBufferData{ nullptr };
LPALDOPPLERFACTOR alDopplerFactor{ nullptr };
LPALDOPPLERVELOCITY alDopplerVelocity{ nullptr };
LPALSPEEDOFSOUND alSpeedOfSound{ nullptr };
LPALDISTANCEMODEL alDistanceModel{ nullptr };
/* Functions to load after first context creation. */
LPALGENFILTERS alGenFilters{ nullptr };
LPALDELETEFILTERS alDeleteFilters{ nullptr };
LPALISFILTER alIsFilter{ nullptr };
LPALFILTERF alFilterf{ nullptr };
LPALFILTERFV alFilterfv{ nullptr };
LPALFILTERI alFilteri{ nullptr };
LPALFILTERIV alFilteriv{ nullptr };
LPALGETFILTERF alGetFilterf{ nullptr };
LPALGETFILTERFV alGetFilterfv{ nullptr };
LPALGETFILTERI alGetFilteri{ nullptr };
LPALGETFILTERIV alGetFilteriv{ nullptr };
LPALGENEFFECTS alGenEffects{ nullptr };
LPALDELETEEFFECTS alDeleteEffects{ nullptr };
LPALISEFFECT alIsEffect{ nullptr };
LPALEFFECTF alEffectf{ nullptr };
LPALEFFECTFV alEffectfv{ nullptr };
LPALEFFECTI alEffecti{ nullptr };
LPALEFFECTIV alEffectiv{ nullptr };
LPALGETEFFECTF alGetEffectf{ nullptr };
LPALGETEFFECTFV alGetEffectfv{ nullptr };
LPALGETEFFECTI alGetEffecti{ nullptr };
LPALGETEFFECTIV alGetEffectiv{ nullptr };
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots{ nullptr };
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots{ nullptr };
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot{ nullptr };
LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf{ nullptr };
LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv{ nullptr };
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti{ nullptr };
LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv{ nullptr };
LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf{ nullptr };
LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv{ nullptr };
LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti{ nullptr };
LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv{ nullptr };
};
using LPOPENALFNTABLE = OPENALFNTABLE*;
#endif
} OPENALFNTABLE, *LPOPENALFNTABLE;
#endif
ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable);
ALboolean LoadOAL10Library(char* szOALFullPathName, LPOPENALFNTABLE lpOALFnTable);
ALvoid UnloadOAL10Library();
#endif // _LOADOAL_H_

View file

@ -1,303 +0,0 @@
/*
* Copyright (c) 2006, Creative Labs Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the distribution.
* * Neither the name of Creative Labs Inc. nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "core/strings/stringFunctions.h"
#include "aldlist.h"
#if defined(TORQUE_OS_MAC)
#include <OpenAL/alc.h>
#elif defined(TORQUE_OS_LINUX)
#include <AL/alc.h>
#else
#include <al/alc.h>
#endif
/*
* Init call
*/
ALDeviceList::ALDeviceList( const OPENALFNTABLE& oalft )
{
VECTOR_SET_ASSOCIATION( vDeviceInfo );
ALDEVICEINFO ALDeviceInfo;
char *devices;
int index;
const char *defaultDeviceName;
const char *actualDeviceName;
dMemcpy( &ALFunction, &oalft, sizeof(OPENALFNTABLE) );
// DeviceInfo vector stores, for each enumerated device, it's device name, selection status, spec version #, and extension support
vDeviceInfo.clear();
vDeviceInfo.reserve(10);
defaultDeviceIndex = 0;
// grab function pointers for 1.0-API functions, and if successful proceed to enumerate all devices
if (ALFunction.alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT")) {
devices = (char *)ALFunction.alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
defaultDeviceName = (char *)ALFunction.alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER);
}
else
{
devices = (char *)ALFunction.alcGetString(NULL, ALC_DEVICE_SPECIFIER);
defaultDeviceName = (char *)ALFunction.alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
}
index = 0;
// go through device list (each device terminated with a single NULL, list terminated with double NULL)
while (*devices != '\0') {
if (String::compare(defaultDeviceName, devices) == 0) {
defaultDeviceIndex = index;
}
ALCdevice* device = ALFunction.alcOpenDevice(devices);
if (device)
{
ALCcontext* ctx = ALFunction.alcCreateContext(device, nullptr);
if (ctx)
{
ALFunction.alcMakeContextCurrent(ctx);
actualDeviceName = ALFunction.alcGetString(device, ALC_DEVICE_SPECIFIER);
bool bNewName = true;
if (actualDeviceName)
{
for (int i = 0; i < GetNumDevices(); i++) {
if (String::compare(GetDeviceName(i), devices) == 0) {
bNewName = false;
}
}
}
if ((bNewName) && (actualDeviceName != NULL) && (dStrlen(actualDeviceName) > 0))
{
dMemset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO));
ALDeviceInfo.bSelected = true;
dStrncpy(ALDeviceInfo.strDeviceName, actualDeviceName, sizeof(ALDeviceInfo.strDeviceName));
char deviceExternal[256];
dStrcpy(deviceExternal, devices, 256);
vDeviceInfo.push_back(ALDeviceInfo);
}
ALFunction.alcMakeContextCurrent(nullptr);
ALFunction.alcDestroyContext(ctx);
}
ALFunction.alcCloseDevice(device);
}
devices += dStrlen(devices) + 1;
index += 1;
}
ResetFilters();
}
/*
* Exit call
*/
ALDeviceList::~ALDeviceList()
{
}
/*
* Returns the number of devices in the complete device list
*/
int ALDeviceList::GetNumDevices()
{
return (int)vDeviceInfo.size();
}
/*
* Returns the device name at an index in the complete device list
*/
const char* ALDeviceList::GetDeviceName(int index)
{
if (index < GetNumDevices())
return vDeviceInfo[index].strDeviceName;
else
return NULL;
}
/*
* Returns the major and minor version numbers for a device at a specified index in the complete list
*/
void ALDeviceList::GetDeviceVersion(int index, int *major, int *minor)
{
if (index < GetNumDevices()) {
if (major)
*major = vDeviceInfo[index].iMajorVersion;
if (minor)
*minor = vDeviceInfo[index].iMinorVersion;
}
return;
}
/*
* Returns the maximum number of Sources that can be generate on the given device
*/
U32 ALDeviceList::GetMaxNumSources(S32 index)
{
if (index < GetNumDevices())
return vDeviceInfo[index].uiSourceCount;
else
return 0;
}
/*
* Checks if the extension is supported on the given device
*/
bool ALDeviceList::IsExtensionSupported(int index, SFXALCaps cap)
{
bool bReturn = false;
if (index < GetNumDevices())
bReturn = vDeviceInfo[index].iCapsFlags & cap;
return bReturn;
}
/*
* returns the index of the default device in the complete device list
*/
int ALDeviceList::GetDefaultDevice()
{
return defaultDeviceIndex;
}
/*
* Deselects devices which don't have the specified minimum version
*/
void ALDeviceList::FilterDevicesMinVer(S32 major, S32 minor)
{
int dMajor, dMinor;
for (U32 i = 0; i < vDeviceInfo.size(); i++) {
GetDeviceVersion(i, &dMajor, &dMinor);
if ((dMajor < major) || ((dMajor == major) && (dMinor < minor))) {
vDeviceInfo[i].bSelected = false;
}
}
}
/*
* Deselects devices which don't have the specified maximum version
*/
void ALDeviceList::FilterDevicesMaxVer(S32 major, S32 minor)
{
S32 dMajor, dMinor;
for (U32 i = 0; i < vDeviceInfo.size(); i++) {
GetDeviceVersion(i, &dMajor, &dMinor);
if ((dMajor > major) || ((dMajor == major) && (dMinor > minor))) {
vDeviceInfo[i].bSelected = false;
}
}
}
/*
* Deselects device which don't support the given extension name
*/
void ALDeviceList::FilterDevicesExtension(SFXALCaps cap)
{
for (U32 i = 0; i < vDeviceInfo.size(); i++)
vDeviceInfo[i].bSelected = vDeviceInfo[i].iCapsFlags & cap;
}
/*
* Resets all filtering, such that all devices are in the list
*/
void ALDeviceList::ResetFilters()
{
for (S32 i = 0; i < GetNumDevices(); i++) {
vDeviceInfo[i].bSelected = true;
}
filterIndex = 0;
}
/*
* Gets index of first filtered device
*/
int ALDeviceList::GetFirstFilteredDevice()
{
int i;
for (i = 0; i < GetNumDevices(); i++) {
if (vDeviceInfo[i].bSelected == true) {
break;
}
}
filterIndex = i + 1;
return i;
}
/*
* Gets index of next filtered device
*/
int ALDeviceList::GetNextFilteredDevice()
{
int i;
for (i = filterIndex; i < GetNumDevices(); i++) {
if (vDeviceInfo[i].bSelected == true) {
break;
}
}
filterIndex = i + 1;
return i;
}
/*
* Internal function to detemine max number of Sources that can be generated
*/
unsigned int ALDeviceList::GetMaxNumSources()
{
ALuint uiSources[256];
U32 iSourceCount = 0;
// Clear AL Error Code
ALFunction.alGetError();
// Generate up to 256 Sources, checking for any errors
for (iSourceCount = 0; iSourceCount < 256; iSourceCount++)
{
ALFunction.alGenSources(1, &uiSources[iSourceCount]);
if (ALFunction.alGetError() != AL_NO_ERROR)
break;
}
// Release the Sources
ALFunction.alDeleteSources(iSourceCount, uiSources);
if (ALFunction.alGetError() != AL_NO_ERROR)
{
for (U32 i = 0; i < 256; i++)
{
ALFunction.alDeleteSources(1, &uiSources[i]);
}
}
return iSourceCount;
}

View file

@ -1,71 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef ALDEVICELIST_H
#define ALDEVICELIST_H
#pragma warning(disable: 4786) //disable warning "identifier was truncated to '255' characters in the browser information"
#include "core/util/tVector.h"
#include "core/stringTable.h"
#include "sfx/openal/sfxALCaps.h"
#include "LoadOAL.h"
typedef struct
{
char strDeviceName[256];
char strInternalDeviceName[256];
S32 iMajorVersion;
S32 iMinorVersion;
U32 uiSourceCount;
S32 iCapsFlags;
bool bSelected;
} ALDEVICEINFO, *LPALDEVICEINFO;
class ALDeviceList
{
private:
OPENALFNTABLE ALFunction;
Vector<ALDEVICEINFO> vDeviceInfo;
S32 defaultDeviceIndex;
S32 filterIndex;
public:
ALDeviceList ( const OPENALFNTABLE &oalft );
~ALDeviceList ();
S32 GetNumDevices();
const char *GetDeviceName(S32 index);
void GetDeviceVersion(S32 index, S32 *major, S32 *minor);
U32 GetMaxNumSources(S32 index);
bool IsExtensionSupported(S32 index, SFXALCaps caps);
S32 GetDefaultDevice();
void FilterDevicesMinVer(S32 major, S32 minor);
void FilterDevicesMaxVer(S32 major, S32 minor);
void FilterDevicesExtension(SFXALCaps caps);
void ResetFilters();
S32 GetFirstFilteredDevice();
S32 GetNextFilteredDevice();
private:
U32 GetMaxNumSources();
};
#endif // ALDEVICELIST_H

View file

@ -1,616 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// TODO: Implement OpenAL loading code which is currently stubbed out.
#if defined(__linux__) && !defined(TORQUE_OS_LINUX)
#define TORQUE_OS_LINUX
#endif
#include <dlfcn.h>
#include <err.h>
#include <string.h>
#include "sfx/openal/LoadOAL.h"
#include "console/console.h"
void* openal_library = NULL;
ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable)
{
if (!lpOALFnTable)
return AL_FALSE;
if (szOALFullPathName)
openal_library = dlopen(szOALFullPathName, RTLD_NOW);
else
{
#ifdef TORQUE_DEBUG
openal_library = dlopen("libopenald.so.1", RTLD_NOW);
// If the .1 library is not found, try the normal filename
if (openal_library == NULL)
{
openal_library = dlopen("libopenald.so", RTLD_NOW);
}
#else
openal_library = dlopen("libopenal.so.1", RTLD_NOW);
// If the .1 library is not found, try the normal filename
if (openal_library == NULL)
{
openal_library = dlopen("libopenal.so", RTLD_NOW);
}
#endif
}
if (openal_library == NULL) {
Con::errorf("Failed to load OpenAL shared library. Sound will not be available");
return AL_FALSE;
}
memset(lpOALFnTable, 0, sizeof(OPENALFNTABLE));
lpOALFnTable->alEnable = (LPALENABLE)dlsym(openal_library,"alEnable");
if (lpOALFnTable->alEnable == NULL)
{
warn("Failed to retrieve 'alEnable' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDisable = (LPALDISABLE)dlsym(openal_library,"alDisable");
if (lpOALFnTable->alDisable == NULL)
{
warn("Failed to retrieve 'alDisable' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsEnabled = (LPALISENABLED)dlsym(openal_library,"alIsEnabled");
if (lpOALFnTable->alIsEnabled == NULL)
{
warn("Failed to retrieve 'alIsEnabled' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBoolean = (LPALGETBOOLEAN)dlsym(openal_library,"alGetBoolean");
if (lpOALFnTable->alGetBoolean == NULL)
{
warn("Failed to retrieve 'alGetBoolean' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetInteger = (LPALGETINTEGER)dlsym(openal_library,"alGetInteger");
if (lpOALFnTable->alGetInteger == NULL)
{
warn("Failed to retrieve 'alGetInteger' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetFloat = (LPALGETFLOAT)dlsym(openal_library,"alGetFloat");
if (lpOALFnTable->alGetFloat == NULL)
{
warn("Failed to retrieve 'alGetFloat' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetDouble = (LPALGETDOUBLE)dlsym(openal_library,"alGetDouble");
if (lpOALFnTable->alGetDouble == NULL)
{
warn("Failed to retrieve 'alGetDouble' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBooleanv = (LPALGETBOOLEANV)dlsym(openal_library,"alGetBooleanv");
if (lpOALFnTable->alGetBooleanv == NULL)
{
warn("Failed to retrieve 'alGetBooleanv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetIntegerv = (LPALGETINTEGERV)dlsym(openal_library,"alGetIntegerv");
if (lpOALFnTable->alGetIntegerv == NULL)
{
warn("Failed to retrieve 'alGetIntegerv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetFloatv = (LPALGETFLOATV)dlsym(openal_library,"alGetFloatv");
if (lpOALFnTable->alGetFloatv == NULL)
{
warn("Failed to retrieve 'alGetFloatv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetDoublev = (LPALGETDOUBLEV)dlsym(openal_library,"alGetDoublev");
if (lpOALFnTable->alGetDoublev == NULL)
{
warn("Failed to retrieve 'alGetDoublev' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetString = (LPALGETSTRING)dlsym(openal_library,"alGetString");
if (lpOALFnTable->alGetString == NULL)
{
warn("Failed to retrieve 'alGetString' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetError = (LPALGETERROR)dlsym(openal_library,"alGetError");
if (lpOALFnTable->alGetError == NULL)
{
warn("Failed to retrieve 'alGetError' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsExtensionPresent = (LPALISEXTENSIONPRESENT)dlsym(openal_library,"alIsExtensionPresent");
if (lpOALFnTable->alIsExtensionPresent == NULL)
{
warn("Failed to retrieve 'alIsExtensionPresent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetProcAddress = (LPALGETPROCADDRESS)dlsym(openal_library,"alGetProcAddress");
if (lpOALFnTable->alGetProcAddress == NULL)
{
warn("Failed to retrieve 'alGetProcAddress' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEnumValue = (LPALGETENUMVALUE)dlsym(openal_library,"alGetEnumValue");
if (lpOALFnTable->alGetEnumValue == NULL)
{
warn("Failed to retrieve 'alGetEnumValue' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListeneri = (LPALLISTENERI)dlsym(openal_library,"alListeneri");
if (lpOALFnTable->alListeneri == NULL)
{
warn("Failed to retrieve 'alListeneri' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListenerf = (LPALLISTENERF)dlsym(openal_library,"alListenerf");
if (lpOALFnTable->alListenerf == NULL)
{
warn("Failed to retrieve 'alListenerf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListener3f = (LPALLISTENER3F)dlsym(openal_library,"alListener3f");
if (lpOALFnTable->alListener3f == NULL)
{
warn("Failed to retrieve 'alListener3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListenerfv = (LPALLISTENERFV)dlsym(openal_library,"alListenerfv");
if (lpOALFnTable->alListenerfv == NULL)
{
warn("Failed to retrieve 'alListenerfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListeneri = (LPALGETLISTENERI)dlsym(openal_library,"alGetListeneri");
if (lpOALFnTable->alGetListeneri == NULL)
{
warn("Failed to retrieve 'alGetListeneri' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListenerf =(LPALGETLISTENERF)dlsym(openal_library,"alGetListenerf");
if (lpOALFnTable->alGetListenerf == NULL)
{
warn("Failed to retrieve 'alGetListenerf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListener3f = (LPALGETLISTENER3F)dlsym(openal_library,"alGetListener3f");
if (lpOALFnTable->alGetListener3f == NULL)
{
warn("Failed to retrieve 'alGetListener3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListenerfv = (LPALGETLISTENERFV)dlsym(openal_library,"alGetListenerfv");
if (lpOALFnTable->alGetListenerfv == NULL)
{
warn("Failed to retrieve 'alGetListenerfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGenSources = (LPALGENSOURCES)dlsym(openal_library,"alGenSources");
if (lpOALFnTable->alGenSources == NULL)
{
warn("Failed to retrieve 'alGenSources' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteSources = (LPALDELETESOURCES)dlsym(openal_library,"alDeleteSources");
if (lpOALFnTable->alDeleteSources == NULL)
{
warn("Failed to retrieve 'alDeleteSources' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsSource = (LPALISSOURCE)dlsym(openal_library,"alIsSource");
if (lpOALFnTable->alIsSource == NULL)
{
warn("Failed to retrieve 'alIsSource' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcei = (LPALSOURCEI)dlsym(openal_library,"alSourcei");
if (lpOALFnTable->alSourcei == NULL)
{
warn("Failed to retrieve 'alSourcei' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcef = (LPALSOURCEF)dlsym(openal_library,"alSourcef");
if (lpOALFnTable->alSourcef == NULL)
{
warn("Failed to retrieve 'alSourcef' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSource3f = (LPALSOURCE3F)dlsym(openal_library,"alSource3f");
if (lpOALFnTable->alSource3f == NULL)
{
warn("Failed to retrieve 'alSource3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcefv = (LPALSOURCEFV)dlsym(openal_library,"alSourcefv");
if (lpOALFnTable->alSourcefv == NULL)
{
warn("Failed to retrieve 'alSourcefv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcei = (LPALGETSOURCEI)dlsym(openal_library,"alGetSourcei");
if (lpOALFnTable->alGetSourcei == NULL)
{
warn("Failed to retrieve 'alGetSourcei' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcef = (LPALGETSOURCEF)dlsym(openal_library,"alGetSourcef");
if (lpOALFnTable->alGetSourcef == NULL)
{
warn("Failed to retrieve 'alGetSourcef' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcefv = (LPALGETSOURCEFV)dlsym(openal_library,"alGetSourcefv");
if (lpOALFnTable->alGetSourcefv == NULL)
{
warn("Failed to retrieve 'alGetSourcefv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePlayv = (LPALSOURCEPLAYV)dlsym(openal_library,"alSourcePlayv");
if (lpOALFnTable->alSourcePlayv == NULL)
{
warn("Failed to retrieve 'alSourcePlayv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceStopv = (LPALSOURCESTOPV)dlsym(openal_library,"alSourceStopv");
if (lpOALFnTable->alSourceStopv == NULL)
{
warn("Failed to retrieve 'alSourceStopv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePlay = (LPALSOURCEPLAY)dlsym(openal_library,"alSourcePlay");
if (lpOALFnTable->alSourcePlay == NULL)
{
warn("Failed to retrieve 'alSourcePlay' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePause = (LPALSOURCEPAUSE)dlsym(openal_library,"alSourcePause");
if (lpOALFnTable->alSourcePause == NULL)
{
warn("Failed to retrieve 'alSourcePause' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceStop = (LPALSOURCESTOP)dlsym(openal_library,"alSourceStop");
if (lpOALFnTable->alSourceStop == NULL)
{
warn("Failed to retrieve 'alSourceStop' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceRewind = (LPALSOURCEREWIND)dlsym(openal_library,"alSourceRewind");
if (lpOALFnTable->alSourceRewind == NULL)
{
warn("Failed to retrieve 'alSourceRewind' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGenBuffers = (LPALGENBUFFERS)dlsym(openal_library,"alGenBuffers");
if (lpOALFnTable->alGenBuffers == NULL)
{
warn("Failed to retrieve 'alGenBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteBuffers = (LPALDELETEBUFFERS)dlsym(openal_library,"alDeleteBuffers");
if (lpOALFnTable->alDeleteBuffers == NULL)
{
warn("Failed to retrieve 'alDeleteBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsBuffer = (LPALISBUFFER)dlsym(openal_library,"alIsBuffer");
if (lpOALFnTable->alIsBuffer == NULL)
{
warn("Failed to retrieve 'alIsBuffer' function address\n");
return AL_FALSE;
}
lpOALFnTable->alBufferData = (LPALBUFFERDATA)dlsym(openal_library,"alBufferData");
if (lpOALFnTable->alBufferData == NULL)
{
warn("Failed to retrieve 'alBufferData' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBufferi = (LPALGETBUFFERI)dlsym(openal_library,"alGetBufferi");
if (lpOALFnTable->alGetBufferi == NULL)
{
warn("Failed to retrieve 'alGetBufferi' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBufferf = (LPALGETBUFFERF)dlsym(openal_library,"alGetBufferf");
if (lpOALFnTable->alGetBufferf == NULL)
{
warn("Failed to retrieve 'alGetBufferf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceQueueBuffers = (LPALSOURCEQUEUEBUFFERS)dlsym(openal_library,"alSourceQueueBuffers");
if (lpOALFnTable->alSourceQueueBuffers == NULL)
{
warn("Failed to retrieve 'alSourceQueueBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceUnqueueBuffers = (LPALSOURCEUNQUEUEBUFFERS)dlsym(openal_library,"alSourceUnqueueBuffers");
if (lpOALFnTable->alSourceUnqueueBuffers == NULL)
{
warn("Failed to retrieve 'alSourceUnqueueBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDistanceModel = (LPALDISTANCEMODEL)dlsym(openal_library,"alDistanceModel");
if (lpOALFnTable->alDistanceModel == NULL)
{
warn("Failed to retrieve 'alDistanceModel' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDopplerFactor = (LPALDOPPLERFACTOR)dlsym(openal_library,"alDopplerFactor");
if (lpOALFnTable->alDopplerFactor == NULL)
{
warn("Failed to retrieve 'alDopplerFactor' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDopplerVelocity = (LPALDOPPLERVELOCITY)dlsym(openal_library,"alDopplerVelocity");
if (lpOALFnTable->alDopplerVelocity == NULL)
{
warn("Failed to retrieve 'alDopplerVelocity' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetString = (LPALCGETSTRING)dlsym(openal_library,"alcGetString");
if (lpOALFnTable->alcGetString == NULL)
{
warn("Failed to retrieve 'alcGetString' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetIntegerv = (LPALCGETINTEGERV)dlsym(openal_library,"alcGetIntegerv");
if (lpOALFnTable->alcGetIntegerv == NULL)
{
warn("Failed to retrieve 'alcGetIntegerv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcOpenDevice = (LPALCOPENDEVICE)dlsym(openal_library,"alcOpenDevice");
if (lpOALFnTable->alcOpenDevice == NULL)
{
warn("Failed to retrieve 'alcOpenDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcCloseDevice = (LPALCCLOSEDEVICE)dlsym(openal_library,"alcCloseDevice");
if (lpOALFnTable->alcCloseDevice == NULL)
{
warn("Failed to retrieve 'alcCloseDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcCreateContext = (LPALCCREATECONTEXT)dlsym(openal_library,"alcCreateContext");
if (lpOALFnTable->alcCreateContext == NULL)
{
warn("Failed to retrieve 'alcCreateContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcMakeContextCurrent = (LPALCMAKECONTEXTCURRENT)dlsym(openal_library,"alcMakeContextCurrent");
if (lpOALFnTable->alcMakeContextCurrent == NULL)
{
warn("Failed to retrieve 'alcMakeContextCurrent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcProcessContext = (LPALCPROCESSCONTEXT)dlsym(openal_library,"alcProcessContext");
if (lpOALFnTable->alcProcessContext == NULL)
{
warn("Failed to retrieve 'alcProcessContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetCurrentContext = (LPALCGETCURRENTCONTEXT)dlsym(openal_library,"alcGetCurrentContext");
if (lpOALFnTable->alcGetCurrentContext == NULL)
{
warn("Failed to retrieve 'alcGetCurrentContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetContextsDevice = (LPALCGETCONTEXTSDEVICE)dlsym(openal_library,"alcGetContextsDevice");
if (lpOALFnTable->alcGetContextsDevice == NULL)
{
warn("Failed to retrieve 'alcGetContextsDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcSuspendContext = (LPALCSUSPENDCONTEXT)dlsym(openal_library,"alcSuspendContext");
if (lpOALFnTable->alcSuspendContext == NULL)
{
warn("Failed to retrieve 'alcSuspendContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcDestroyContext = (LPALCDESTROYCONTEXT)dlsym(openal_library,"alcDestroyContext");
if (lpOALFnTable->alcDestroyContext == NULL)
{
warn("Failed to retrieve 'alcDestroyContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetError = (LPALCGETERROR)dlsym(openal_library,"alcGetError");
if (lpOALFnTable->alcGetError == NULL)
{
warn("Failed to retrieve 'alcGetError' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcIsExtensionPresent = (LPALCISEXTENSIONPRESENT)dlsym(openal_library,"alcIsExtensionPresent");
if (lpOALFnTable->alcIsExtensionPresent == NULL)
{
warn("Failed to retrieve 'alcIsExtensionPresent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetProcAddress = (LPALCGETPROCADDRESS)dlsym(openal_library,"alcGetProcAddress");
if (lpOALFnTable->alcGetProcAddress == NULL)
{
warn("Failed to retrieve 'alcGetProcAddress' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetEnumValue = (LPALCGETENUMVALUE)dlsym(openal_library,"alcGetEnumValue");
if (lpOALFnTable->alcGetEnumValue == NULL)
{
warn("Failed to retrieve 'alcGetEnumValue' function address\n");
return AL_FALSE;
}
#if defined(AL_ALEXT_PROTOTYPES)
//efx
lpOALFnTable->alGenEffects = (LPALGENEFFECTS)dlsym(openal_library, "alGenEffects");
if (lpOALFnTable->alGenEffects == NULL)
{
warn("Failed to retrieve 'alGenEffects' function address\n");
return AL_FALSE;
}
lpOALFnTable->alEffecti = (LPALEFFECTI)dlsym(openal_library, "alEffecti");
if (lpOALFnTable->alEffecti == NULL)
{
warn("Failed to retrieve 'alEffecti' function address\n");
return AL_FALSE;
}
lpOALFnTable->alEffectiv = (LPALEFFECTIV)dlsym(openal_library, "alEffectiv");
if (lpOALFnTable->alEffectiv == NULL)
{
warn("Failed to retrieve 'alEffectiv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alEffectf = (LPALEFFECTF)dlsym(openal_library, "alEffectf");
if (lpOALFnTable->alEffectf == NULL)
{
warn("Failed to retrieve 'alEffectf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alEffectfv = (LPALEFFECTFV)dlsym(openal_library, "alEffectfv");
if (lpOALFnTable->alEffectfv == NULL)
{
warn("Failed to retrieve 'alEffectfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEffecti = (LPALGETEFFECTI)dlsym(openal_library, "alGetEffecti");
if (lpOALFnTable->alGetEffecti == NULL)
{
warn("Failed to retrieve 'alGetEffecti' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEffectiv = (LPALGETEFFECTIV)dlsym(openal_library, "alGetEffectiv");
if (lpOALFnTable->alGetEffectiv == NULL)
{
warn("Failed to retrieve 'alGetEffectiv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEffectf = (LPALGETEFFECTF)dlsym(openal_library, "alGetEffectf");
if (lpOALFnTable->alGetEffectf == NULL)
{
warn("Failed to retrieve 'alGetEffectf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEffectfv = (LPALGETEFFECTFV)dlsym(openal_library, "alGetEffectfv");
if (lpOALFnTable->alGetEffectfv == NULL)
{
warn("Failed to retrieve 'alGetEffectfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteEffects = (LPALDELETEEFFECTS)dlsym(openal_library, "alDeleteEffects");
if (lpOALFnTable->alDeleteEffects == NULL)
{
warn("Failed to retrieve 'alDeleteEffects' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsEffect = (LPALISEFFECT)dlsym(openal_library, "alIsEffect");
if (lpOALFnTable->alIsEffect == NULL)
{
warn("Failed to retrieve 'alIsEffect' function address\n");
return AL_FALSE;
}
lpOALFnTable->alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)dlsym(openal_library, "alAuxiliaryEffectSlotf");
if (lpOALFnTable->alAuxiliaryEffectSlotf == NULL)
{
warn("Failed to retrieve 'alAuxiliaryEffectSlotf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alAuxiliaryEffectSlotfv = (LPALAUXILIARYEFFECTSLOTFV)dlsym(openal_library, "alAuxiliaryEffectSlotfv");
if (lpOALFnTable->alAuxiliaryEffectSlotfv == NULL)
{
warn("Failed to retrieve 'alAuxiliaryEffectSlotfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)dlsym(openal_library, "alAuxiliaryEffectSloti");
if (lpOALFnTable->alAuxiliaryEffectSloti == NULL)
{
warn("Failed to retrieve 'alAuxiliaryEffectSloti' function address\n");
return AL_FALSE;
}
lpOALFnTable->alAuxiliaryEffectSlotiv = (LPALAUXILIARYEFFECTSLOTIV)dlsym(openal_library, "alAuxiliaryEffectSlotiv");
if (lpOALFnTable->alAuxiliaryEffectSlotiv == NULL)
{
warn("Failed to retrieve 'alAuxiliaryEffectSlotiv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)dlsym(openal_library, "alIsAuxiliaryEffectSlot");
if (lpOALFnTable->alIsAuxiliaryEffectSlot == NULL)
{
warn("Failed to retrieve 'alIsAuxiliaryEffectSlot' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)dlsym(openal_library, "alGenAuxiliaryEffectSlots");
if (lpOALFnTable->alGenAuxiliaryEffectSlots == NULL)
{
warn("Failed to retrieve 'alGenAuxiliaryEffectSlots' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)dlsym(openal_library, "alDeleteAuxiliaryEffectSlots");
if (lpOALFnTable->alDeleteAuxiliaryEffectSlots == NULL)
{
warn("Failed to retrieve 'alDeleteAuxiliaryEffectSlots' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetAuxiliaryEffectSlotf = (LPALGETAUXILIARYEFFECTSLOTF)dlsym(openal_library, "alGetAuxiliaryEffectSlotf");
if (lpOALFnTable->alGetAuxiliaryEffectSlotf == NULL)
{
warn("Failed to retrieve 'alGetAuxiliaryEffectSlotf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetAuxiliaryEffectSlotfv = (LPALGETAUXILIARYEFFECTSLOTFV)dlsym(openal_library, "alGetAuxiliaryEffectSlotfv");
if (lpOALFnTable->alGetAuxiliaryEffectSlotfv == NULL)
{
warn("Failed to retrieve 'alGetAuxiliaryEffectSlotfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetAuxiliaryEffectSloti = (LPALGETAUXILIARYEFFECTSLOTI)dlsym(openal_library, "alGetAuxiliaryEffectSloti");
if (lpOALFnTable->alGetAuxiliaryEffectSloti == NULL)
{
warn("Failed to retrieve 'alGetAuxiliaryEffectSloti' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetAuxiliaryEffectSlotiv = (LPALGETAUXILIARYEFFECTSLOTIV)dlsym(openal_library, "alGetAuxiliaryEffectSlotiv");
if (lpOALFnTable->alGetAuxiliaryEffectSlotiv == NULL)
{
warn("Failed to retrieve 'alGetAuxiliaryEffectSlotiv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSource3i = (LPALSOURCE3I)dlsym(openal_library, "alSource3i");
if (lpOALFnTable->alSource3i == NULL)
{
warn("Failed to retrieve 'alSource3i' function address\n");
return AL_FALSE;
}
#endif
return AL_TRUE;
}
ALvoid UnloadOAL10Library()
{
if (openal_library != NULL)
dlclose(openal_library);
}

View file

@ -1,618 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// TODO: Implement OpenAL loading code which is currently stubbed out.
#if defined(__MACOSX__) && !defined(TORQUE_OS_MAC)
#define TORQUE_OS_MAC
#endif
#include "console/console.h"
#include <err.h>
#include <string.h>
#include <dlfcn.h>
#include "sfx/openal/LoadOAL.h"
void* openal_library = NULL;
ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable)
{
// TODO: Implement this.
if (!lpOALFnTable)
return AL_FALSE;
if (szOALFullPathName)
openal_library = dlopen(szOALFullPathName, RTLD_NOW);
else
{
#ifdef TORQUE_DEBUG
openal_library = dlopen("@rpath/libopenald.1.23.1.dylib", RTLD_NOW);
if (openal_library == NULL)
{
openal_library = dlopen("@rpath/libopenald.1.dylib", RTLD_NOW);
}
#else
openal_library = dlopen("@rpath/libopenal.1.23.1.dylib", RTLD_NOW);
if (openal_library == NULL)
{
openal_library = dlopen("@rpath/libopenal .1.dylib", RTLD_NOW);
}
#endif
}
if (openal_library == NULL)
{
Con::errorf("Failed to load OpenAL shared library. Sound will not be available");
return AL_FALSE;
}
memset(lpOALFnTable, 0, sizeof(OPENALFNTABLE));
lpOALFnTable->alEnable = (LPALENABLE)dlsym(openal_library,"alEnable");
if (lpOALFnTable->alEnable == NULL)
{
warn("Failed to retrieve 'alEnable' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDisable = (LPALDISABLE)dlsym(openal_library,"alDisable");
if (lpOALFnTable->alDisable == NULL)
{
warn("Failed to retrieve 'alDisable' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsEnabled = (LPALISENABLED)dlsym(openal_library,"alIsEnabled");
if (lpOALFnTable->alIsEnabled == NULL)
{
warn("Failed to retrieve 'alIsEnabled' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBoolean = (LPALGETBOOLEAN)dlsym(openal_library,"alGetBoolean");
if (lpOALFnTable->alGetBoolean == NULL)
{
warn("Failed to retrieve 'alGetBoolean' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetInteger = (LPALGETINTEGER)dlsym(openal_library,"alGetInteger");
if (lpOALFnTable->alGetInteger == NULL)
{
warn("Failed to retrieve 'alGetInteger' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetFloat = (LPALGETFLOAT)dlsym(openal_library,"alGetFloat");
if (lpOALFnTable->alGetFloat == NULL)
{
warn("Failed to retrieve 'alGetFloat' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetDouble = (LPALGETDOUBLE)dlsym(openal_library,"alGetDouble");
if (lpOALFnTable->alGetDouble == NULL)
{
warn("Failed to retrieve 'alGetDouble' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBooleanv = (LPALGETBOOLEANV)dlsym(openal_library,"alGetBooleanv");
if (lpOALFnTable->alGetBooleanv == NULL)
{
warn("Failed to retrieve 'alGetBooleanv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetIntegerv = (LPALGETINTEGERV)dlsym(openal_library,"alGetIntegerv");
if (lpOALFnTable->alGetIntegerv == NULL)
{
warn("Failed to retrieve 'alGetIntegerv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetFloatv = (LPALGETFLOATV)dlsym(openal_library,"alGetFloatv");
if (lpOALFnTable->alGetFloatv == NULL)
{
warn("Failed to retrieve 'alGetFloatv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetDoublev = (LPALGETDOUBLEV)dlsym(openal_library,"alGetDoublev");
if (lpOALFnTable->alGetDoublev == NULL)
{
warn("Failed to retrieve 'alGetDoublev' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetString = (LPALGETSTRING)dlsym(openal_library,"alGetString");
if (lpOALFnTable->alGetString == NULL)
{
warn("Failed to retrieve 'alGetString' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetError = (LPALGETERROR)dlsym(openal_library,"alGetError");
if (lpOALFnTable->alGetError == NULL)
{
warn("Failed to retrieve 'alGetError' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsExtensionPresent = (LPALISEXTENSIONPRESENT)dlsym(openal_library,"alIsExtensionPresent");
if (lpOALFnTable->alIsExtensionPresent == NULL)
{
warn("Failed to retrieve 'alIsExtensionPresent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetProcAddress = (LPALGETPROCADDRESS)dlsym(openal_library,"alGetProcAddress");
if (lpOALFnTable->alGetProcAddress == NULL)
{
warn("Failed to retrieve 'alGetProcAddress' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEnumValue = (LPALGETENUMVALUE)dlsym(openal_library,"alGetEnumValue");
if (lpOALFnTable->alGetEnumValue == NULL)
{
warn("Failed to retrieve 'alGetEnumValue' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListeneri = (LPALLISTENERI)dlsym(openal_library,"alListeneri");
if (lpOALFnTable->alListeneri == NULL)
{
warn("Failed to retrieve 'alListeneri' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListenerf = (LPALLISTENERF)dlsym(openal_library,"alListenerf");
if (lpOALFnTable->alListenerf == NULL)
{
warn("Failed to retrieve 'alListenerf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListener3f = (LPALLISTENER3F)dlsym(openal_library,"alListener3f");
if (lpOALFnTable->alListener3f == NULL)
{
warn("Failed to retrieve 'alListener3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListenerfv = (LPALLISTENERFV)dlsym(openal_library,"alListenerfv");
if (lpOALFnTable->alListenerfv == NULL)
{
warn("Failed to retrieve 'alListenerfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListeneri = (LPALGETLISTENERI)dlsym(openal_library,"alGetListeneri");
if (lpOALFnTable->alGetListeneri == NULL)
{
warn("Failed to retrieve 'alGetListeneri' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListenerf =(LPALGETLISTENERF)dlsym(openal_library,"alGetListenerf");
if (lpOALFnTable->alGetListenerf == NULL)
{
warn("Failed to retrieve 'alGetListenerf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListener3f = (LPALGETLISTENER3F)dlsym(openal_library,"alGetListener3f");
if (lpOALFnTable->alGetListener3f == NULL)
{
warn("Failed to retrieve 'alGetListener3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListenerfv = (LPALGETLISTENERFV)dlsym(openal_library,"alGetListenerfv");
if (lpOALFnTable->alGetListenerfv == NULL)
{
warn("Failed to retrieve 'alGetListenerfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGenSources = (LPALGENSOURCES)dlsym(openal_library,"alGenSources");
if (lpOALFnTable->alGenSources == NULL)
{
warn("Failed to retrieve 'alGenSources' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteSources = (LPALDELETESOURCES)dlsym(openal_library,"alDeleteSources");
if (lpOALFnTable->alDeleteSources == NULL)
{
warn("Failed to retrieve 'alDeleteSources' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsSource = (LPALISSOURCE)dlsym(openal_library,"alIsSource");
if (lpOALFnTable->alIsSource == NULL)
{
warn("Failed to retrieve 'alIsSource' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcei = (LPALSOURCEI)dlsym(openal_library,"alSourcei");
if (lpOALFnTable->alSourcei == NULL)
{
warn("Failed to retrieve 'alSourcei' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcef = (LPALSOURCEF)dlsym(openal_library,"alSourcef");
if (lpOALFnTable->alSourcef == NULL)
{
warn("Failed to retrieve 'alSourcef' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSource3f = (LPALSOURCE3F)dlsym(openal_library,"alSource3f");
if (lpOALFnTable->alSource3f == NULL)
{
warn("Failed to retrieve 'alSource3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcefv = (LPALSOURCEFV)dlsym(openal_library,"alSourcefv");
if (lpOALFnTable->alSourcefv == NULL)
{
warn("Failed to retrieve 'alSourcefv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcei = (LPALGETSOURCEI)dlsym(openal_library,"alGetSourcei");
if (lpOALFnTable->alGetSourcei == NULL)
{
warn("Failed to retrieve 'alGetSourcei' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcef = (LPALGETSOURCEF)dlsym(openal_library,"alGetSourcef");
if (lpOALFnTable->alGetSourcef == NULL)
{
warn("Failed to retrieve 'alGetSourcef' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcefv = (LPALGETSOURCEFV)dlsym(openal_library,"alGetSourcefv");
if (lpOALFnTable->alGetSourcefv == NULL)
{
warn("Failed to retrieve 'alGetSourcefv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePlayv = (LPALSOURCEPLAYV)dlsym(openal_library,"alSourcePlayv");
if (lpOALFnTable->alSourcePlayv == NULL)
{
warn("Failed to retrieve 'alSourcePlayv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceStopv = (LPALSOURCESTOPV)dlsym(openal_library,"alSourceStopv");
if (lpOALFnTable->alSourceStopv == NULL)
{
warn("Failed to retrieve 'alSourceStopv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePlay = (LPALSOURCEPLAY)dlsym(openal_library,"alSourcePlay");
if (lpOALFnTable->alSourcePlay == NULL)
{
warn("Failed to retrieve 'alSourcePlay' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePause = (LPALSOURCEPAUSE)dlsym(openal_library,"alSourcePause");
if (lpOALFnTable->alSourcePause == NULL)
{
warn("Failed to retrieve 'alSourcePause' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceStop = (LPALSOURCESTOP)dlsym(openal_library,"alSourceStop");
if (lpOALFnTable->alSourceStop == NULL)
{
warn("Failed to retrieve 'alSourceStop' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceRewind = (LPALSOURCEREWIND)dlsym(openal_library,"alSourceRewind");
if (lpOALFnTable->alSourceRewind == NULL)
{
warn("Failed to retrieve 'alSourceRewind' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGenBuffers = (LPALGENBUFFERS)dlsym(openal_library,"alGenBuffers");
if (lpOALFnTable->alGenBuffers == NULL)
{
warn("Failed to retrieve 'alGenBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteBuffers = (LPALDELETEBUFFERS)dlsym(openal_library,"alDeleteBuffers");
if (lpOALFnTable->alDeleteBuffers == NULL)
{
warn("Failed to retrieve 'alDeleteBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsBuffer = (LPALISBUFFER)dlsym(openal_library,"alIsBuffer");
if (lpOALFnTable->alIsBuffer == NULL)
{
warn("Failed to retrieve 'alIsBuffer' function address\n");
return AL_FALSE;
}
lpOALFnTable->alBufferData = (LPALBUFFERDATA)dlsym(openal_library,"alBufferData");
if (lpOALFnTable->alBufferData == NULL)
{
warn("Failed to retrieve 'alBufferData' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBufferi = (LPALGETBUFFERI)dlsym(openal_library,"alGetBufferi");
if (lpOALFnTable->alGetBufferi == NULL)
{
warn("Failed to retrieve 'alGetBufferi' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBufferf = (LPALGETBUFFERF)dlsym(openal_library,"alGetBufferf");
if (lpOALFnTable->alGetBufferf == NULL)
{
warn("Failed to retrieve 'alGetBufferf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceQueueBuffers = (LPALSOURCEQUEUEBUFFERS)dlsym(openal_library,"alSourceQueueBuffers");
if (lpOALFnTable->alSourceQueueBuffers == NULL)
{
warn("Failed to retrieve 'alSourceQueueBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceUnqueueBuffers = (LPALSOURCEUNQUEUEBUFFERS)dlsym(openal_library,"alSourceUnqueueBuffers");
if (lpOALFnTable->alSourceUnqueueBuffers == NULL)
{
warn("Failed to retrieve 'alSourceUnqueueBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDistanceModel = (LPALDISTANCEMODEL)dlsym(openal_library,"alDistanceModel");
if (lpOALFnTable->alDistanceModel == NULL)
{
warn("Failed to retrieve 'alDistanceModel' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDopplerFactor = (LPALDOPPLERFACTOR)dlsym(openal_library,"alDopplerFactor");
if (lpOALFnTable->alDopplerFactor == NULL)
{
warn("Failed to retrieve 'alDopplerFactor' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDopplerVelocity = (LPALDOPPLERVELOCITY)dlsym(openal_library,"alDopplerVelocity");
if (lpOALFnTable->alDopplerVelocity == NULL)
{
warn("Failed to retrieve 'alDopplerVelocity' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetString = (LPALCGETSTRING)dlsym(openal_library,"alcGetString");
if (lpOALFnTable->alcGetString == NULL)
{
warn("Failed to retrieve 'alcGetString' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetIntegerv = (LPALCGETINTEGERV)dlsym(openal_library,"alcGetIntegerv");
if (lpOALFnTable->alcGetIntegerv == NULL)
{
warn("Failed to retrieve 'alcGetIntegerv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcOpenDevice = (LPALCOPENDEVICE)dlsym(openal_library,"alcOpenDevice");
if (lpOALFnTable->alcOpenDevice == NULL)
{
warn("Failed to retrieve 'alcOpenDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcCloseDevice = (LPALCCLOSEDEVICE)dlsym(openal_library,"alcCloseDevice");
if (lpOALFnTable->alcCloseDevice == NULL)
{
warn("Failed to retrieve 'alcCloseDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcCreateContext = (LPALCCREATECONTEXT)dlsym(openal_library,"alcCreateContext");
if (lpOALFnTable->alcCreateContext == NULL)
{
warn("Failed to retrieve 'alcCreateContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcMakeContextCurrent = (LPALCMAKECONTEXTCURRENT)dlsym(openal_library,"alcMakeContextCurrent");
if (lpOALFnTable->alcMakeContextCurrent == NULL)
{
warn("Failed to retrieve 'alcMakeContextCurrent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcProcessContext = (LPALCPROCESSCONTEXT)dlsym(openal_library,"alcProcessContext");
if (lpOALFnTable->alcProcessContext == NULL)
{
warn("Failed to retrieve 'alcProcessContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetCurrentContext = (LPALCGETCURRENTCONTEXT)dlsym(openal_library,"alcGetCurrentContext");
if (lpOALFnTable->alcGetCurrentContext == NULL)
{
warn("Failed to retrieve 'alcGetCurrentContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetContextsDevice = (LPALCGETCONTEXTSDEVICE)dlsym(openal_library,"alcGetContextsDevice");
if (lpOALFnTable->alcGetContextsDevice == NULL)
{
warn("Failed to retrieve 'alcGetContextsDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcSuspendContext = (LPALCSUSPENDCONTEXT)dlsym(openal_library,"alcSuspendContext");
if (lpOALFnTable->alcSuspendContext == NULL)
{
warn("Failed to retrieve 'alcSuspendContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcDestroyContext = (LPALCDESTROYCONTEXT)dlsym(openal_library,"alcDestroyContext");
if (lpOALFnTable->alcDestroyContext == NULL)
{
warn("Failed to retrieve 'alcDestroyContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetError = (LPALCGETERROR)dlsym(openal_library,"alcGetError");
if (lpOALFnTable->alcGetError == NULL)
{
warn("Failed to retrieve 'alcGetError' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcIsExtensionPresent = (LPALCISEXTENSIONPRESENT)dlsym(openal_library,"alcIsExtensionPresent");
if (lpOALFnTable->alcIsExtensionPresent == NULL)
{
warn("Failed to retrieve 'alcIsExtensionPresent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetProcAddress = (LPALCGETPROCADDRESS)dlsym(openal_library,"alcGetProcAddress");
if (lpOALFnTable->alcGetProcAddress == NULL)
{
warn("Failed to retrieve 'alcGetProcAddress' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetEnumValue = (LPALCGETENUMVALUE)dlsym(openal_library,"alcGetEnumValue");
if (lpOALFnTable->alcGetEnumValue == NULL)
{
warn("Failed to retrieve 'alcGetEnumValue' function address\n");
return AL_FALSE;
}
#if defined(AL_ALEXT_PROTOTYPES)
//efx
lpOALFnTable->alGenEffects = (LPALGENEFFECTS)dlsym(openal_library, "alGenEffects");
if (lpOALFnTable->alGenEffects == NULL)
{
warn("Failed to retrieve 'alGenEffects' function address\n");
return AL_FALSE;
}
lpOALFnTable->alEffecti = (LPALEFFECTI)dlsym(openal_library, "alEffecti");
if (lpOALFnTable->alEffecti == NULL)
{
warn("Failed to retrieve 'alEffecti' function address\n");
return AL_FALSE;
}
lpOALFnTable->alEffectiv = (LPALEFFECTIV)dlsym(openal_library, "alEffectiv");
if (lpOALFnTable->alEffectiv == NULL)
{
warn("Failed to retrieve 'alEffectiv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alEffectf = (LPALEFFECTF)dlsym(openal_library, "alEffectf");
if (lpOALFnTable->alEffectf == NULL)
{
warn("Failed to retrieve 'alEffectf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alEffectfv = (LPALEFFECTFV)dlsym(openal_library, "alEffectfv");
if (lpOALFnTable->alEffectfv == NULL)
{
warn("Failed to retrieve 'alEffectfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEffecti = (LPALGETEFFECTI)dlsym(openal_library, "alGetEffecti");
if (lpOALFnTable->alGetEffecti == NULL)
{
warn("Failed to retrieve 'alGetEffecti' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEffectiv = (LPALGETEFFECTIV)dlsym(openal_library, "alGetEffectiv");
if (lpOALFnTable->alGetEffectiv == NULL)
{
warn("Failed to retrieve 'alGetEffectiv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEffectf = (LPALGETEFFECTF)dlsym(openal_library, "alGetEffectf");
if (lpOALFnTable->alGetEffectf == NULL)
{
warn("Failed to retrieve 'alGetEffectf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEffectfv = (LPALGETEFFECTFV)dlsym(openal_library, "alGetEffectfv");
if (lpOALFnTable->alGetEffectfv == NULL)
{
warn("Failed to retrieve 'alGetEffectfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteEffects = (LPALDELETEEFFECTS)dlsym(openal_library, "alDeleteEffects");
if (lpOALFnTable->alDeleteEffects == NULL)
{
warn("Failed to retrieve 'alDeleteEffects' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsEffect = (LPALISEFFECT)dlsym(openal_library, "alIsEffect");
if (lpOALFnTable->alIsEffect == NULL)
{
warn("Failed to retrieve 'alIsEffect' function address\n");
return AL_FALSE;
}
lpOALFnTable->alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)dlsym(openal_library, "alAuxiliaryEffectSlotf");
if (lpOALFnTable->alAuxiliaryEffectSlotf == NULL)
{
warn("Failed to retrieve 'alAuxiliaryEffectSlotf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alAuxiliaryEffectSlotfv = (LPALAUXILIARYEFFECTSLOTFV)dlsym(openal_library, "alAuxiliaryEffectSlotfv");
if (lpOALFnTable->alAuxiliaryEffectSlotfv == NULL)
{
warn("Failed to retrieve 'alAuxiliaryEffectSlotfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)dlsym(openal_library, "alAuxiliaryEffectSloti");
if (lpOALFnTable->alAuxiliaryEffectSloti == NULL)
{
warn("Failed to retrieve 'alAuxiliaryEffectSloti' function address\n");
return AL_FALSE;
}
lpOALFnTable->alAuxiliaryEffectSlotiv = (LPALAUXILIARYEFFECTSLOTIV)dlsym(openal_library, "alAuxiliaryEffectSlotiv");
if (lpOALFnTable->alAuxiliaryEffectSlotiv == NULL)
{
warn("Failed to retrieve 'alAuxiliaryEffectSlotiv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)dlsym(openal_library, "alIsAuxiliaryEffectSlot");
if (lpOALFnTable->alIsAuxiliaryEffectSlot == NULL)
{
warn("Failed to retrieve 'alIsAuxiliaryEffectSlot' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)dlsym(openal_library, "alGenAuxiliaryEffectSlots");
if (lpOALFnTable->alGenAuxiliaryEffectSlots == NULL)
{
warn("Failed to retrieve 'alGenAuxiliaryEffectSlots' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)dlsym(openal_library, "alDeleteAuxiliaryEffectSlots");
if (lpOALFnTable->alDeleteAuxiliaryEffectSlots == NULL)
{
warn("Failed to retrieve 'alDeleteAuxiliaryEffectSlots' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetAuxiliaryEffectSlotf = (LPALGETAUXILIARYEFFECTSLOTF)dlsym(openal_library, "alGetAuxiliaryEffectSlotf");
if (lpOALFnTable->alGetAuxiliaryEffectSlotf == NULL)
{
warn("Failed to retrieve 'alGetAuxiliaryEffectSlotf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetAuxiliaryEffectSlotfv = (LPALGETAUXILIARYEFFECTSLOTFV)dlsym(openal_library, "alGetAuxiliaryEffectSlotfv");
if (lpOALFnTable->alGetAuxiliaryEffectSlotfv == NULL)
{
warn("Failed to retrieve 'alGetAuxiliaryEffectSlotfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetAuxiliaryEffectSloti = (LPALGETAUXILIARYEFFECTSLOTI)dlsym(openal_library, "alGetAuxiliaryEffectSloti");
if (lpOALFnTable->alGetAuxiliaryEffectSloti == NULL)
{
warn("Failed to retrieve 'alGetAuxiliaryEffectSloti' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetAuxiliaryEffectSlotiv = (LPALGETAUXILIARYEFFECTSLOTIV)dlsym(openal_library, "alGetAuxiliaryEffectSlotiv");
if (lpOALFnTable->alGetAuxiliaryEffectSlotiv == NULL)
{
warn("Failed to retrieve 'alGetAuxiliaryEffectSlotiv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSource3i = (LPALSOURCE3I)dlsym(openal_library, "alSource3i");
if (lpOALFnTable->alSource3i == NULL)
{
warn("Failed to retrieve 'alSource3i' function address\n");
return AL_FALSE;
}
#endif
return AL_TRUE;
}
ALvoid UnloadOAL10Library()
{
if (openal_library != NULL)
dlclose(openal_library);
}

View file

@ -30,8 +30,7 @@
//#define DEBUG_SPEW
SFXALBuffer* SFXALBuffer::create( const OPENALFNTABLE &oalft,
const ThreadSafeRef< SFXStream >& stream,
SFXALBuffer* SFXALBuffer::create( const ThreadSafeRef< SFXStream >& stream,
SFXDescription* description,
bool useHardware )
{
@ -41,27 +40,24 @@ SFXALBuffer* SFXALBuffer::create( const OPENALFNTABLE &oalft,
return NULL;
}
SFXALBuffer *buffer = new SFXALBuffer( oalft,
stream,
SFXALBuffer *buffer = new SFXALBuffer( stream,
description,
useHardware );
return buffer;
}
SFXALBuffer::SFXALBuffer( const OPENALFNTABLE &oalft,
const ThreadSafeRef< SFXStream >& stream,
SFXALBuffer::SFXALBuffer( const ThreadSafeRef< SFXStream >& stream,
SFXDescription* description,
bool useHardware )
: Parent( stream, description ),
mIs3d( description->mIs3D ),
mUseHardware( useHardware ),
mOpenAL( oalft )
mUseHardware( useHardware )
{
// Set up device buffers.
if( !isStreaming() )
mOpenAL.alGenBuffers( 1, &mALBuffer );
alGenBuffers( 1, &mALBuffer );
}
SFXALBuffer::~SFXALBuffer()
@ -70,13 +66,13 @@ SFXALBuffer::~SFXALBuffer()
_getUniqueVoice()->stop();
// Release buffers.
if ( mOpenAL.alIsBuffer( mALBuffer ))
mOpenAL.alDeleteBuffers( 1, &mALBuffer );
if ( alIsBuffer( mALBuffer ))
alDeleteBuffers( 1, &mALBuffer );
while( mFreeBuffers.size() )
{
ALuint buffer = mFreeBuffers.last();
mOpenAL.alDeleteBuffers( 1, &buffer );
alDeleteBuffers( 1, &buffer );
mFreeBuffers.pop_back();
}
}
@ -98,7 +94,7 @@ void SFXALBuffer::write( SFXInternal::SFXStreamPacket* const* packets, U32 num )
ALenum alFormat = _sfxFormatToALFormat( getFormat() );
AssertFatal( alFormat != 0, "SFXALBuffer::write() - format unsupported" );
mOpenAL.alBufferData( mALBuffer, alFormat,
alBufferData( mALBuffer, alFormat,
packet->data, packet->mSizeActual, getFormat().getSamplesPerSecond() );
destructSingle( packet );
@ -112,19 +108,19 @@ void SFXALBuffer::write( SFXInternal::SFXStreamPacket* const* packets, U32 num )
ALuint source = _getUniqueVoice()->mSourceName;
ALint numProcessed;
mOpenAL.alGetSourcei( source, AL_BUFFERS_PROCESSED, &numProcessed );
alGetSourcei( source, AL_BUFFERS_PROCESSED, &numProcessed );
for( U32 i = 0; i < numProcessed; ++ i )
{
// Unqueue the buffer.
ALuint buffer;
mOpenAL.alSourceUnqueueBuffers( source, 1, &buffer );
alSourceUnqueueBuffers( source, 1, &buffer );
// Update the sample offset on the voice.
ALint size;
mOpenAL.alGetBufferi( buffer, AL_SIZE, &size );
alGetBufferi( buffer, AL_SIZE, &size );
_getUniqueVoice()->mSampleOffset += size / getFormat().getBytesPerSample();
// Push the buffer onto the freelist.
@ -147,22 +143,22 @@ void SFXALBuffer::write( SFXInternal::SFXStreamPacket* const* packets, U32 num )
mFreeBuffers.pop_back();
}
else
mOpenAL.alGenBuffers( 1, &buffer );
alGenBuffers( 1, &buffer );
// Upload the data.
ALenum alFormat = _sfxFormatToALFormat( getFormat() );
AssertFatal( alFormat != 0, "SFXALBuffer::write() - format unsupported" );
AssertFatal( mOpenAL.alIsBuffer( buffer ), "SFXALBuffer::write() - buffer invalid" );
AssertFatal( alIsBuffer( buffer ), "SFXALBuffer::write() - buffer invalid" );
mOpenAL.alBufferData( buffer, alFormat,
alBufferData( buffer, alFormat,
packet->data, packet->mSizeActual, getFormat().getSamplesPerSecond() );
destructSingle( packet );
// Queue the buffer.
mOpenAL.alSourceQueueBuffers( source, 1, &buffer );
alSourceQueueBuffers( source, 1, &buffer );
}
}
@ -183,12 +179,12 @@ void SFXALBuffer::_flush()
ALuint source = _getUniqueVoice()->mSourceName;
ALint numQueued;
mOpenAL.alGetSourcei( source, AL_BUFFERS_QUEUED, &numQueued );
alGetSourcei( source, AL_BUFFERS_QUEUED, &numQueued );
for( U32 i = 0; i < numQueued; ++ i )
{
ALuint buffer;
mOpenAL.alSourceUnqueueBuffers( source, 1, &buffer );
alSourceUnqueueBuffers( source, 1, &buffer );
mFreeBuffers.push_back( buffer );
}
@ -203,20 +199,20 @@ void SFXALBuffer::_flush()
// issues any concurrent state changes on the voice resulting in us losing state here.
ALuint newSource;
mOpenAL.alGenSources( 1, &newSource );
alGenSources( 1, &newSource );
#define COPY_F( name ) \
{ \
F32 val; \
mOpenAL.alGetSourcef( source, name, &val ); \
mOpenAL.alSourcef( source, name, val ); \
alGetSourcef( source, name, &val ); \
alSourcef( source, name, val ); \
}
#define COPY_FV( name ) \
{ \
VectorF val; \
mOpenAL.alGetSourcefv( source, name, val ); \
mOpenAL.alSourcefv( source, name, val ); \
alGetSourcefv( source, name, val ); \
alSourcefv( source, name, val ); \
}
COPY_F( AL_REFERENCE_DISTANCE );
@ -232,7 +228,7 @@ void SFXALBuffer::_flush()
COPY_FV( AL_DIRECTION );
_getUniqueVoice()->mSourceName = newSource;
mOpenAL.alDeleteSources( 1, &source );
alDeleteSources( 1, &source );
#endif
}

View file

@ -24,13 +24,13 @@
#define _SFXALBUFFER_H_
#ifndef _LOADOAL_H
#include "sfx/openal/LoadOAL.h"
#include "sfx/openal/LoadOAL.h"
#endif
#ifndef _SFXINTERNAL_H_
#include "sfx/sfxInternal.h"
#include "sfx/sfxInternal.h"
#endif
#ifndef _TVECTOR_H_
#include "core/util/tVector.h"
#include "core/util/tVector.h"
#endif
@ -39,81 +39,95 @@ class SFXALVoice;
class SFXALBuffer : public SFXBuffer
{
public:
public:
typedef SFXBuffer Parent;
typedef SFXBuffer Parent;
friend class SFXALDevice;
friend class SFXALVoice;
friend class SFXALDevice;
friend class SFXALVoice;
protected:
/// AL buffer in case this is a static, non-streaming buffer.
ALuint mALBuffer;
/// Free buffers for use in queuing in case this is a streaming buffer.
Vector< ALuint > mFreeBuffers;
protected:
///
SFXALBuffer( const OPENALFNTABLE &oalft,
const ThreadSafeRef< SFXStream >& stream,
SFXDescription* description,
bool useHardware );
/// AL buffer in case this is a static, non-streaming buffer.
ALuint mALBuffer;
///
bool mIs3d;
/// Free buffers for use in queuing in case this is a streaming buffer.
Vector< ALuint > mFreeBuffers;
///
bool mUseHardware;
///
SFXALBuffer(const ThreadSafeRef< SFXStream >& stream,
SFXDescription* description,
bool useHardware);
const OPENALFNTABLE &mOpenAL;
///
bool mIs3d;
///
ALenum _getALFormat() const
///
bool mUseHardware;
///
ALenum _getALFormat() const
{
return _sfxFormatToALFormat(getFormat());
}
///
static ALenum _sfxFormatToALFormat(const SFXFormat& format)
{
const U32 channels = format.getChannels();
const SFXSampleType type = format.getSampleType();
switch (type)
{
return _sfxFormatToALFormat( getFormat() );
case Sample_Int8:
if (channels == 1) return AL_FORMAT_MONO8;
if (channels == 2) return AL_FORMAT_STEREO8;
break;
case Sample_Int16:
if (channels == 1) return AL_FORMAT_MONO16;
if (channels == 2) return AL_FORMAT_STEREO16;
break;
case Sample_Float:
if (channels == 1) return AL_FORMAT_MONO_FLOAT32;
if (channels == 2) return AL_FORMAT_STEREO_FLOAT32;
break;
case Sample_IMA4:
if (channels == 1) return AL_FORMAT_MONO_IMA4;
if (channels == 2) return AL_FORMAT_STEREO_IMA4;
break;
case Sample_MSADPCM:
// Requires OpenAL Soft MSADPCM extension
if (channels == 1) return AL_FORMAT_MONO_MSADPCM_SOFT;
if (channels == 2) return AL_FORMAT_STEREO_MSADPCM_SOFT;
break;
}
///
static ALenum _sfxFormatToALFormat( const SFXFormat& format )
{
if( format.getChannels() == 2 )
{
const U32 bps = format.getBitsPerSample();
if( bps == 16 )
return AL_FORMAT_STEREO8;
else if( bps == 32 )
return AL_FORMAT_STEREO16;
}
else if( format.getChannels() == 1 )
{
const U32 bps = format.getBitsPerSample();
if( bps == 8 )
return AL_FORMAT_MONO8;
else if( bps == 16 )
return AL_FORMAT_MONO16;
}
return 0;
}
// Unsupported channel count or layout
Con::errorf("_sfxFormatToALFormat - Unsupported format: channels=%d, type=%d",
channels, type);
return 0;
}
///
SFXALVoice* _getUniqueVoice() const
{
return ( SFXALVoice* ) mUniqueVoice.getPointer();
}
///
SFXALVoice* _getUniqueVoice() const
{
return (SFXALVoice*)mUniqueVoice.getPointer();
}
// SFXBuffer.
void write( SFXInternal::SFXStreamPacket* const* packets, U32 num ) override;
void _flush() override;
// SFXBuffer.
void write(SFXInternal::SFXStreamPacket* const* packets, U32 num) override;
void _flush() override;
public:
public:
static SFXALBuffer* create( const OPENALFNTABLE &oalft,
const ThreadSafeRef< SFXStream >& stream,
SFXDescription* description,
bool useHardware );
static SFXALBuffer* create(const ThreadSafeRef< SFXStream >& stream,
SFXDescription* description,
bool useHardware);
virtual ~SFXALBuffer();
virtual ~SFXALBuffer();
};
#endif // _SFXALBUFFER_H_
#endif // _SFXALBUFFER_H_

View file

@ -24,6 +24,90 @@
#include "sfx/openal/sfxALBuffer.h"
#include "platform/async/asyncUpdate.h"
#include "AL/al.h"
#include "AL/alc.h"
#include "AL/efx.h"
#include "AL/alext.h"
#ifndef ALC_CONNECTED
#define ALC_CONNECTED 0x313
#endif
#ifndef ALC_DEVICE_CLOCK_SOFT
#define ALC_DEVICE_CLOCK_SOFT 0x1600
#endif
#ifndef ALC_DEVICE_LATENCY_SOFT
#define ALC_DEVICE_LATENCY_SOFT 0x1601
#endif
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define FUNCTION_CAST(T, ptr) (union{void *p; T f;}){ptr}.f
#elif defined(__cplusplus)
#define FUNCTION_CAST(T, ptr) reinterpret_cast<T>(ptr)
#else
#define FUNCTION_CAST(T, ptr) (T)(ptr)
#endif
/* Effect object functions */
static LPALGENFILTERS alGenFilters{ nullptr };
static LPALDELETEFILTERS alDeleteFilters{ nullptr };
static LPALISFILTER alIsFilter{ nullptr };
static LPALFILTERF alFilterf{ nullptr };
static LPALFILTERFV alFilterfv{ nullptr };
static LPALFILTERI alFilteri{ nullptr };
static LPALFILTERIV alFilteriv{ nullptr };
static LPALGETFILTERF alGetFilterf{ nullptr };
static LPALGETFILTERFV alGetFilterfv{ nullptr };
static LPALGETFILTERI alGetFilteri{ nullptr };
static LPALGETFILTERIV alGetFilteriv{ nullptr };
static LPALGENEFFECTS alGenEffects{ nullptr };
static LPALDELETEEFFECTS alDeleteEffects{ nullptr };
static LPALISEFFECT alIsEffect{ nullptr };
static LPALEFFECTF alEffectf{ nullptr };
static LPALEFFECTFV alEffectfv{ nullptr };
static LPALEFFECTI alEffecti{ nullptr };
static LPALEFFECTIV alEffectiv{ nullptr };
static LPALGETEFFECTF alGetEffectf{ nullptr };
static LPALGETEFFECTFV alGetEffectfv{ nullptr };
static LPALGETEFFECTI alGetEffecti{ nullptr };
static LPALGETEFFECTIV alGetEffectiv{ nullptr };
static LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots{ nullptr };
static LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots{ nullptr };
static LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot{ nullptr };
static LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf{ nullptr };
static LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv{ nullptr };
static LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti{ nullptr };
static LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv{ nullptr };
static LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf{ nullptr };
static LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv{ nullptr };
static LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti{ nullptr };
static LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv{ nullptr };
static LPALCGETSTRINGISOFT alcGetStringiSOFT{ nullptr };
static LPALCRESETDEVICESOFT alcResetDeviceSOFT{ nullptr };
static LPALCREOPENDEVICESOFT alcReopenDeviceSOFT{ nullptr };
static LPALCGETINTEGER64VSOFT alcGetInteger64vSOFT{ nullptr };
class SFXALRegisterProvider
{
public:
SFXALRegisterProvider()
{
SFXSystem::getRegisterProviderSignal().notify(&SFXALDevice::enumerateProviders);
}
};
static SFXALRegisterProvider pSFXALRegisterProvider;
SFXProvider::CreateProviderInstanceDelegate SFXALDevice::mCreateDeviceInstance(SFXALDevice::createInstance);
SFXDevice* SFXALDevice::createInstance(U32 providerIndex)
{
SFXALDevice* dev = new SFXALDevice(providerIndex);
return dev;
}
//----------------------------------------------------------------------------
// STATIC OPENAL FUNCTIONS
//----------------------------------------------------------------------------
@ -35,39 +119,54 @@ void SFXALDevice::printALInfo(ALCdevice* device)
const ALCchar* devname = NULL;
Con::printBlankLine();
if (mOpenAL.alcIsExtensionPresent(device, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
if (alcIsExtensionPresent(device, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
{
devname = mOpenAL.alcGetString(device, ALC_ALL_DEVICES_SPECIFIER);
devname = alcGetString(device, ALC_ALL_DEVICES_SPECIFIER);
}
else
{
devname = mOpenAL.alcGetString(device, ALC_DEVICE_SPECIFIER);
devname = alcGetString(device, ALC_DEVICE_SPECIFIER);
}
Con::printf("| Device info for: %s ", devname);
}
mOpenAL.alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major);
mOpenAL.alcGetIntegerv(device, ALC_MINOR_VERSION, 1, &minor);
alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major);
alcGetIntegerv(device, ALC_MINOR_VERSION, 1, &minor);
Con::printf("| OpenAL Version: %d.%d", major, minor);
if (device)
{
Con::printf("%s", mOpenAL.alcGetString(device, ALC_EXTENSIONS));
const ALchar* extStr = alcGetString(device, ALC_EXTENSIONS);
if (extStr)
{
Con::printf("| SFXALDevice - Supported ALC extensions:");
U32 err = mOpenAL.alcGetError(device);
// Copy to a modifiable string.
char* extCopy = dStrdup(extStr);
char* token = dStrtok(extCopy, " ");
while (token)
{
Con::printf("| %s", token);
token = dStrtok(NULL, " ");
}
dFree(extCopy);
}
U32 err = alcGetError(device);
if (err != ALC_NO_ERROR)
Con::errorf("SFXALDevice - Error Retrieving ALC Extensions: %s", mOpenAL.alcGetString(device, err));
Con::errorf("SFXALDevice - Error Retrieving ALC Extensions: %s", alcGetString(device, err));
}
}
S32 SFXALDevice::getMaxSources()
{
mOpenAL.alGetError();
alGetError();
ALCint nummono;
mOpenAL.alcGetIntegerv(mDevice, ALC_MONO_SOURCES, 1, &nummono);
alcGetIntegerv(mDevice, ALC_MONO_SOURCES, 1, &nummono);
if(nummono == 0)
nummono = getMaxSourcesOld();
@ -81,21 +180,21 @@ S32 SFXALDevice::getMaxSourcesOld()
S32 sourceCount = 0;
// clear errors.
mOpenAL.alGetError();
alGetError();
for(sourceCount = 0; sourceCount < 256; sourceCount++)
{
mOpenAL.alGenSources(1,&uiSource[sourceCount]);
if(mOpenAL.alGetError() != AL_NO_ERROR)
alGenSources(1,&uiSource[sourceCount]);
if(alGetError() != AL_NO_ERROR)
break;
}
mOpenAL.alDeleteSources(sourceCount, uiSource);
if(mOpenAL.alGetError() != AL_NO_ERROR)
alDeleteSources(sourceCount, uiSource);
if(alGetError() != AL_NO_ERROR)
{
for(U32 i = 0; i < 256; i++)
{
mOpenAL.alDeleteSources(1,&uiSource[i]);
alDeleteSources(1,&uiSource[i]);
}
}
@ -103,55 +202,31 @@ S32 SFXALDevice::getMaxSourcesOld()
}
//-----------------------------------------------------------------------------
SFXALDevice::SFXALDevice( SFXProvider *provider,
const OPENALFNTABLE &openal,
String name,
bool useHardware,
S32 maxBuffers )
: Parent( name, provider, useHardware, maxBuffers ),
mOpenAL( openal ),
mContext( NULL ),
mDevice( NULL ),
SFXALDevice::SFXALDevice(U32 providerIndex)
: mContext(NULL),
mDevice(NULL),
mDistanceModel(SFXDistanceModelLinear),
mDistanceFactor(1.0f),
mRolloffFactor( 1.0f ),
mRolloffFactor(1.0f),
mUserRolloffFactor(1.0f)
{
mMaxBuffers = getMax( maxBuffers, 8 );
SFXProvider* p = SFXSystem::getProvider(providerIndex);
// TODO: The OpenAL device doesn't set the primary buffer
// $pref::SFX::frequency or $pref::SFX::bitrate!
//check auxiliary device sends 4 and add them to the device
ALint attribs[4] = { 0 };
#if defined(AL_ALEXT_PROTOTYPES)
ALCint iSends = 0;
attribs[0] = ALC_MAX_AUXILIARY_SENDS;
#endif
attribs[1] = 4;
mDevice = alcOpenDevice(p->getName());
printALInfo(NULL);
mDevice = mOpenAL.alcOpenDevice( name );
U32 err = mOpenAL.alcGetError(mDevice);
U32 err = alcGetError(mDevice);
if (err != ALC_NO_ERROR)
Con::errorf("SFXALDevice - Device Initialization Error: %s", mOpenAL.alcGetString(mDevice, err));
Con::errorf("SFXALDevice - Device Initialization Error: %s", alcGetString(mDevice, err));
if( mDevice )
if (mDevice)
{
mContext = mOpenAL.alcCreateContext( mDevice, attribs );
mContext = alcCreateContext(mDevice, NULL);
if( mContext )
mOpenAL.alcMakeContextCurrent( mContext );
if (mContext)
alcMakeContextCurrent(mContext);
#if defined(AL_ALEXT_PROTOTYPES)
mOpenAL.alcGetIntegerv(mDevice, ALC_MAX_AUXILIARY_SENDS, 1, &iSends);
#endif
err = mOpenAL.alcGetError( mDevice );
if( err != ALC_NO_ERROR )
Con::errorf( "SFXALDevice - Context Initialization Error: %s", mOpenAL.alcGetString( mDevice, err ) );
Con::errorf( "SFXALDevice - Context Initialization Error: %s", alcGetString( mDevice, err ) );
}
AssertFatal( mDevice != NULL && mContext != NULL, "Failed to create OpenAL device and/or context!" );
@ -168,20 +243,64 @@ SFXALDevice::SFXALDevice( SFXProvider *provider,
}
#endif
#if defined(AL_ALEXT_PROTOTYPES)
dMemset(effectSlot, 0, sizeof(effectSlot));
dMemset(effect, 0, sizeof(effect));
uLoop = 0;
#endif
// --- Capabilities ---
if (alcIsExtensionPresent(mDevice, "ALC_EXT_EFX") == AL_TRUE)
mCaps |= CAPS_Reverb | CAPS_Occlusion;
if (alcIsExtensionPresent(mDevice, "ALC_SOFT_HRTF") == AL_TRUE)
mCaps |= CAPS_HRTF;
if (alIsExtensionPresent("AL_EXT_float32") == AL_TRUE)
mCaps |= CAPS_Float32;
if (alIsExtensionPresent("AL_EXT_MCFORMATS") == AL_TRUE)
mCaps |= CAPS_MonoStereo;
if (mCaps & CAPS_Reverb)
{
#define LOAD_PROC(T, x) ((x) = FUNCTION_CAST(T, alGetProcAddress(#x)))
LOAD_PROC(LPALGENEFFECTS, alGenEffects);
LOAD_PROC(LPALDELETEEFFECTS, alDeleteEffects);
LOAD_PROC(LPALISEFFECT, alIsEffect);
LOAD_PROC(LPALEFFECTI, alEffecti);
LOAD_PROC(LPALEFFECTIV, alEffectiv);
LOAD_PROC(LPALEFFECTF, alEffectf);
LOAD_PROC(LPALEFFECTFV, alEffectfv);
LOAD_PROC(LPALGETEFFECTI, alGetEffecti);
LOAD_PROC(LPALGETEFFECTIV, alGetEffectiv);
LOAD_PROC(LPALGETEFFECTF, alGetEffectf);
LOAD_PROC(LPALGETEFFECTFV, alGetEffectfv);
LOAD_PROC(LPALGENAUXILIARYEFFECTSLOTS, alGenAuxiliaryEffectSlots);
LOAD_PROC(LPALDELETEAUXILIARYEFFECTSLOTS, alDeleteAuxiliaryEffectSlots);
LOAD_PROC(LPALISAUXILIARYEFFECTSLOT, alIsAuxiliaryEffectSlot);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTI, alAuxiliaryEffectSloti);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTIV, alAuxiliaryEffectSlotiv);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTF, alAuxiliaryEffectSlotf);
LOAD_PROC(LPALAUXILIARYEFFECTSLOTFV, alAuxiliaryEffectSlotfv);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTI, alGetAuxiliaryEffectSloti);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTIV, alGetAuxiliaryEffectSlotiv);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTF, alGetAuxiliaryEffectSlotf);
LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTFV, alGetAuxiliaryEffectSlotfv);
#undef LOAD_PROC
// generate our auxiliary slot for the effects.
// alGenAuxiliaryEffectSlots(1, &mAuxSlot);
}
// --- Device frequency ---
ALCint freq = 0;
alcGetIntegerv(mDevice, ALC_FREQUENCY, 1, &freq);
if (freq > 0)
Con::setIntVariable("$pref::SFX::frequency", freq);
else
Con::setIntVariable("$pref::SFX::frequency", 44100); // default
// --- Bitrate approximation ---
U32 bitrate = (mCaps & CAPS_Float32) ? 32 : 16;
Con::setIntVariable("$pref::SFX::bitrate", bitrate);
printALInfo(mDevice);
mMaxBuffers = getMaxSources();
// this should be max sources.
Con::printf("| Max Sources: %d", mMaxBuffers);
Con::setIntVariable("$pref::SFX::maxSoftwareBuffers", mMaxBuffers);
}
//-----------------------------------------------------------------------------
@ -189,26 +308,60 @@ SFXALDevice::SFXALDevice( SFXProvider *provider,
SFXALDevice::~SFXALDevice()
{
_releaseAllResources();
///cleanup our effects
#if defined(AL_ALEXT_PROTOTYPES)
mOpenAL.alDeleteAuxiliaryEffectSlots(4, effectSlot);
mOpenAL.alDeleteEffects(2, effect);
#endif
///cleanup of effects ends
mOpenAL.alcMakeContextCurrent( NULL );
mOpenAL.alcDestroyContext( mContext );
mOpenAL.alcCloseDevice( mDevice );
alcMakeContextCurrent( NULL );
alcDestroyContext( mContext );
alcCloseDevice( mDevice );
}
//-----------------------------------------------------------------------------
void SFXALDevice::enumerateProviders(Vector<SFXProvider*>& providerList)
{
const ALCchar* devices;
U32 index = providerList.size();
const ALCchar* defaultDeviceName;
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") == AL_TRUE)
{
devices = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
defaultDeviceName = alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER);
}
else
{
devices = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
defaultDeviceName = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
}
const ALCchar* currentDevice = devices;
while (*currentDevice != '\0')
{
SFXProvider* toAdd = new SFXProvider;
toAdd->mName = String::ToString(currentDevice);
toAdd->mIndex = index;
toAdd->mDeviceType = Output;
toAdd->mType = OpenAL;
toAdd->mCreateDeviceInstanceDelegate = mCreateDeviceInstance;
if (String::compare(currentDevice, defaultDeviceName) == 0)
toAdd->mDefault = true;
currentDevice += dStrlen(currentDevice) + 1;
index++;
providerList.push_back(toAdd);
}
}
SFXBuffer* SFXALDevice::createBuffer( const ThreadSafeRef< SFXStream >& stream, SFXDescription* description )
{
AssertFatal( stream, "SFXALDevice::createBuffer() - Got null stream!" );
AssertFatal( description, "SFXALDevice::createBuffer() - Got null description!" );
SFXALBuffer* buffer = SFXALBuffer::create( mOpenAL,
stream,
SFXALBuffer* buffer = SFXALBuffer::create( stream,
description,
mUseHardware );
if ( !buffer )
@ -258,14 +411,9 @@ void SFXALDevice::setListener( U32 index, const SFXListenerProperties& listener
const VectorF &velocity = listener.getVelocity();
mOpenAL.alListenerfv( AL_POSITION, pos );
mOpenAL.alListenerfv( AL_VELOCITY, velocity );
mOpenAL.alListenerfv( AL_ORIENTATION, (const F32 *)&tupple[0] );
///Pass a unit size to openal, 1.0 assumes 1 meter to 1 game unit.
///Crucial for air absorbtion calculations.
#if defined(AL_ALEXT_PROTOTYPES)
mOpenAL.alListenerf(AL_METERS_PER_UNIT, 1.0f);
#endif
alListenerfv( AL_POSITION, pos );
alListenerfv( AL_VELOCITY, velocity );
alListenerfv( AL_ORIENTATION, (const F32 *)&tupple[0] );
}
//-----------------------------------------------------------------------------
@ -275,19 +423,19 @@ void SFXALDevice::setDistanceModel( SFXDistanceModel model )
switch( model )
{
case SFXDistanceModelLinear:
mOpenAL.alDistanceModel( AL_LINEAR_DISTANCE_CLAMPED );
alDistanceModel( AL_LINEAR_DISTANCE_CLAMPED );
if( mRolloffFactor != 1.0f )
_setRolloffFactor( 1.0f ); // No rolloff on linear.
break;
case SFXDistanceModelLogarithmic:
mOpenAL.alDistanceModel( AL_INVERSE_DISTANCE_CLAMPED );
alDistanceModel( AL_INVERSE_DISTANCE_CLAMPED );
if( mUserRolloffFactor != mRolloffFactor )
_setRolloffFactor( mUserRolloffFactor );
break;
/// create a case for our exponential distance model
case SFXDistanceModelExponent:
mOpenAL.alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED);
alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED);
if (mUserRolloffFactor != mRolloffFactor)
_setRolloffFactor(mUserRolloffFactor);
break;
@ -303,7 +451,7 @@ void SFXALDevice::setDistanceModel( SFXDistanceModel model )
void SFXALDevice::setDopplerFactor( F32 factor )
{
mOpenAL.alDopplerFactor( factor );
alDopplerFactor( factor );
}
//-----------------------------------------------------------------------------
@ -313,7 +461,7 @@ void SFXALDevice::_setRolloffFactor( F32 factor )
mRolloffFactor = factor;
for( U32 i = 0, num = mVoices.size(); i < num; ++ i )
mOpenAL.alSourcef( ( ( SFXALVoice* ) mVoices[ i ] )->mSourceName, AL_ROLLOFF_FACTOR, factor );
alSourcef( ( ( SFXALVoice* ) mVoices[ i ] )->mSourceName, AL_ROLLOFF_FACTOR, factor );
}
//-----------------------------------------------------------------------------
@ -328,110 +476,7 @@ void SFXALDevice::setRolloffFactor( F32 factor )
mUserRolloffFactor = factor;
}
#if defined(AL_ALEXT_PROTOTYPES)
void SFXALDevice::openSlots()
void SFXALDevice::setSpeedOfSound(F32 speedOfSound)
{
for (uLoop = 0; uLoop < 4; uLoop++)
{
mOpenAL.alGenAuxiliaryEffectSlots(1, &effectSlot[uLoop]);
}
for (uLoop = 0; uLoop < 2; uLoop++)
{
mOpenAL.alGenEffects(1, &effect[uLoop]);
}
///debug string output so we know our slots are open
Platform::outputDebugString("Slots Open");
alSpeedOfSound(speedOfSound);
}
///create reverb effect
void SFXALDevice::setReverb(const SFXReverbProperties& reverb)
{
///output a debug string so we know each time the reverb changes
Platform::outputDebugString("Updated");
///load an efxeaxreverb default and add our values from
///sfxreverbproperties to it
EFXEAXREVERBPROPERTIES prop = EFX_REVERB_PRESET_GENERIC;
prop.flDensity = reverb.flDensity;
prop.flDiffusion = reverb.flDiffusion;
prop.flGain = reverb.flGain;
prop.flGainHF = reverb.flGainHF;
prop.flGainLF = reverb.flGainLF;
prop.flDecayTime = reverb.flDecayTime;
prop.flDecayHFRatio = reverb.flDecayHFRatio;
prop.flDecayLFRatio = reverb.flDecayLFRatio;
prop.flReflectionsGain = reverb.flReflectionsGain;
prop.flReflectionsDelay = reverb.flReflectionsDelay;
prop.flLateReverbGain = reverb.flLateReverbGain;
prop.flLateReverbDelay = reverb.flLateReverbDelay;
prop.flEchoTime = reverb.flEchoTime;
prop.flEchoDepth = reverb.flEchoDepth;
prop.flModulationTime = reverb.flModulationTime;
prop.flModulationDepth = reverb.flModulationDepth;
prop.flAirAbsorptionGainHF = reverb.flAirAbsorptionGainHF;
prop.flHFReference = reverb.flHFReference;
prop.flLFReference = reverb.flLFReference;
prop.flRoomRolloffFactor = reverb.flRoomRolloffFactor;
prop.iDecayHFLimit = reverb.iDecayHFLimit;
if (mOpenAL.alGetEnumValue("AL_EFFECT_EAXREVERB") != 0)
{
/// EAX Reverb is available. Set the EAX effect type
mOpenAL.alEffecti(effect[0], AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB);
///add our values to the setup of the reverb
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DENSITY, prop.flDensity);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DIFFUSION, prop.flDiffusion);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_GAIN, prop.flGain);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_GAINHF, prop.flGainHF);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_GAINLF, prop.flGainLF);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DECAY_TIME, prop.flDecayTime);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DECAY_HFRATIO, prop.flDecayHFRatio);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_DECAY_LFRATIO, prop.flDecayLFRatio);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_REFLECTIONS_GAIN, prop.flReflectionsGain);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_REFLECTIONS_DELAY, prop.flReflectionsDelay);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_LATE_REVERB_GAIN, prop.flLateReverbGain);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_LATE_REVERB_DELAY, prop.flLateReverbDelay);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_ECHO_TIME, prop.flEchoTime);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_ECHO_DEPTH, prop.flEchoDepth);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_MODULATION_TIME, prop.flModulationTime);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_MODULATION_DEPTH, prop.flModulationDepth);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_AIR_ABSORPTION_GAINHF, prop.flAirAbsorptionGainHF);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_HFREFERENCE, prop.flHFReference);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_LFREFERENCE, prop.flLFReference);
mOpenAL.alEffectf(effect[0], AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, prop.flRoomRolloffFactor);
mOpenAL.alEffecti(effect[0], AL_EAXREVERB_DECAY_HFLIMIT, prop.iDecayHFLimit);
mOpenAL.alAuxiliaryEffectSloti(1, AL_EFFECTSLOT_EFFECT, effect[0]);
Platform::outputDebugString("eax reverb properties set");
}
else
{
/// No EAX Reverb. Set the standard reverb effect
mOpenAL.alEffecti(effect[0], AL_EFFECT_TYPE, AL_EFFECT_REVERB);
mOpenAL.alEffectf(effect[0], AL_REVERB_DENSITY, prop.flDensity);
mOpenAL.alEffectf(effect[0], AL_REVERB_DIFFUSION, prop.flDiffusion);
mOpenAL.alEffectf(effect[0], AL_REVERB_GAIN, prop.flGain);
mOpenAL.alEffectf(effect[0], AL_REVERB_GAINHF, prop.flGainHF);
mOpenAL.alEffectf(effect[0], AL_REVERB_DECAY_TIME, prop.flDecayTime);
mOpenAL.alEffectf(effect[0], AL_REVERB_DECAY_HFRATIO, prop.flDecayHFRatio);
mOpenAL.alEffectf(effect[0], AL_REVERB_REFLECTIONS_GAIN, prop.flReflectionsGain);
mOpenAL.alEffectf(effect[0], AL_REVERB_REFLECTIONS_DELAY, prop.flReflectionsDelay);
mOpenAL.alEffectf(effect[0], AL_REVERB_LATE_REVERB_GAIN, prop.flLateReverbGain);
mOpenAL.alEffectf(effect[0], AL_REVERB_LATE_REVERB_DELAY, prop.flLateReverbDelay);
mOpenAL.alEffectf(effect[0], AL_REVERB_AIR_ABSORPTION_GAINHF, prop.flAirAbsorptionGainHF);
mOpenAL.alEffectf(effect[0], AL_REVERB_ROOM_ROLLOFF_FACTOR, prop.flRoomRolloffFactor);
mOpenAL.alEffecti(effect[0], AL_REVERB_DECAY_HFLIMIT, prop.iDecayHFLimit);
mOpenAL.alAuxiliaryEffectSloti(1, AL_EFFECTSLOT_EFFECT, effect[0]);
}
}
#endif

View file

@ -23,8 +23,6 @@
#ifndef _SFXALDEVICE_H_
#define _SFXALDEVICE_H_
class SFXProvider;
#ifndef _SFXDEVICE_H_
# include "sfx/sfxDevice.h"
#endif
@ -45,6 +43,9 @@ class SFXProvider;
# include "sfx/openal/LoadOAL.h"
#endif
#ifndef _SFXSYSTEM_H_
#include "sfx/sfxSystem.h"
#endif
class SFXALDevice : public SFXDevice
{
@ -53,6 +54,8 @@ class SFXALDevice : public SFXDevice
typedef SFXDevice Parent;
friend class SFXALVoice; // mDistanceFactor, mRolloffFactor
static SFXDevice* createInstance(U32 adapterIndex);
void printALInfo(ALCdevice* device);
void printHRTFInfo(ALCdevice* device);
void getEFXInfo(ALCdevice* device);
@ -61,16 +64,12 @@ class SFXALDevice : public SFXDevice
// Compatibility with pre openal 1.2
S32 getMaxSourcesOld();
SFXALDevice( SFXProvider *provider,
const OPENALFNTABLE &openal,
String name,
bool useHardware,
S32 maxBuffers );
SFXALDevice(U32 providerIndex);
virtual ~SFXALDevice();
protected:
static SFXProvider::CreateProviderInstanceDelegate mCreateDeviceInstance;
OPENALFNTABLE mOpenAL;
ALCcontext *mContext;
@ -85,7 +84,7 @@ class SFXALDevice : public SFXDevice
void _setRolloffFactor( F32 factor );
public:
static void enumerateProviders(Vector<SFXProvider*>& providerList);
// SFXDevice.
SFXBuffer* createBuffer( const ThreadSafeRef< SFXStream >& stream, SFXDescription* description ) override;
SFXVoice* createVoice( bool is3D, SFXBuffer *buffer ) override;
@ -93,17 +92,8 @@ class SFXALDevice : public SFXDevice
void setDistanceModel( SFXDistanceModel model ) override;
void setDopplerFactor( F32 factor ) override;
void setRolloffFactor( F32 factor ) override;
#if defined(AL_ALEXT_PROTOTYPES)
//function for openAL to open slots
virtual void openSlots();
//slots
ALuint effectSlot[4] = { 0 };
ALuint effect[2] = { 0 };
ALuint uLoop;
//get values from sfxreverbproperties and pass it to openal device
virtual void setReverb(const SFXReverbProperties& reverb);
#endif
void resetReverb() override {}
void setSpeedOfSound(F32 speedOfSound) override;
};
#endif // _SFXALDEVICE_H_

View file

@ -1,127 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "sfx/sfxProvider.h"
#include "sfx/openal/sfxALDevice.h"
#include "sfx/openal/aldlist.h"
#include "sfx/openal/LoadOAL.h"
#include "core/strings/stringFunctions.h"
#include "console/console.h"
#include "core/module.h"
class SFXALProvider : public SFXProvider
{
public:
SFXALProvider()
: SFXProvider( "OpenAL" ) { dMemset(&mOpenAL,0,sizeof(mOpenAL)); mALDL = NULL; }
virtual ~SFXALProvider();
protected:
OPENALFNTABLE mOpenAL;
ALDeviceList *mALDL;
struct ALDeviceInfo : SFXDeviceInfo
{
};
void init() override;
public:
SFXDevice *createDevice( const String& deviceName, bool useHardware, S32 maxBuffers ) override;
};
MODULE_BEGIN( OpenAL )
MODULE_INIT_BEFORE( SFX )
MODULE_SHUTDOWN_AFTER( SFX )
SFXALProvider* mProvider = NULL;
MODULE_INIT
{
mProvider = new SFXALProvider;
}
MODULE_SHUTDOWN
{
delete mProvider;
}
MODULE_END;
void SFXALProvider::init()
{
if( LoadOAL10Library( NULL, &mOpenAL ) != AL_TRUE )
{
Con::printf( "SFXALProvider - OpenAL not available." );
return;
}
mALDL = new ALDeviceList( mOpenAL );
// Did we get any devices?
if ( mALDL->GetNumDevices() < 1 )
{
Con::printf( "SFXALProvider - No valid devices found!" );
return;
}
// Cool, loop through them, and caps em
//const char *deviceFormat = "OpenAL v%d.%d %s";
for( S32 i = 0; i < mALDL->GetNumDevices(); i++ )
{
ALDeviceInfo* info = new ALDeviceInfo;
//info->internalName = String( mALDL->GetInternalDeviceName( i ) );
info->name = String( mALDL->GetDeviceName( i ) );
mDeviceInfo.push_back( info );
}
regProvider( this );
}
SFXALProvider::~SFXALProvider()
{
UnloadOAL10Library();
if (mALDL)
delete mALDL;
}
SFXDevice* SFXALProvider::createDevice(const String& deviceName, bool useHardware, S32 maxBuffers)
{
ALDeviceInfo* info = dynamic_cast<ALDeviceInfo*>
(_findDeviceInfo(deviceName));
// Do we find one to create?
if (info)
return new SFXALDevice(this, mOpenAL, info->name, useHardware, maxBuffers);
return NULL;
}

View file

@ -28,7 +28,7 @@
#ifdef TORQUE_DEBUG
# define AL_SANITY_CHECK() \
AssertFatal( mOpenAL.alIsSource( mSourceName ), "AL Source Sanity Check Failed!" );
AssertFatal( alIsSource( mSourceName ), "AL Source Sanity Check Failed!" );
#else
# define AL_SANITY_CHECK()
#endif
@ -42,8 +42,8 @@ SFXALVoice* SFXALVoice::create( SFXALDevice* device, SFXALBuffer *buffer )
AssertFatal( buffer, "SFXALVoice::create() - Got null buffer!" );
ALuint sourceName;
device->mOpenAL.alGenSources( 1, &sourceName );
AssertFatal( device->mOpenAL.alIsSource( sourceName ), "AL Source Sanity Check Failed!" );
alGenSources( 1, &sourceName );
AssertFatal( alIsSource( sourceName ), "AL Source Sanity Check Failed!" );
// Is this 3d?
// Okay, this looks odd, but bear with me for a moment. AL_SOURCE_RELATIVE does NOT indicate
@ -52,34 +52,32 @@ SFXALVoice* SFXALVoice::create( SFXALDevice* device, SFXALBuffer *buffer )
// does do is dictate if the position of THIS SOURCE is relative to the listener. If AL_SOURCE_RELATIVE is AL_TRUE
// and the source's position is 0, 0, 0, then the source is directly on top of the listener at all times, which is what
// we want for non-3d sounds.
device->mOpenAL.alSourcei( sourceName, AL_SOURCE_RELATIVE, ( buffer->mIs3d ? AL_FALSE : AL_TRUE ) );
alSourcei( sourceName, AL_SOURCE_RELATIVE, ( buffer->mIs3d ? AL_FALSE : AL_TRUE ) );
if( buffer->mIs3d )
device->mOpenAL.alSourcef( sourceName, AL_ROLLOFF_FACTOR, device->mRolloffFactor );
alSourcef( sourceName, AL_ROLLOFF_FACTOR, device->mRolloffFactor );
SFXALVoice *voice = new SFXALVoice( device->mOpenAL,
buffer,
SFXALVoice *voice = new SFXALVoice( buffer,
sourceName );
return voice;
}
SFXALVoice::SFXALVoice( const OPENALFNTABLE &oalft,
SFXALBuffer *buffer,
SFXALVoice::SFXALVoice( SFXALBuffer *buffer,
ALuint sourceName )
: Parent( buffer ),
mSourceName( sourceName ),
mResumeAtSampleOffset( -1.0f ),
mSampleOffset( 0 ),
mOpenAL( oalft )
mSampleOffset( 0 )
{
AL_SANITY_CHECK();
}
SFXALVoice::~SFXALVoice()
{
mOpenAL.alDeleteSources( 1, &mSourceName );
alSourcei(mSourceName, AL_BUFFER, 0);
alDeleteSources( 1, &mSourceName );
}
void SFXALVoice::_lateBindStaticBufferIfNecessary()
@ -87,9 +85,9 @@ void SFXALVoice::_lateBindStaticBufferIfNecessary()
if( !mBuffer->isStreaming() )
{
ALint bufferId;
mOpenAL.alGetSourcei( mSourceName, AL_BUFFER, &bufferId );
alGetSourcei( mSourceName, AL_BUFFER, &bufferId );
if( !bufferId )
mOpenAL.alSourcei( mSourceName, AL_BUFFER, _getBuffer()->mALBuffer );
alSourcei( mSourceName, AL_BUFFER, _getBuffer()->mALBuffer );
}
}
@ -99,7 +97,7 @@ SFXStatus SFXALVoice::_status() const
AL_SANITY_CHECK();
ALint state;
mOpenAL.alGetSourcei( mSourceName, AL_SOURCE_STATE, &state );
alGetSourcei( mSourceName, AL_SOURCE_STATE, &state );
switch( state )
{
@ -118,18 +116,15 @@ void SFXALVoice::_play()
#ifdef DEBUG_SPEW
Platform::outputDebugString( "[SFXALVoice] Starting playback" );
#endif
#if defined(AL_ALEXT_PROTOTYPES)
//send every voice that plays to the alauxiliary slot that has the reverb
mOpenAL.alSource3i(mSourceName, AL_AUXILIARY_SEND_FILTER, 1, 0, AL_FILTER_NULL);
#endif
mOpenAL.alSourcePlay( mSourceName );
alSourcePlay( mSourceName );
//WORKAROUND: Adjust play cursor for buggy OAL when resuming playback. Do this after alSourcePlay
// as it is the play function that will cause the cursor to jump.
if( mResumeAtSampleOffset != -1.0f )
{
mOpenAL.alSourcef( mSourceName, AL_SAMPLE_OFFSET, mResumeAtSampleOffset );
alSourcef( mSourceName, AL_SAMPLE_OFFSET, mResumeAtSampleOffset );
mResumeAtSampleOffset = -1.0f;
}
}
@ -142,12 +137,12 @@ void SFXALVoice::_pause()
Platform::outputDebugString( "[SFXALVoice] Pausing playback" );
#endif
mOpenAL.alSourcePause( mSourceName );
alSourcePause( mSourceName );
//WORKAROUND: Another workaround for buggy OAL. Resuming playback of a paused source will cause the
// play cursor to jump. Save the cursor so we can manually move it into position in _play(). Sigh.
mOpenAL.alGetSourcef( mSourceName, AL_SAMPLE_OFFSET, &mResumeAtSampleOffset );
alGetSourcef( mSourceName, AL_SAMPLE_OFFSET, &mResumeAtSampleOffset );
}
void SFXALVoice::_stop()
@ -158,7 +153,7 @@ void SFXALVoice::_stop()
Platform::outputDebugString( "[SFXALVoice] Stopping playback" );
#endif
mOpenAL.alSourceStop( mSourceName );
alSourceStop( mSourceName );
mSampleOffset = 0;
mResumeAtSampleOffset = -1.0f;
@ -169,7 +164,7 @@ void SFXALVoice::_seek( U32 sample )
AL_SANITY_CHECK();
_lateBindStaticBufferIfNecessary();
mOpenAL.alSourcei( mSourceName, AL_SAMPLE_OFFSET, sample );
alSourcei( mSourceName, AL_SAMPLE_OFFSET, sample );
mResumeAtSampleOffset = -1.0f;
}
@ -183,7 +178,7 @@ U32 SFXALVoice::_tell() const
mBuffer->write( NULL, 0 );
ALint pos;
mOpenAL.alGetSourcei( mSourceName, AL_SAMPLE_OFFSET, &pos );
alGetSourcei( mSourceName, AL_SAMPLE_OFFSET, &pos );
return ( pos + mSampleOffset );
}
@ -191,17 +186,17 @@ void SFXALVoice::setMinMaxDistance( F32 min, F32 max )
{
AL_SANITY_CHECK();
mOpenAL.alSourcef( mSourceName, AL_REFERENCE_DISTANCE, min );
mOpenAL.alSourcef( mSourceName, AL_MAX_DISTANCE, max );
alSourcef( mSourceName, AL_REFERENCE_DISTANCE, min );
alSourcef( mSourceName, AL_MAX_DISTANCE, max );
}
void SFXALVoice::play( bool looping )
{
AL_SANITY_CHECK();
mOpenAL.alSourceStop( mSourceName );
alSourceStop( mSourceName );
if( !mBuffer->isStreaming() )
mOpenAL.alSourcei( mSourceName, AL_LOOPING, ( looping ? AL_TRUE : AL_FALSE ) );
alSourcei( mSourceName, AL_LOOPING, ( looping ? AL_TRUE : AL_FALSE ) );
Parent::play( looping );
}
@ -213,7 +208,7 @@ void SFXALVoice::setVelocity( const VectorF& velocity )
// Torque and OpenAL are both right handed
// systems, so no coordinate flipping is needed.
mOpenAL.alSourcefv( mSourceName, AL_VELOCITY, velocity );
alSourcefv( mSourceName, AL_VELOCITY, velocity );
}
void SFXALVoice::setTransform( const MatrixF& transform )
@ -227,34 +222,34 @@ void SFXALVoice::setTransform( const MatrixF& transform )
transform.getColumn( 3, &pos );
transform.getColumn( 1, &dir );
mOpenAL.alSourcefv( mSourceName, AL_POSITION, pos );
mOpenAL.alSourcefv( mSourceName, AL_DIRECTION, dir );
alSourcefv( mSourceName, AL_POSITION, pos );
alSourcefv( mSourceName, AL_DIRECTION, dir );
}
void SFXALVoice::setVolume( F32 volume )
{
AL_SANITY_CHECK();
mOpenAL.alSourcef( mSourceName, AL_GAIN, volume );
alSourcef( mSourceName, AL_GAIN, volume );
}
void SFXALVoice::setPitch( F32 pitch )
{
AL_SANITY_CHECK();
mOpenAL.alSourcef( mSourceName, AL_PITCH, pitch );
alSourcef( mSourceName, AL_PITCH, pitch );
}
void SFXALVoice::setCone( F32 innerAngle, F32 outerAngle, F32 outerVolume )
{
AL_SANITY_CHECK();
mOpenAL.alSourcef( mSourceName, AL_CONE_INNER_ANGLE, innerAngle );
mOpenAL.alSourcef( mSourceName, AL_CONE_OUTER_ANGLE, outerAngle );
mOpenAL.alSourcef( mSourceName, AL_CONE_OUTER_GAIN, outerVolume );
alSourcef( mSourceName, AL_CONE_INNER_ANGLE, innerAngle );
alSourcef( mSourceName, AL_CONE_OUTER_ANGLE, outerAngle );
alSourcef( mSourceName, AL_CONE_OUTER_GAIN, outerVolume );
}
void SFXALVoice::setRolloffFactor( F32 factor )
{
mOpenAL.alSourcef( mSourceName, AL_ROLLOFF_FACTOR, factor );
alSourcef( mSourceName, AL_ROLLOFF_FACTOR, factor );
}

View file

@ -47,8 +47,7 @@ class SFXALVoice : public SFXVoice
protected:
SFXALVoice( const OPENALFNTABLE &oalft,
SFXALBuffer *buffer,
SFXALVoice( SFXALBuffer *buffer,
ALuint sourceName );
ALuint mSourceName;
@ -65,8 +64,6 @@ class SFXALVoice : public SFXVoice
Mutex mMutex;
const OPENALFNTABLE &mOpenAL;
///
SFXALBuffer* _getBuffer() const
{
@ -104,4 +101,4 @@ class SFXALVoice : public SFXVoice
void setRolloffFactor( F32 factor ) override;
};
#endif // _SFXALVOICE_H_
#endif // _SFXALVOICE_H_

View file

@ -1,601 +0,0 @@
/*
* Copyright (c) 2006, Creative Labs Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the distribution.
* * Neither the name of Creative Labs Inc. nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <windows.h>
#include "sfx/openal/LoadOAL.h"
HINSTANCE g_hOpenALDLL = NULL;
ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable)
{
if (!lpOALFnTable)
return AL_FALSE;
if (szOALFullPathName)
g_hOpenALDLL = LoadLibraryA(szOALFullPathName);
else
{
#ifdef TORQUE_DEBUG
g_hOpenALDLL = LoadLibraryA("openal32d.dll");
#else
g_hOpenALDLL = LoadLibraryA("openal32.dll");
#endif
}
if (!g_hOpenALDLL)
return AL_FALSE;
memset(lpOALFnTable, 0, sizeof(OPENALFNTABLE));
// Get function pointers
lpOALFnTable->alEnable = (LPALENABLE)GetProcAddress(g_hOpenALDLL, "alEnable");
if (lpOALFnTable->alEnable == NULL)
{
OutputDebugStringA("Failed to retrieve 'alEnable' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDisable = (LPALDISABLE)GetProcAddress(g_hOpenALDLL, "alDisable");
if (lpOALFnTable->alDisable == NULL)
{
OutputDebugStringA("Failed to retrieve 'alDisable' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsEnabled = (LPALISENABLED)GetProcAddress(g_hOpenALDLL, "alIsEnabled");
if (lpOALFnTable->alIsEnabled == NULL)
{
OutputDebugStringA("Failed to retrieve 'alIsEnabled' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBoolean = (LPALGETBOOLEAN)GetProcAddress(g_hOpenALDLL, "alGetBoolean");
if (lpOALFnTable->alGetBoolean == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetBoolean' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetInteger = (LPALGETINTEGER)GetProcAddress(g_hOpenALDLL, "alGetInteger");
if (lpOALFnTable->alGetInteger == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetInteger' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetFloat = (LPALGETFLOAT)GetProcAddress(g_hOpenALDLL, "alGetFloat");
if (lpOALFnTable->alGetFloat == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetFloat' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetDouble = (LPALGETDOUBLE)GetProcAddress(g_hOpenALDLL, "alGetDouble");
if (lpOALFnTable->alGetDouble == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetDouble' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBooleanv = (LPALGETBOOLEANV)GetProcAddress(g_hOpenALDLL, "alGetBooleanv");
if (lpOALFnTable->alGetBooleanv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetBooleanv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetIntegerv = (LPALGETINTEGERV)GetProcAddress(g_hOpenALDLL, "alGetIntegerv");
if (lpOALFnTable->alGetIntegerv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetIntegerv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetFloatv = (LPALGETFLOATV)GetProcAddress(g_hOpenALDLL, "alGetFloatv");
if (lpOALFnTable->alGetFloatv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetFloatv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetDoublev = (LPALGETDOUBLEV)GetProcAddress(g_hOpenALDLL, "alGetDoublev");
if (lpOALFnTable->alGetDoublev == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetDoublev' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetString = (LPALGETSTRING)GetProcAddress(g_hOpenALDLL, "alGetString");
if (lpOALFnTable->alGetString == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetString' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetError = (LPALGETERROR)GetProcAddress(g_hOpenALDLL, "alGetError");
if (lpOALFnTable->alGetError == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetError' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsExtensionPresent = (LPALISEXTENSIONPRESENT)GetProcAddress(g_hOpenALDLL, "alIsExtensionPresent");
if (lpOALFnTable->alIsExtensionPresent == NULL)
{
OutputDebugStringA("Failed to retrieve 'alIsExtensionPresent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetProcAddress = (LPALGETPROCADDRESS)GetProcAddress(g_hOpenALDLL, "alGetProcAddress");
if (lpOALFnTable->alGetProcAddress == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetProcAddress' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEnumValue = (LPALGETENUMVALUE)GetProcAddress(g_hOpenALDLL, "alGetEnumValue");
if (lpOALFnTable->alGetEnumValue == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetEnumValue' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListeneri = (LPALLISTENERI)GetProcAddress(g_hOpenALDLL, "alListeneri");
if (lpOALFnTable->alListeneri == NULL)
{
OutputDebugStringA("Failed to retrieve 'alListeneri' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListenerf = (LPALLISTENERF)GetProcAddress(g_hOpenALDLL, "alListenerf");
if (lpOALFnTable->alListenerf == NULL)
{
OutputDebugStringA("Failed to retrieve 'alListenerf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListener3f = (LPALLISTENER3F)GetProcAddress(g_hOpenALDLL, "alListener3f");
if (lpOALFnTable->alListener3f == NULL)
{
OutputDebugStringA("Failed to retrieve 'alListener3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListenerfv = (LPALLISTENERFV)GetProcAddress(g_hOpenALDLL, "alListenerfv");
if (lpOALFnTable->alListenerfv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alListenerfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListeneri = (LPALGETLISTENERI)GetProcAddress(g_hOpenALDLL, "alGetListeneri");
if (lpOALFnTable->alGetListeneri == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetListeneri' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListenerf =(LPALGETLISTENERF)GetProcAddress(g_hOpenALDLL, "alGetListenerf");
if (lpOALFnTable->alGetListenerf == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetListenerf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListener3f = (LPALGETLISTENER3F)GetProcAddress(g_hOpenALDLL, "alGetListener3f");
if (lpOALFnTable->alGetListener3f == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetListener3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListenerfv = (LPALGETLISTENERFV)GetProcAddress(g_hOpenALDLL, "alGetListenerfv");
if (lpOALFnTable->alGetListenerfv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetListenerfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGenSources = (LPALGENSOURCES)GetProcAddress(g_hOpenALDLL, "alGenSources");
if (lpOALFnTable->alGenSources == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGenSources' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteSources = (LPALDELETESOURCES)GetProcAddress(g_hOpenALDLL, "alDeleteSources");
if (lpOALFnTable->alDeleteSources == NULL)
{
OutputDebugStringA("Failed to retrieve 'alDeleteSources' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsSource = (LPALISSOURCE)GetProcAddress(g_hOpenALDLL, "alIsSource");
if (lpOALFnTable->alIsSource == NULL)
{
OutputDebugStringA("Failed to retrieve 'alIsSource' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcei = (LPALSOURCEI)GetProcAddress(g_hOpenALDLL, "alSourcei");
if (lpOALFnTable->alSourcei == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSourcei' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcef = (LPALSOURCEF)GetProcAddress(g_hOpenALDLL, "alSourcef");
if (lpOALFnTable->alSourcef == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSourcef' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSource3f = (LPALSOURCE3F)GetProcAddress(g_hOpenALDLL, "alSource3f");
if (lpOALFnTable->alSource3f == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSource3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcefv = (LPALSOURCEFV)GetProcAddress(g_hOpenALDLL, "alSourcefv");
if (lpOALFnTable->alSourcefv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSourcefv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcei = (LPALGETSOURCEI)GetProcAddress(g_hOpenALDLL, "alGetSourcei");
if (lpOALFnTable->alGetSourcei == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetSourcei' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcef = (LPALGETSOURCEF)GetProcAddress(g_hOpenALDLL, "alGetSourcef");
if (lpOALFnTable->alGetSourcef == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetSourcef' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcefv = (LPALGETSOURCEFV)GetProcAddress(g_hOpenALDLL, "alGetSourcefv");
if (lpOALFnTable->alGetSourcefv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetSourcefv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePlayv = (LPALSOURCEPLAYV)GetProcAddress(g_hOpenALDLL, "alSourcePlayv");
if (lpOALFnTable->alSourcePlayv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSourcePlayv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceStopv = (LPALSOURCESTOPV)GetProcAddress(g_hOpenALDLL, "alSourceStopv");
if (lpOALFnTable->alSourceStopv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSourceStopv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePlay = (LPALSOURCEPLAY)GetProcAddress(g_hOpenALDLL, "alSourcePlay");
if (lpOALFnTable->alSourcePlay == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSourcePlay' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePause = (LPALSOURCEPAUSE)GetProcAddress(g_hOpenALDLL, "alSourcePause");
if (lpOALFnTable->alSourcePause == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSourcePause' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceStop = (LPALSOURCESTOP)GetProcAddress(g_hOpenALDLL, "alSourceStop");
if (lpOALFnTable->alSourceStop == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSourceStop' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceRewind = (LPALSOURCEREWIND)GetProcAddress(g_hOpenALDLL, "alSourceRewind");
if (lpOALFnTable->alSourceRewind == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSourceRewind' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGenBuffers = (LPALGENBUFFERS)GetProcAddress(g_hOpenALDLL, "alGenBuffers");
if (lpOALFnTable->alGenBuffers == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGenBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteBuffers = (LPALDELETEBUFFERS)GetProcAddress(g_hOpenALDLL, "alDeleteBuffers");
if (lpOALFnTable->alDeleteBuffers == NULL)
{
OutputDebugStringA("Failed to retrieve 'alDeleteBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsBuffer = (LPALISBUFFER)GetProcAddress(g_hOpenALDLL, "alIsBuffer");
if (lpOALFnTable->alIsBuffer == NULL)
{
OutputDebugStringA("Failed to retrieve 'alIsBuffer' function address\n");
return AL_FALSE;
}
lpOALFnTable->alBufferData = (LPALBUFFERDATA)GetProcAddress(g_hOpenALDLL, "alBufferData");
if (lpOALFnTable->alBufferData == NULL)
{
OutputDebugStringA("Failed to retrieve 'alBufferData' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBufferi = (LPALGETBUFFERI)GetProcAddress(g_hOpenALDLL, "alGetBufferi");
if (lpOALFnTable->alGetBufferi == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetBufferi' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBufferf = (LPALGETBUFFERF)GetProcAddress(g_hOpenALDLL, "alGetBufferf");
if (lpOALFnTable->alGetBufferf == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetBufferf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceQueueBuffers = (LPALSOURCEQUEUEBUFFERS)GetProcAddress(g_hOpenALDLL, "alSourceQueueBuffers");
if (lpOALFnTable->alSourceQueueBuffers == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSourceQueueBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceUnqueueBuffers = (LPALSOURCEUNQUEUEBUFFERS)GetProcAddress(g_hOpenALDLL, "alSourceUnqueueBuffers");
if (lpOALFnTable->alSourceUnqueueBuffers == NULL)
{
OutputDebugStringA("Failed to retrieve 'alSourceUnqueueBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDistanceModel = (LPALDISTANCEMODEL)GetProcAddress(g_hOpenALDLL, "alDistanceModel");
if (lpOALFnTable->alDistanceModel == NULL)
{
OutputDebugStringA("Failed to retrieve 'alDistanceModel' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDopplerFactor = (LPALDOPPLERFACTOR)GetProcAddress(g_hOpenALDLL, "alDopplerFactor");
if (lpOALFnTable->alDopplerFactor == NULL)
{
OutputDebugStringA("Failed to retrieve 'alDopplerFactor' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDopplerVelocity = (LPALDOPPLERVELOCITY)GetProcAddress(g_hOpenALDLL, "alDopplerVelocity");
if (lpOALFnTable->alDopplerVelocity == NULL)
{
OutputDebugStringA("Failed to retrieve 'alDopplerVelocity' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetString = (LPALCGETSTRING)GetProcAddress(g_hOpenALDLL, "alcGetString");
if (lpOALFnTable->alcGetString == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcGetString' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetIntegerv = (LPALCGETINTEGERV)GetProcAddress(g_hOpenALDLL, "alcGetIntegerv");
if (lpOALFnTable->alcGetIntegerv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcGetIntegerv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcOpenDevice = (LPALCOPENDEVICE)GetProcAddress(g_hOpenALDLL, "alcOpenDevice");
if (lpOALFnTable->alcOpenDevice == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcOpenDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcCloseDevice = (LPALCCLOSEDEVICE)GetProcAddress(g_hOpenALDLL, "alcCloseDevice");
if (lpOALFnTable->alcCloseDevice == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcCloseDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcCreateContext = (LPALCCREATECONTEXT)GetProcAddress(g_hOpenALDLL, "alcCreateContext");
if (lpOALFnTable->alcCreateContext == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcCreateContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcMakeContextCurrent = (LPALCMAKECONTEXTCURRENT)GetProcAddress(g_hOpenALDLL, "alcMakeContextCurrent");
if (lpOALFnTable->alcMakeContextCurrent == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcMakeContextCurrent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcProcessContext = (LPALCPROCESSCONTEXT)GetProcAddress(g_hOpenALDLL, "alcProcessContext");
if (lpOALFnTable->alcProcessContext == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcProcessContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetCurrentContext = (LPALCGETCURRENTCONTEXT)GetProcAddress(g_hOpenALDLL, "alcGetCurrentContext");
if (lpOALFnTable->alcGetCurrentContext == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcGetCurrentContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetContextsDevice = (LPALCGETCONTEXTSDEVICE)GetProcAddress(g_hOpenALDLL, "alcGetContextsDevice");
if (lpOALFnTable->alcGetContextsDevice == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcGetContextsDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcSuspendContext = (LPALCSUSPENDCONTEXT)GetProcAddress(g_hOpenALDLL, "alcSuspendContext");
if (lpOALFnTable->alcSuspendContext == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcSuspendContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcDestroyContext = (LPALCDESTROYCONTEXT)GetProcAddress(g_hOpenALDLL, "alcDestroyContext");
if (lpOALFnTable->alcDestroyContext == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcDestroyContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetError = (LPALCGETERROR)GetProcAddress(g_hOpenALDLL, "alcGetError");
if (lpOALFnTable->alcGetError == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcGetError' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcIsExtensionPresent = (LPALCISEXTENSIONPRESENT)GetProcAddress(g_hOpenALDLL, "alcIsExtensionPresent");
if (lpOALFnTable->alcIsExtensionPresent == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcIsExtensionPresent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetProcAddress = (LPALCGETPROCADDRESS)GetProcAddress(g_hOpenALDLL, "alcGetProcAddress");
if (lpOALFnTable->alcGetProcAddress == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcGetProcAddress' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetEnumValue = (LPALCGETENUMVALUE)GetProcAddress(g_hOpenALDLL, "alcGetEnumValue");
if (lpOALFnTable->alcGetEnumValue == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcGetEnumValue' function address\n");
return AL_FALSE;
}
#if defined(AL_ALEXT_PROTOTYPES)
lpOALFnTable->alGenEffects = (LPALGENEFFECTS)GetProcAddress(g_hOpenALDLL, "alGenEffects");
if (lpOALFnTable->alGenEffects == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGenEffects' function address\n");
}
lpOALFnTable->alEffecti = (LPALEFFECTI)GetProcAddress(g_hOpenALDLL, "alEffecti");
if (lpOALFnTable->alEffecti == NULL)
{
OutputDebugStringA("Failed to retrieve 'alEffecti' function address\n");
}
lpOALFnTable->alEffectiv = (LPALEFFECTIV)GetProcAddress(g_hOpenALDLL, "alEffectiv");
if (lpOALFnTable->alEffectiv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alEffectiv' function address\n");
}
lpOALFnTable->alEffectf = (LPALEFFECTF)GetProcAddress(g_hOpenALDLL, "alEffectf");
if (lpOALFnTable->alEffectf == NULL)
{
OutputDebugStringA("Failed to retrieve 'alEffectf' function address\n");
}
lpOALFnTable->alEffectfv = (LPALEFFECTFV)GetProcAddress(g_hOpenALDLL, "alEffectfv");
if (lpOALFnTable->alEffectfv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alEffectfv' function address\n");
}
lpOALFnTable->alGetEffecti = (LPALGETEFFECTI)GetProcAddress(g_hOpenALDLL, "alGetEffecti");
if (lpOALFnTable->alGetEffecti == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetEffecti' function address\n");
}
lpOALFnTable->alGetEffectiv = (LPALGETEFFECTIV)GetProcAddress(g_hOpenALDLL, "alGetEffectiv");
if (lpOALFnTable->alGetEffectiv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetEffectiv' function address\n");
}
lpOALFnTable->alGetEffectf = (LPALGETEFFECTF)GetProcAddress(g_hOpenALDLL, "alGetEffectf");
if (lpOALFnTable->alGetEffectf == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetEffectf' function address\n");
}
lpOALFnTable->alGetEffectfv = (LPALGETEFFECTFV)GetProcAddress(g_hOpenALDLL, "alGetEffectfv");
if (lpOALFnTable->alGetEffectfv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetEffectfv' function address\n");
}
lpOALFnTable->alDeleteEffects = (LPALDELETEEFFECTS)GetProcAddress(g_hOpenALDLL, "alDeleteEffects");
if (lpOALFnTable->alDeleteEffects == NULL)
{
OutputDebugStringA("Failed to retrieve 'alDeleteEffects' function address\n");
}
lpOALFnTable->alIsEffect = (LPALISEFFECT)GetProcAddress(g_hOpenALDLL, "alIsEffect");
if (lpOALFnTable->alIsEffect == NULL)
{
OutputDebugStringA("Failed to retrieve 'alIsEffect' function address\n");
}
lpOALFnTable->alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSlotf");
if (lpOALFnTable->alAuxiliaryEffectSlotf == NULL)
{
OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSlotf' function address\n");
}
lpOALFnTable->alAuxiliaryEffectSlotfv = (LPALAUXILIARYEFFECTSLOTFV)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSlotfv");
if (lpOALFnTable->alAuxiliaryEffectSlotfv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSlotfv' function address\n");
}
lpOALFnTable->alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSloti");
if (lpOALFnTable->alAuxiliaryEffectSloti == NULL)
{
OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSloti' function address\n");
}
lpOALFnTable->alAuxiliaryEffectSlotiv = (LPALAUXILIARYEFFECTSLOTIV)GetProcAddress(g_hOpenALDLL, "alAuxiliaryEffectSlotiv");
if (lpOALFnTable->alAuxiliaryEffectSlotiv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alAuxiliaryEffectSlotiv' function address\n");
}
lpOALFnTable->alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)GetProcAddress(g_hOpenALDLL, "alIsAuxiliaryEffectSlot");
if (lpOALFnTable->alIsAuxiliaryEffectSlot == NULL)
{
OutputDebugStringA("Failed to retrieve 'alIsAuxiliaryEffectSlot' function address\n");
}
lpOALFnTable->alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)GetProcAddress(g_hOpenALDLL, "alGenAuxiliaryEffectSlots");
if (lpOALFnTable->alGenAuxiliaryEffectSlots == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGenAuxiliaryEffectSlots' function address\n");
}
lpOALFnTable->alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)GetProcAddress(g_hOpenALDLL, "alDeleteAuxiliaryEffectSlots");
if (lpOALFnTable->alDeleteAuxiliaryEffectSlots == NULL)
{
OutputDebugStringA("Failed to retrieve 'alDeleteAuxiliaryEffectSlots' function address\n");
}
lpOALFnTable->alGetAuxiliaryEffectSlotf = (LPALGETAUXILIARYEFFECTSLOTF)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSlotf");
if (lpOALFnTable->alGetAuxiliaryEffectSlotf == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSlotf' function address\n");
}
lpOALFnTable->alGetAuxiliaryEffectSlotfv = (LPALGETAUXILIARYEFFECTSLOTFV)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSlotfv");
if (lpOALFnTable->alGetAuxiliaryEffectSlotfv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSlotfv' function address\n");
}
lpOALFnTable->alGetAuxiliaryEffectSloti = (LPALGETAUXILIARYEFFECTSLOTI)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSloti");
if (lpOALFnTable->alGetAuxiliaryEffectSloti == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSloti' function address\n");
}
lpOALFnTable->alGetAuxiliaryEffectSlotiv = (LPALGETAUXILIARYEFFECTSLOTIV)GetProcAddress(g_hOpenALDLL, "alGetAuxiliaryEffectSlotiv");
if (lpOALFnTable->alGetAuxiliaryEffectSlotiv == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGetAuxiliaryEffectSlotiv' function address\n");
}
lpOALFnTable->alSource3i = (LPALSOURCE3I)GetProcAddress(g_hOpenALDLL, "alSource3i");
lpOALFnTable->alGenFilters = (LPALGENFILTERS)GetProcAddress(g_hOpenALDLL, "alGenFilters");
if (lpOALFnTable->alGenFilters == NULL)
{
OutputDebugStringA("Failed to retrieve 'alGenFilters' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteFilters = (LPALDELETEFILTERS)GetProcAddress(g_hOpenALDLL, "alDeleteFilters");
if (lpOALFnTable->alGenFilters == NULL)
{
OutputDebugStringA("Failed to retrieve 'alDeleteFilters' function address\n");
return AL_FALSE;
}
lpOALFnTable->alFilteri = (LPALFILTERI)GetProcAddress(g_hOpenALDLL, "alFilteri");
if (lpOALFnTable->alGenFilters == NULL)
{
OutputDebugStringA("Failed to retrieve 'alFilteri' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetStringiSOFT = (LPALCGETSTRINGISOFT)GetProcAddress(g_hOpenALDLL, "alcGetStringiSOFT");
if (lpOALFnTable->alcGetStringiSOFT == NULL)
{
OutputDebugStringA("Failed to retrieve 'alcGetStringiSOFT' function address\n");
return AL_FALSE;
}
#endif
return AL_TRUE;
}
ALvoid UnloadOAL10Library()
{
// Unload the dll
if (g_hOpenALDLL)
{
FreeLibrary(g_hOpenALDLL);
g_hOpenALDLL = NULL;
}
}