From f86774605f46a911c995525e242f0b46d07e2471 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Thu, 30 Jan 2025 15:06:27 +0000 Subject: [PATCH 01/19] oal loading update oal loading more to be added to this to get other drivers working build and run: backup commit before changing how devices are initialized --- Engine/lib/CMakeLists.txt | 4 - Engine/source/CMakeLists.txt | 3 + Engine/source/sfx/openal/LoadOAL.h | 285 +++++---- Engine/source/sfx/openal/aldlist.cpp | 4 +- Engine/source/sfx/openal/aldlist.h | 4 +- Engine/source/sfx/openal/sfxALBuffer.cpp | 4 +- Engine/source/sfx/openal/sfxALBuffer.h | 6 +- Engine/source/sfx/openal/sfxALDevice.cpp | 11 +- Engine/source/sfx/openal/sfxALDevice.h | 6 +- Engine/source/sfx/openal/sfxALProvider.cpp | 8 +- Engine/source/sfx/openal/sfxALVoice.cpp | 2 +- Engine/source/sfx/openal/sfxALVoice.h | 6 +- Engine/source/sfx/openal/win32/LoadOAL.cpp | 671 ++++----------------- Engine/source/sfx/sfxSystem.cpp | 4 +- 14 files changed, 337 insertions(+), 681 deletions(-) diff --git a/Engine/lib/CMakeLists.txt b/Engine/lib/CMakeLists.txt index 1000cba536..d293e03e67 100644 --- a/Engine/lib/CMakeLists.txt +++ b/Engine/lib/CMakeLists.txt @@ -14,10 +14,6 @@ else() advanced_option(AL_ALEXT_PROTOTYPES "Use Extended OpenAL options" ON) endif() -if(AL_ALEXT_PROTOTYPES) - addDef( "AL_ALEXT_PROTOTYPES" ) -endif() - #SDL set(SDL_SHARED ON CACHE BOOL "Build a shared version of the library" FORCE) set(SDL_STATIC OFF CACHE BOOL "Build a static version of the library" FORCE) diff --git a/Engine/source/CMakeLists.txt b/Engine/source/CMakeLists.txt index 35d9d81d70..fed34b8f5f 100644 --- a/Engine/source/CMakeLists.txt +++ b/Engine/source/CMakeLists.txt @@ -71,6 +71,9 @@ torqueAddSourceDirectories("ts" "ts/collada" "ts/assimp" "ts/loader" "ts/arch") # Handle SFX - OpenAL is handled as a module later on torqueAddSourceDirectories("sfx" "sfx/media" "sfx/null") if(TORQUE_SFX_OPENAL AND NOT TORQUE_DEDICATED) + if(AL_ALEXT_PROTOTYPES) + addDef( "AL_ALEXT_PROTOTYPES" ) + endif() torqueAddSourceDirectories("sfx/openal") if(WIN32) torqueAddSourceDirectories("sfx/openal/win32") diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index dc9cc5de81..9074e7cbf7 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -44,6 +44,40 @@ # include #endif +#if defined(TORQUE_OS_WIN) +#include +#define LIB_HANDLE HINSTANCE +#define LOAD_LIBRARY(path) LoadLibraryW(path) +#define GET_PROC_ADDRESS(lib, name) GetProcAddress(lib, name) +#define CLOSE_LIBRARY(lib) FreeLibrary(lib) +#define LIB_EXTENSION L".dll" +#else +#include +#define LIB_HANDLE void* +#define LOAD_LIBRARY(path) dlopen(path, RTLD_NOW) +#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 + +#define LOAD_REQUIRED(table, x) \ + table.x = reinterpret_cast(reinterpret_cast( \ + GET_PROC_ADDRESS(table.openaAlDll, #x))); \ + if(!table.x) \ + { \ + Con::warnf("Failed to find entry point :%s\n", #x); \ + loadok = false; \ + } + + +constexpr auto MakeALCVer(int major, int minor) noexcept -> int { + return (major << 8) | minor; +} + #ifndef ALAPIENTRY #define ALAPIENTRY #endif @@ -54,8 +88,8 @@ // Open AL Function table definition -#ifndef _OPENALFNTABLE -#define _OPENALFNTABLE +#ifndef _openAlInterface +#define _openAlInterface // AL 1.0 did not define the ALchar and ALCchar types, so define them here // if they don't exist @@ -68,110 +102,155 @@ #define ALCchar char #endif -typedef struct +struct openAlInterface { - 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; -#endif + 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 }; + LPALCGETSTRINGISOFT alcGetStringiSOFT{ nullptr }; + LPALCRESETDEVICESOFT alcResetDeviceSOFT{ nullptr }; + + int ALCVer{ 0 }; + LIB_HANDLE openaAlDll{ nullptr }; + + virtual ~openAlInterface() { + if (openaAlDll) + CLOSE_LIBRARY(openaAlDll); + } + +}; -} OPENALFNTABLE, *LPOPENALFNTABLE; #endif -ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable); -ALvoid UnloadOAL10Library(); +ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable); #endif // _LOADOAL_H_ diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp index b80efd21f5..145e0ec2ef 100644 --- a/Engine/source/sfx/openal/aldlist.cpp +++ b/Engine/source/sfx/openal/aldlist.cpp @@ -36,7 +36,7 @@ /* * Init call */ -ALDeviceList::ALDeviceList( const OPENALFNTABLE &oalft ) +ALDeviceList::ALDeviceList( const openAlInterface &oalft ) { VECTOR_SET_ASSOCIATION( vDeviceInfo ); @@ -45,7 +45,7 @@ ALDeviceList::ALDeviceList( const OPENALFNTABLE &oalft ) int index; const char *defaultDeviceName; - dMemcpy( &ALFunction, &oalft, sizeof( OPENALFNTABLE ) ); + dMemcpy( &ALFunction, &oalft, sizeof( openAlInterface ) ); // DeviceInfo vector stores, for each enumerated device, it's device name, selection status, spec version #, and extension support vDeviceInfo.clear(); diff --git a/Engine/source/sfx/openal/aldlist.h b/Engine/source/sfx/openal/aldlist.h index 7927914cf8..9e8d246c69 100644 --- a/Engine/source/sfx/openal/aldlist.h +++ b/Engine/source/sfx/openal/aldlist.h @@ -43,13 +43,13 @@ typedef struct class ALDeviceList { private: - OPENALFNTABLE ALFunction; + openAlInterface ALFunction; Vector vDeviceInfo; S32 defaultDeviceIndex; S32 filterIndex; public: - ALDeviceList ( const OPENALFNTABLE &oalft ); + ALDeviceList ( const openAlInterface &oalft ); ~ALDeviceList (); S32 GetNumDevices(); const char *GetDeviceName(S32 index); diff --git a/Engine/source/sfx/openal/sfxALBuffer.cpp b/Engine/source/sfx/openal/sfxALBuffer.cpp index c276e2a3df..b1fd1ffb1c 100644 --- a/Engine/source/sfx/openal/sfxALBuffer.cpp +++ b/Engine/source/sfx/openal/sfxALBuffer.cpp @@ -30,7 +30,7 @@ //#define DEBUG_SPEW -SFXALBuffer* SFXALBuffer::create( const OPENALFNTABLE &oalft, +SFXALBuffer* SFXALBuffer::create( const openAlInterface &oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ) @@ -49,7 +49,7 @@ SFXALBuffer* SFXALBuffer::create( const OPENALFNTABLE &oalft, return buffer; } -SFXALBuffer::SFXALBuffer( const OPENALFNTABLE &oalft, +SFXALBuffer::SFXALBuffer( const openAlInterface &oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ) diff --git a/Engine/source/sfx/openal/sfxALBuffer.h b/Engine/source/sfx/openal/sfxALBuffer.h index 26864a3d06..e3ec180205 100644 --- a/Engine/source/sfx/openal/sfxALBuffer.h +++ b/Engine/source/sfx/openal/sfxALBuffer.h @@ -55,7 +55,7 @@ class SFXALBuffer : public SFXBuffer Vector< ALuint > mFreeBuffers; /// - SFXALBuffer( const OPENALFNTABLE &oalft, + SFXALBuffer( const openAlInterface &oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ); @@ -66,7 +66,7 @@ class SFXALBuffer : public SFXBuffer /// bool mUseHardware; - const OPENALFNTABLE &mOpenAL; + const openAlInterface &mOpenAL; /// ALenum _getALFormat() const @@ -108,7 +108,7 @@ class SFXALBuffer : public SFXBuffer public: - static SFXALBuffer* create( const OPENALFNTABLE &oalft, + static SFXALBuffer* create( const openAlInterface &oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ); diff --git a/Engine/source/sfx/openal/sfxALDevice.cpp b/Engine/source/sfx/openal/sfxALDevice.cpp index 765cb01fff..1f883e7816 100644 --- a/Engine/source/sfx/openal/sfxALDevice.cpp +++ b/Engine/source/sfx/openal/sfxALDevice.cpp @@ -106,7 +106,7 @@ S32 SFXALDevice::getMaxSourcesOld() //----------------------------------------------------------------------------- SFXALDevice::SFXALDevice( SFXProvider *provider, - const OPENALFNTABLE &openal, + const openAlInterface &openal, String name, bool useHardware, S32 maxBuffers ) @@ -190,14 +190,15 @@ SFXALDevice::~SFXALDevice() { _releaseAllResources(); ///cleanup our effects -#if defined(AL_ALEXT_PROTOTYPES) - mOpenAL.alDeleteAuxiliaryEffectSlots(4, effectSlot); - mOpenAL.alDeleteEffects(2, effect); -#endif +//#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 ); + } //----------------------------------------------------------------------------- diff --git a/Engine/source/sfx/openal/sfxALDevice.h b/Engine/source/sfx/openal/sfxALDevice.h index 3d2bf5e78e..d478552da3 100644 --- a/Engine/source/sfx/openal/sfxALDevice.h +++ b/Engine/source/sfx/openal/sfxALDevice.h @@ -41,7 +41,7 @@ class SFXProvider; # include "sfx/openal/sfxALVoice.h" #endif -#ifndef _OPENALFNTABLE +#ifndef _openAlInterface # include "sfx/openal/LoadOAL.h" #endif @@ -62,7 +62,7 @@ class SFXALDevice : public SFXDevice S32 getMaxSourcesOld(); SFXALDevice( SFXProvider *provider, - const OPENALFNTABLE &openal, + const openAlInterface& openal, String name, bool useHardware, S32 maxBuffers ); @@ -71,7 +71,7 @@ class SFXALDevice : public SFXDevice protected: - OPENALFNTABLE mOpenAL; + openAlInterface mOpenAL; ALCcontext *mContext; diff --git a/Engine/source/sfx/openal/sfxALProvider.cpp b/Engine/source/sfx/openal/sfxALProvider.cpp index 28a28b9e48..8d82ab453c 100644 --- a/Engine/source/sfx/openal/sfxALProvider.cpp +++ b/Engine/source/sfx/openal/sfxALProvider.cpp @@ -40,7 +40,7 @@ class SFXALProvider : public SFXProvider virtual ~SFXALProvider(); protected: - OPENALFNTABLE mOpenAL; + openAlInterface mOpenAL; ALDeviceList *mALDL; struct ALDeviceInfo : SFXDeviceInfo @@ -76,7 +76,7 @@ MODULE_END; void SFXALProvider::init() { - if( LoadOAL10Library( NULL, &mOpenAL ) != AL_TRUE ) + if( LoadOAL10Library( NULL, mOpenAL ) != AL_TRUE ) { Con::printf( "SFXALProvider - OpenAL not available." ); return; @@ -108,10 +108,8 @@ void SFXALProvider::init() SFXALProvider::~SFXALProvider() { - UnloadOAL10Library(); - if (mALDL) - delete mALDL; + delete mALDL; } SFXDevice *SFXALProvider::createDevice( const String& deviceName, bool useHardware, S32 maxBuffers ) diff --git a/Engine/source/sfx/openal/sfxALVoice.cpp b/Engine/source/sfx/openal/sfxALVoice.cpp index 12267d3c0e..9546065c23 100644 --- a/Engine/source/sfx/openal/sfxALVoice.cpp +++ b/Engine/source/sfx/openal/sfxALVoice.cpp @@ -64,7 +64,7 @@ SFXALVoice* SFXALVoice::create( SFXALDevice* device, SFXALBuffer *buffer ) return voice; } -SFXALVoice::SFXALVoice( const OPENALFNTABLE &oalft, +SFXALVoice::SFXALVoice( const openAlInterface &oalft, SFXALBuffer *buffer, ALuint sourceName ) diff --git a/Engine/source/sfx/openal/sfxALVoice.h b/Engine/source/sfx/openal/sfxALVoice.h index 2f3dd8eca6..605d465ed2 100644 --- a/Engine/source/sfx/openal/sfxALVoice.h +++ b/Engine/source/sfx/openal/sfxALVoice.h @@ -26,7 +26,7 @@ #ifndef _SFXVOICE_H_ #include "sfx/sfxVoice.h" #endif -#ifndef _OPENALFNTABLE +#ifndef _openAlInterface #include "sfx/openal/LoadOAL.h" #endif #ifndef _PLATFORM_THREADS_MUTEX_H_ @@ -47,7 +47,7 @@ class SFXALVoice : public SFXVoice protected: - SFXALVoice( const OPENALFNTABLE &oalft, + SFXALVoice( const openAlInterface &oalft, SFXALBuffer *buffer, ALuint sourceName ); @@ -65,7 +65,7 @@ class SFXALVoice : public SFXVoice Mutex mMutex; - const OPENALFNTABLE &mOpenAL; + const openAlInterface &mOpenAL; /// SFXALBuffer* _getBuffer() const diff --git a/Engine/source/sfx/openal/win32/LoadOAL.cpp b/Engine/source/sfx/openal/win32/LoadOAL.cpp index 4c1888a695..15f1b8b073 100644 --- a/Engine/source/sfx/openal/win32/LoadOAL.cpp +++ b/Engine/source/sfx/openal/win32/LoadOAL.cpp @@ -24,578 +24,157 @@ #include #include "sfx/openal/LoadOAL.h" +#include "console/console.h" -HINSTANCE g_hOpenALDLL = NULL; -ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable) +ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable) { - if (!lpOALFnTable) - return AL_FALSE; - if (szOALFullPathName) - g_hOpenALDLL = LoadLibraryA(szOALFullPathName); + lpOALFnTable.openaAlDll = LoadLibraryA(szOALFullPathName); else { #ifdef TORQUE_DEBUG - g_hOpenALDLL = LoadLibraryA("openal32d.dll"); + lpOALFnTable.openaAlDll = LoadLibraryA("openal32d.dll"); #else - g_hOpenALDLL = LoadLibraryA("openal32.dll"); + lpOALFnTable.openaAlDll = LoadLibraryA("openal32.dll"); #endif } - if (!g_hOpenALDLL) + if (!lpOALFnTable.openaAlDll) return AL_FALSE; - memset(lpOALFnTable, 0, sizeof(OPENALFNTABLE)); + bool loadok = true; - // 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"); - } + LOAD_REQUIRED(lpOALFnTable, alcCreateContext); + LOAD_REQUIRED(lpOALFnTable, alcMakeContextCurrent); + LOAD_REQUIRED(lpOALFnTable, alcProcessContext); + LOAD_REQUIRED(lpOALFnTable, alcSuspendContext); + LOAD_REQUIRED(lpOALFnTable, alcDestroyContext); + LOAD_REQUIRED(lpOALFnTable, alcGetCurrentContext); + LOAD_REQUIRED(lpOALFnTable, alcGetContextsDevice); + LOAD_REQUIRED(lpOALFnTable, alcOpenDevice); + LOAD_REQUIRED(lpOALFnTable, alcCloseDevice); + LOAD_REQUIRED(lpOALFnTable, alcGetError); + LOAD_REQUIRED(lpOALFnTable, alcIsExtensionPresent); + LOAD_REQUIRED(lpOALFnTable, alcGetProcAddress); + LOAD_REQUIRED(lpOALFnTable, alcGetEnumValue); + LOAD_REQUIRED(lpOALFnTable, alcGetString); + LOAD_REQUIRED(lpOALFnTable, alcGetIntegerv); + LOAD_REQUIRED(lpOALFnTable, alcCaptureOpenDevice); + LOAD_REQUIRED(lpOALFnTable, alcCaptureCloseDevice); + LOAD_REQUIRED(lpOALFnTable, alcCaptureStart); + LOAD_REQUIRED(lpOALFnTable, alcCaptureStop); + LOAD_REQUIRED(lpOALFnTable, alcCaptureSamples); - 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"); + LOAD_REQUIRED(lpOALFnTable, alEnable); + LOAD_REQUIRED(lpOALFnTable, alDisable); + LOAD_REQUIRED(lpOALFnTable, alIsEnabled); + LOAD_REQUIRED(lpOALFnTable, alGetString); + LOAD_REQUIRED(lpOALFnTable, alGetBooleanv); + LOAD_REQUIRED(lpOALFnTable, alGetIntegerv); + LOAD_REQUIRED(lpOALFnTable, alGetFloatv); + LOAD_REQUIRED(lpOALFnTable, alGetDoublev); + LOAD_REQUIRED(lpOALFnTable, alGetBoolean); + LOAD_REQUIRED(lpOALFnTable, alGetInteger); + LOAD_REQUIRED(lpOALFnTable, alGetFloat); + LOAD_REQUIRED(lpOALFnTable, alGetDouble); + LOAD_REQUIRED(lpOALFnTable, alGetError); + LOAD_REQUIRED(lpOALFnTable, alIsExtensionPresent); + LOAD_REQUIRED(lpOALFnTable, alGetProcAddress); + LOAD_REQUIRED(lpOALFnTable, alGetEnumValue); + LOAD_REQUIRED(lpOALFnTable, alListenerf); + LOAD_REQUIRED(lpOALFnTable, alListener3f); + LOAD_REQUIRED(lpOALFnTable, alListenerfv); + LOAD_REQUIRED(lpOALFnTable, alListeneri); + LOAD_REQUIRED(lpOALFnTable, alListener3i); + LOAD_REQUIRED(lpOALFnTable, alListeneriv); + LOAD_REQUIRED(lpOALFnTable, alGetListenerf); + LOAD_REQUIRED(lpOALFnTable, alGetListener3f); + LOAD_REQUIRED(lpOALFnTable, alGetListenerfv); + LOAD_REQUIRED(lpOALFnTable, alGetListeneri); + LOAD_REQUIRED(lpOALFnTable, alGetListener3i); + LOAD_REQUIRED(lpOALFnTable, alGetListeneriv); + LOAD_REQUIRED(lpOALFnTable, alGenSources); + LOAD_REQUIRED(lpOALFnTable, alDeleteSources); + LOAD_REQUIRED(lpOALFnTable, alIsSource); + LOAD_REQUIRED(lpOALFnTable, alSourcef); + LOAD_REQUIRED(lpOALFnTable, alSource3f); + LOAD_REQUIRED(lpOALFnTable, alSourcefv); + LOAD_REQUIRED(lpOALFnTable, alSourcei); + LOAD_REQUIRED(lpOALFnTable, alSource3i); + LOAD_REQUIRED(lpOALFnTable, alSourceiv); + LOAD_REQUIRED(lpOALFnTable, alGetSourcef); + LOAD_REQUIRED(lpOALFnTable, alGetSource3f); + LOAD_REQUIRED(lpOALFnTable, alGetSourcefv); + LOAD_REQUIRED(lpOALFnTable, alGetSourcei); + LOAD_REQUIRED(lpOALFnTable, alGetSource3i); + LOAD_REQUIRED(lpOALFnTable, alGetSourceiv); + LOAD_REQUIRED(lpOALFnTable, alSourcePlayv); + LOAD_REQUIRED(lpOALFnTable, alSourceStopv); + LOAD_REQUIRED(lpOALFnTable, alSourceRewindv); + LOAD_REQUIRED(lpOALFnTable, alSourcePausev); + LOAD_REQUIRED(lpOALFnTable, alSourcePlay); + LOAD_REQUIRED(lpOALFnTable, alSourceStop); + LOAD_REQUIRED(lpOALFnTable, alSourceRewind); + LOAD_REQUIRED(lpOALFnTable, alSourcePause); + LOAD_REQUIRED(lpOALFnTable, alSourceQueueBuffers); + LOAD_REQUIRED(lpOALFnTable, alSourceUnqueueBuffers); + LOAD_REQUIRED(lpOALFnTable, alGenBuffers); + LOAD_REQUIRED(lpOALFnTable, alDeleteBuffers); + LOAD_REQUIRED(lpOALFnTable, alIsBuffer); + LOAD_REQUIRED(lpOALFnTable, alBufferData); + LOAD_REQUIRED(lpOALFnTable, alDopplerFactor); + LOAD_REQUIRED(lpOALFnTable, alDopplerVelocity); + LOAD_REQUIRED(lpOALFnTable, alSpeedOfSound); + LOAD_REQUIRED(lpOALFnTable, alDistanceModel); - lpOALFnTable->alGenFilters = (LPALGENFILTERS)GetProcAddress(g_hOpenALDLL, "alGenFilters"); - if (lpOALFnTable->alGenFilters == NULL) - { - OutputDebugStringA("Failed to retrieve 'alGenFilters' function address\n"); - return AL_FALSE; + if (loadok) + { + ALCint maj, min; + lpOALFnTable.alcGetIntegerv(nullptr, ALC_MAJOR_VERSION, 1, &maj); + lpOALFnTable.alcGetIntegerv(nullptr, ALC_MINOR_VERSION, 1, &min); + if (lpOALFnTable.alcGetError(nullptr) == ALC_NO_ERROR) + { + lpOALFnTable.ALCVer = MakeALCVer(maj, min); + } + else + { + Con::warnf("Failed to query ALC version assuming 1.0"); + lpOALFnTable.ALCVer = MakeALCVer(1, 0); + } } - - lpOALFnTable->alDeleteFilters = (LPALDELETEFILTERS)GetProcAddress(g_hOpenALDLL, "alDeleteFilters"); - if (lpOALFnTable->alGenFilters == NULL) + else { - OutputDebugStringA("Failed to retrieve 'alDeleteFilters' function address\n"); return AL_FALSE; } - lpOALFnTable->alFilteri = (LPALFILTERI)GetProcAddress(g_hOpenALDLL, "alFilteri"); - if (lpOALFnTable->alGenFilters == NULL) + // these are optional. + LOAD_REQUIRED(lpOALFnTable, alBufferf); + LOAD_REQUIRED(lpOALFnTable, alBuffer3f); + LOAD_REQUIRED(lpOALFnTable, alBufferfv); + LOAD_REQUIRED(lpOALFnTable, alBufferi); + LOAD_REQUIRED(lpOALFnTable, alBuffer3i); + LOAD_REQUIRED(lpOALFnTable, alBufferiv); + LOAD_REQUIRED(lpOALFnTable, alGetBufferf); + LOAD_REQUIRED(lpOALFnTable, alGetBuffer3f); + LOAD_REQUIRED(lpOALFnTable, alGetBufferfv); + LOAD_REQUIRED(lpOALFnTable, alGetBufferi); + LOAD_REQUIRED(lpOALFnTable, alGetBuffer3i); + LOAD_REQUIRED(lpOALFnTable, alGetBufferiv); + + if (loadok) { - OutputDebugStringA("Failed to retrieve 'alFilteri' function address\n"); - return AL_FALSE; + if (lpOALFnTable.alcIsExtensionPresent(nullptr, "ALC_EXT_thread_local_context")) + { + LOAD_REQUIRED(lpOALFnTable, alcSetThreadContext); + LOAD_REQUIRED(lpOALFnTable, alcGetThreadContext); + } } - - lpOALFnTable->alcGetStringiSOFT = (LPALCGETSTRINGISOFT)GetProcAddress(g_hOpenALDLL, "alcGetStringiSOFT"); - if (lpOALFnTable->alcGetStringiSOFT == NULL) + + if (!loadok) { - 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; - } -} diff --git a/Engine/source/sfx/sfxSystem.cpp b/Engine/source/sfx/sfxSystem.cpp index 37133de0db..0903536cfc 100644 --- a/Engine/source/sfx/sfxSystem.cpp +++ b/Engine/source/sfx/sfxSystem.cpp @@ -454,8 +454,8 @@ bool SFXSystem::createDevice( const String& providerName, const String& deviceNa mDevice->setRolloffFactor( mRolloffFactor ); //OpenAL requires slots for effects, this creates an empty function //that will run when a sfxdevice is created. - mDevice->openSlots(); - mDevice->setReverb( mReverb ); + //mDevice->openSlots(); + //mDevice->setReverb( mReverb ); // Signal system. From d2fd3f26b3fed77a16ef7cada90f92b0bab7abe6 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Thu, 30 Jan 2025 18:04:33 +0000 Subject: [PATCH 02/19] remove internal name remove internal name property was just causing issues use actual device name loadOal is now cross platform, no longer a separate implementation for linux/mac etc --- Engine/source/CMakeLists.txt | 7 - .../source/sfx/openal/{win32 => }/LoadOAL.cpp | 88 ++- Engine/source/sfx/openal/LoadOAL.h | 2 + Engine/source/sfx/openal/aldlist.cpp | 72 +- Engine/source/sfx/openal/aldlist.h | 2 - .../source/sfx/openal/linux/LoadOAL.linux.cpp | 616 ----------------- Engine/source/sfx/openal/mac/LoadOAL.mac.cpp | 618 ------------------ Engine/source/sfx/openal/sfxALProvider.cpp | 7 +- 8 files changed, 128 insertions(+), 1284 deletions(-) rename Engine/source/sfx/openal/{win32 => }/LoadOAL.cpp (78%) delete mode 100644 Engine/source/sfx/openal/linux/LoadOAL.linux.cpp delete mode 100644 Engine/source/sfx/openal/mac/LoadOAL.mac.cpp diff --git a/Engine/source/CMakeLists.txt b/Engine/source/CMakeLists.txt index fed34b8f5f..37b31addbf 100644 --- a/Engine/source/CMakeLists.txt +++ b/Engine/source/CMakeLists.txt @@ -75,13 +75,6 @@ if(TORQUE_SFX_OPENAL AND NOT TORQUE_DEDICATED) addDef( "AL_ALEXT_PROTOTYPES" ) endif() torqueAddSourceDirectories("sfx/openal") - if(WIN32) - torqueAddSourceDirectories("sfx/openal/win32") - elseif(UNIX AND NOT APPLE) - torqueAddSourceDirectories("sfx/openal/linux") - elseif(APPLE) - torqueAddSourceDirectories("sfx/openal/mac") - endif() endif() # Handle GFX torqueAddSourceDirectories("gfx" "gfx/Null" "gfx/test" "gfx/bitmap" "gfx/bitmap/loaders" "gfx/bitmap/loaders/ies" diff --git a/Engine/source/sfx/openal/win32/LoadOAL.cpp b/Engine/source/sfx/openal/LoadOAL.cpp similarity index 78% rename from Engine/source/sfx/openal/win32/LoadOAL.cpp rename to Engine/source/sfx/openal/LoadOAL.cpp index 15f1b8b073..c339625a05 100644 --- a/Engine/source/sfx/openal/win32/LoadOAL.cpp +++ b/Engine/source/sfx/openal/LoadOAL.cpp @@ -22,10 +22,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sfx/openal/LoadOAL.h" #include "console/console.h" +#if defined(TORQUE_OS_WIN) +#include +#else +#include +#include +#endif ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable) { @@ -178,3 +183,84 @@ ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTabl return AL_TRUE; } +void LoadDriverList() +{ + Vector driverPaths; + + /// make sure our built dll is top of the list. +#if defined(TORQUE_OS_WIN) + +#ifdef TORQUE_DEBUG + driverPaths.push_back("openal32d.dll"); +#else + driverPaths.push_back("openal32.dll"); +#endif + + char sys_path[MAX_PATH]; + if (GetSystemDirectoryA(sys_path, MAX_PATH)) + { + String searchPath = String::ToString(sys_path) + "\\*oal.dll"; + + WIN32_FIND_DATAA fdata; + HANDLE srchHdl = FindFirstFileA(searchPath.c_str(), &fdata); + if (srchHdl == INVALID_HANDLE_VALUE) return; + + do { + String fullPath = String::ToString(sys_path) + "\\" + fdata.cFileName; + driverPaths.push_back(fullPath); + } while (FindNextFileA(srchHdl, &fdata)); + + FindClose(srchHdl); + } + +#else // Linux & macOS + const char* sys_path = "/usr/lib/"; + +#ifdef __linux__ + +#ifdef TORQUE_DEBUG + driverPaths.push_back("libopenald.so.1"); + driverPaths.push_back("libopenald.so"); +#else + driverPaths.push_back("libopenal.so.1"); + driverPaths.push_back("libopenal.so"); +#endif + + const char* pattern = "*oal.so" + +#elif __APPLE__ + +#ifdef TORQUE_DEBUG + driverPaths.push_back("@rpath/libopenald.1.dylib"); + driverPaths.push_back("@rpath/libopenald.1.23.1.dylib"); +#else + driverPaths.push_back("@rpath/libopenal.1.dylib"); + driverPaths.push_back("@rpath/libopenal.1.23.1.dylib"); +#endif + + const char* pattern = "*oal.dylib" + +#endif + + char search[1024]; + dSprintf(search, sizeof(search), "%s", sys_path, pattern); + + DIR* dir = opendir(search); + if (!dir) return; + + struct dirent* fEntry; + while ((fEntry = readdir(dir)) != nullptr) + { + if ((fStat.st_mode & S_IFMT) == S_IFDIR) + continue; + + char filename[BUFSIZ + 1]; + dSprintf(filename, sizeof(filename), "%s/%s", search, fEntry->d_name); // "construct" the file name + String fullPath = String::ToString(filename); + driverPaths.push_back(fullPath); + } + + closedir(dir); +#endif +} + diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index 9074e7cbf7..19ccaf8120 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -253,4 +253,6 @@ struct openAlInterface ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable); +void LoadDriverList(); + #endif // _LOADOAL_H_ diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp index 145e0ec2ef..1337c3be0b 100644 --- a/Engine/source/sfx/openal/aldlist.cpp +++ b/Engine/source/sfx/openal/aldlist.cpp @@ -33,6 +33,7 @@ #include #endif + /* * Init call */ @@ -44,6 +45,7 @@ ALDeviceList::ALDeviceList( const openAlInterface &oalft ) char *devices; int index; const char *defaultDeviceName; + const char *actualDeviceName; dMemcpy( &ALFunction, &oalft, sizeof( openAlInterface ) ); @@ -66,44 +68,48 @@ ALDeviceList::ALDeviceList( const openAlInterface &oalft ) index = 0; // go through device list (each device terminated with a single NULL, list terminated with double NULL) - while (*devices != 0) { + while (*devices != '\0') { if (String::compare(defaultDeviceName, devices) == 0) { defaultDeviceIndex = index; } - bool bNewName = true; - for (int i = 0; i < GetNumDevices(); i++) { - if (String::compare(GetDeviceName(i), devices) == 0) { - bNewName = false; - } - } - - if ((bNewName) && (devices != NULL) && (dStrlen(devices) > 0)) + ALCdevice* device = ALFunction.alcOpenDevice(devices); + if (device) { - dMemset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO)); - ALDeviceInfo.bSelected = true; - dStrncpy(ALDeviceInfo.strInternalDeviceName, devices, sizeof(ALDeviceInfo.strInternalDeviceName)); - char deviceExternal[256]; - dStrcpy(deviceExternal, devices, 256); - char* openFind = dStrchr(deviceExternal, '('); - if (openFind) - { - char* deviceName = openFind + 1; - char* closeFind = dStrchr(deviceName, ')'); - if (closeFind) - (*closeFind) = '\0'; - - dStrncpy(ALDeviceInfo.strDeviceName, deviceName, sizeof(ALDeviceInfo.strDeviceName)); + ALCcontext* ctx = ALFunction.alcCreateContext(device, nullptr); - } - else + if (ctx) { - dStrncpy(ALDeviceInfo.strDeviceName, devices, sizeof(ALDeviceInfo.strDeviceName)); + 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); } - - vDeviceInfo.push_back(ALDeviceInfo); + ALFunction.alcCloseDevice(device); } - + devices += dStrlen(devices) + 1; index += 1; } @@ -129,14 +135,6 @@ int ALDeviceList::GetNumDevices() /* * Returns the device name at an index in the complete device list */ -const char *ALDeviceList::GetInternalDeviceName(int index) -{ - if (index < GetNumDevices()) - return vDeviceInfo[index].strInternalDeviceName; - else - return NULL; -} - const char* ALDeviceList::GetDeviceName(int index) { if (index < GetNumDevices()) diff --git a/Engine/source/sfx/openal/aldlist.h b/Engine/source/sfx/openal/aldlist.h index 9e8d246c69..fdb1d2939a 100644 --- a/Engine/source/sfx/openal/aldlist.h +++ b/Engine/source/sfx/openal/aldlist.h @@ -32,7 +32,6 @@ typedef struct { char strDeviceName[256]; - char strInternalDeviceName[256]; S32 iMajorVersion; S32 iMinorVersion; U32 uiSourceCount; @@ -53,7 +52,6 @@ class ALDeviceList ~ALDeviceList (); S32 GetNumDevices(); const char *GetDeviceName(S32 index); - const char *GetInternalDeviceName(S32 index); void GetDeviceVersion(S32 index, S32 *major, S32 *minor); U32 GetMaxNumSources(S32 index); bool IsExtensionSupported(S32 index, SFXALCaps caps); diff --git a/Engine/source/sfx/openal/linux/LoadOAL.linux.cpp b/Engine/source/sfx/openal/linux/LoadOAL.linux.cpp deleted file mode 100644 index 0ac1a59b3e..0000000000 --- a/Engine/source/sfx/openal/linux/LoadOAL.linux.cpp +++ /dev/null @@ -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 -#include -#include -#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); -} diff --git a/Engine/source/sfx/openal/mac/LoadOAL.mac.cpp b/Engine/source/sfx/openal/mac/LoadOAL.mac.cpp deleted file mode 100644 index baf40d33be..0000000000 --- a/Engine/source/sfx/openal/mac/LoadOAL.mac.cpp +++ /dev/null @@ -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 -#include -#include -#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); -} diff --git a/Engine/source/sfx/openal/sfxALProvider.cpp b/Engine/source/sfx/openal/sfxALProvider.cpp index 8d82ab453c..748eabe986 100644 --- a/Engine/source/sfx/openal/sfxALProvider.cpp +++ b/Engine/source/sfx/openal/sfxALProvider.cpp @@ -76,6 +76,8 @@ MODULE_END; void SFXALProvider::init() { + LoadDriverList(); + if( LoadOAL10Library( NULL, mOpenAL ) != AL_TRUE ) { Con::printf( "SFXALProvider - OpenAL not available." ); @@ -96,8 +98,7 @@ void SFXALProvider::init() 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 ); @@ -119,7 +120,7 @@ SFXDevice *SFXALProvider::createDevice( const String& deviceName, bool useHardwa // Do we find one to create? if (info) - return new SFXALDevice(this, mOpenAL, info->internalName, useHardware, maxBuffers); + return new SFXALDevice(this, mOpenAL, info->name, useHardware, maxBuffers); return NULL; } From 85761c2efcf433098163ee998a7b37bef4a1fbcb Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Thu, 30 Jan 2025 20:34:05 +0000 Subject: [PATCH 03/19] more groundwork drivers now saved to a list sfxInit class start of mirroring gfx layer. --- Engine/source/sfx/SFXInit.cpp | 41 +++ Engine/source/sfx/SFXInit.h | 18 ++ Engine/source/sfx/openal/LoadOAL.cpp | 284 ++++++++++----------- Engine/source/sfx/openal/LoadOAL.h | 44 ++-- Engine/source/sfx/openal/aldlist.cpp | 205 +++++++-------- Engine/source/sfx/openal/aldlist.h | 6 +- Engine/source/sfx/openal/sfxALDevice.h | 2 +- Engine/source/sfx/openal/sfxALProvider.cpp | 12 +- Engine/source/sfx/openal/sfxALVoice.h | 4 +- 9 files changed, 334 insertions(+), 282 deletions(-) create mode 100644 Engine/source/sfx/SFXInit.cpp create mode 100644 Engine/source/sfx/SFXInit.h diff --git a/Engine/source/sfx/SFXInit.cpp b/Engine/source/sfx/SFXInit.cpp new file mode 100644 index 0000000000..9043ef1c80 --- /dev/null +++ b/Engine/source/sfx/SFXInit.cpp @@ -0,0 +1,41 @@ +//----------------------------------------------------------------------------- +// 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/SFXInit.h" + +#include "console/console.h" +#include "core/module.h" + +MODULE_BEGIN(SFXNEW) + +MODULE_INIT +{ + +} + +MODULE_SHUTDOWN +{ + +} + +MODULE_END; diff --git a/Engine/source/sfx/SFXInit.h b/Engine/source/sfx/SFXInit.h new file mode 100644 index 0000000000..a9d8891702 --- /dev/null +++ b/Engine/source/sfx/SFXInit.h @@ -0,0 +1,18 @@ +#pragma once + +#ifndef _SFXINIT_H_ +#define _SFXINIT_H_ + +#ifndef _ENGINEOBJECT_H_ +#include "console/engineObject.h" +#endif + +class SFXInit +{ + DECLARE_STATIC_CLASS(SFXInit) + +public: + +}; + +#endif // !_SFXINIT_H_ diff --git a/Engine/source/sfx/openal/LoadOAL.cpp b/Engine/source/sfx/openal/LoadOAL.cpp index c339625a05..ffbc15f288 100644 --- a/Engine/source/sfx/openal/LoadOAL.cpp +++ b/Engine/source/sfx/openal/LoadOAL.cpp @@ -32,155 +32,135 @@ #include #endif -ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable) +void AddDriver(const char* name, LIB_HANDLE dllHandle) { - if (szOALFullPathName) - lpOALFnTable.openaAlDll = LoadLibraryA(szOALFullPathName); - else - { -#ifdef TORQUE_DEBUG - lpOALFnTable.openaAlDll = LoadLibraryA("openal32d.dll"); -#else - lpOALFnTable.openaAlDll = LoadLibraryA("openal32.dll"); -#endif - } - if (!lpOALFnTable.openaAlDll) - return AL_FALSE; + openAlInterface* oal = new openAlInterface(name, dllHandle); bool loadok = true; - LOAD_REQUIRED(lpOALFnTable, alcCreateContext); - LOAD_REQUIRED(lpOALFnTable, alcMakeContextCurrent); - LOAD_REQUIRED(lpOALFnTable, alcProcessContext); - LOAD_REQUIRED(lpOALFnTable, alcSuspendContext); - LOAD_REQUIRED(lpOALFnTable, alcDestroyContext); - LOAD_REQUIRED(lpOALFnTable, alcGetCurrentContext); - LOAD_REQUIRED(lpOALFnTable, alcGetContextsDevice); - LOAD_REQUIRED(lpOALFnTable, alcOpenDevice); - LOAD_REQUIRED(lpOALFnTable, alcCloseDevice); - LOAD_REQUIRED(lpOALFnTable, alcGetError); - LOAD_REQUIRED(lpOALFnTable, alcIsExtensionPresent); - LOAD_REQUIRED(lpOALFnTable, alcGetProcAddress); - LOAD_REQUIRED(lpOALFnTable, alcGetEnumValue); - LOAD_REQUIRED(lpOALFnTable, alcGetString); - LOAD_REQUIRED(lpOALFnTable, alcGetIntegerv); - LOAD_REQUIRED(lpOALFnTable, alcCaptureOpenDevice); - LOAD_REQUIRED(lpOALFnTable, alcCaptureCloseDevice); - LOAD_REQUIRED(lpOALFnTable, alcCaptureStart); - LOAD_REQUIRED(lpOALFnTable, alcCaptureStop); - LOAD_REQUIRED(lpOALFnTable, alcCaptureSamples); - - LOAD_REQUIRED(lpOALFnTable, alEnable); - LOAD_REQUIRED(lpOALFnTable, alDisable); - LOAD_REQUIRED(lpOALFnTable, alIsEnabled); - LOAD_REQUIRED(lpOALFnTable, alGetString); - LOAD_REQUIRED(lpOALFnTable, alGetBooleanv); - LOAD_REQUIRED(lpOALFnTable, alGetIntegerv); - LOAD_REQUIRED(lpOALFnTable, alGetFloatv); - LOAD_REQUIRED(lpOALFnTable, alGetDoublev); - LOAD_REQUIRED(lpOALFnTable, alGetBoolean); - LOAD_REQUIRED(lpOALFnTable, alGetInteger); - LOAD_REQUIRED(lpOALFnTable, alGetFloat); - LOAD_REQUIRED(lpOALFnTable, alGetDouble); - LOAD_REQUIRED(lpOALFnTable, alGetError); - LOAD_REQUIRED(lpOALFnTable, alIsExtensionPresent); - LOAD_REQUIRED(lpOALFnTable, alGetProcAddress); - LOAD_REQUIRED(lpOALFnTable, alGetEnumValue); - LOAD_REQUIRED(lpOALFnTable, alListenerf); - LOAD_REQUIRED(lpOALFnTable, alListener3f); - LOAD_REQUIRED(lpOALFnTable, alListenerfv); - LOAD_REQUIRED(lpOALFnTable, alListeneri); - LOAD_REQUIRED(lpOALFnTable, alListener3i); - LOAD_REQUIRED(lpOALFnTable, alListeneriv); - LOAD_REQUIRED(lpOALFnTable, alGetListenerf); - LOAD_REQUIRED(lpOALFnTable, alGetListener3f); - LOAD_REQUIRED(lpOALFnTable, alGetListenerfv); - LOAD_REQUIRED(lpOALFnTable, alGetListeneri); - LOAD_REQUIRED(lpOALFnTable, alGetListener3i); - LOAD_REQUIRED(lpOALFnTable, alGetListeneriv); - LOAD_REQUIRED(lpOALFnTable, alGenSources); - LOAD_REQUIRED(lpOALFnTable, alDeleteSources); - LOAD_REQUIRED(lpOALFnTable, alIsSource); - LOAD_REQUIRED(lpOALFnTable, alSourcef); - LOAD_REQUIRED(lpOALFnTable, alSource3f); - LOAD_REQUIRED(lpOALFnTable, alSourcefv); - LOAD_REQUIRED(lpOALFnTable, alSourcei); - LOAD_REQUIRED(lpOALFnTable, alSource3i); - LOAD_REQUIRED(lpOALFnTable, alSourceiv); - LOAD_REQUIRED(lpOALFnTable, alGetSourcef); - LOAD_REQUIRED(lpOALFnTable, alGetSource3f); - LOAD_REQUIRED(lpOALFnTable, alGetSourcefv); - LOAD_REQUIRED(lpOALFnTable, alGetSourcei); - LOAD_REQUIRED(lpOALFnTable, alGetSource3i); - LOAD_REQUIRED(lpOALFnTable, alGetSourceiv); - LOAD_REQUIRED(lpOALFnTable, alSourcePlayv); - LOAD_REQUIRED(lpOALFnTable, alSourceStopv); - LOAD_REQUIRED(lpOALFnTable, alSourceRewindv); - LOAD_REQUIRED(lpOALFnTable, alSourcePausev); - LOAD_REQUIRED(lpOALFnTable, alSourcePlay); - LOAD_REQUIRED(lpOALFnTable, alSourceStop); - LOAD_REQUIRED(lpOALFnTable, alSourceRewind); - LOAD_REQUIRED(lpOALFnTable, alSourcePause); - LOAD_REQUIRED(lpOALFnTable, alSourceQueueBuffers); - LOAD_REQUIRED(lpOALFnTable, alSourceUnqueueBuffers); - LOAD_REQUIRED(lpOALFnTable, alGenBuffers); - LOAD_REQUIRED(lpOALFnTable, alDeleteBuffers); - LOAD_REQUIRED(lpOALFnTable, alIsBuffer); - LOAD_REQUIRED(lpOALFnTable, alBufferData); - LOAD_REQUIRED(lpOALFnTable, alDopplerFactor); - LOAD_REQUIRED(lpOALFnTable, alDopplerVelocity); - LOAD_REQUIRED(lpOALFnTable, alSpeedOfSound); - LOAD_REQUIRED(lpOALFnTable, alDistanceModel); + 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); if (loadok) { ALCint maj, min; - lpOALFnTable.alcGetIntegerv(nullptr, ALC_MAJOR_VERSION, 1, &maj); - lpOALFnTable.alcGetIntegerv(nullptr, ALC_MINOR_VERSION, 1, &min); - if (lpOALFnTable.alcGetError(nullptr) == ALC_NO_ERROR) + oal->alcGetIntegerv(nullptr, ALC_MAJOR_VERSION, 1, &maj); + oal->alcGetIntegerv(nullptr, ALC_MINOR_VERSION, 1, &min); + if (oal->alcGetError(nullptr) == ALC_NO_ERROR) { - lpOALFnTable.ALCVer = MakeALCVer(maj, min); + oal->ALCVer = MakeALCVer(maj, min); } else { Con::warnf("Failed to query ALC version assuming 1.0"); - lpOALFnTable.ALCVer = MakeALCVer(1, 0); + oal->ALCVer = MakeALCVer(1, 0); } } - else - { - return AL_FALSE; - } // these are optional. - LOAD_REQUIRED(lpOALFnTable, alBufferf); - LOAD_REQUIRED(lpOALFnTable, alBuffer3f); - LOAD_REQUIRED(lpOALFnTable, alBufferfv); - LOAD_REQUIRED(lpOALFnTable, alBufferi); - LOAD_REQUIRED(lpOALFnTable, alBuffer3i); - LOAD_REQUIRED(lpOALFnTable, alBufferiv); - LOAD_REQUIRED(lpOALFnTable, alGetBufferf); - LOAD_REQUIRED(lpOALFnTable, alGetBuffer3f); - LOAD_REQUIRED(lpOALFnTable, alGetBufferfv); - LOAD_REQUIRED(lpOALFnTable, alGetBufferi); - LOAD_REQUIRED(lpOALFnTable, alGetBuffer3i); - LOAD_REQUIRED(lpOALFnTable, alGetBufferiv); + 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); if (loadok) { - if (lpOALFnTable.alcIsExtensionPresent(nullptr, "ALC_EXT_thread_local_context")) + if (oal->alcIsExtensionPresent(nullptr, "ALC_EXT_thread_local_context")) { - LOAD_REQUIRED(lpOALFnTable, alcSetThreadContext); - LOAD_REQUIRED(lpOALFnTable, alcGetThreadContext); + LOAD_REQUIRED(oal, alcSetThreadContext); + LOAD_REQUIRED(oal, alcGetThreadContext); } - } - if (!loadok) - { - return AL_FALSE; + ALDriverList.push_back(oal); } - - return AL_TRUE; } void LoadDriverList() @@ -226,8 +206,6 @@ void LoadDriverList() driverPaths.push_back("libopenal.so"); #endif - const char* pattern = "*oal.so" - #elif __APPLE__ #ifdef TORQUE_DEBUG @@ -238,29 +216,47 @@ void LoadDriverList() driverPaths.push_back("@rpath/libopenal.1.23.1.dylib"); #endif - const char* pattern = "*oal.dylib" - #endif + + const char* searchDirs[] = { + "/usr/lib/", + "/usr/local/lib/", + "/Library/Audio/Plug-Ins/HAL/" + }; + + for (const char* sys_path : searchDirs) + { + DIR* dir = opendir(sys_path); + if (!dir) continue; + + struct dirent* entry; + while ((entry = readdir(dir)) != nullptr) + { + std::string fileName(entry->d_name); - char search[1024]; - dSprintf(search, sizeof(search), "%s", sys_path, pattern); +#ifdef __linux__ + if (fileName.find("oal.so") != std::string::npos) +#elif __APPLE__ + if (fileName.find("openal.dylib") != std::string::npos) // Fix for macOS +#endif + { + std::string fullPath = std::string(sys_path) + fileName; + driverPaths.push_back(fullPath); +} + } - DIR* dir = opendir(search); - if (!dir) return; + closedir(dir); + } +#endif - struct dirent* fEntry; - while ((fEntry = readdir(dir)) != nullptr) + for(String driver : driverPaths) { - if ((fStat.st_mode & S_IFMT) == S_IFDIR) - continue; - - char filename[BUFSIZ + 1]; - dSprintf(filename, sizeof(filename), "%s/%s", search, fEntry->d_name); // "construct" the file name - String fullPath = String::ToString(filename); - driverPaths.push_back(fullPath); + LIB_HANDLE mod = LOAD_LIBRARY(driver); + if (mod) + { + AddDriver(driver, mod); + } } - closedir(dir); -#endif } diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index 19ccaf8120..2159e568c9 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -24,30 +24,29 @@ #define _LOADOAL_H_ #ifndef _PLATFORM_H_ -# include "platform/platform.h" +#include "platform/platform.h" +#endif + +#ifndef _TVECTOR_H_ +#include "core/util/tVector.h" #endif #if defined(TORQUE_OS_MAC) #undef AL_ALEXT_PROTOTYPES # include # include -#elif defined(TORQUE_OS_LINUX) +#else # include # include # include # include # include -#else -# include -# include -# include -# include #endif #if defined(TORQUE_OS_WIN) #include #define LIB_HANDLE HINSTANCE -#define LOAD_LIBRARY(path) LoadLibraryW(path) +#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" @@ -64,13 +63,13 @@ #endif #endif -#define LOAD_REQUIRED(table, x) \ - table.x = reinterpret_cast(reinterpret_cast( \ - GET_PROC_ADDRESS(table.openaAlDll, #x))); \ - if(!table.x) \ - { \ - Con::warnf("Failed to find entry point :%s\n", #x); \ - loadok = false; \ +#define LOAD_REQUIRED(table, x) \ + table->x = reinterpret_castx)>(reinterpret_cast( \ + GET_PROC_ADDRESS(table->openaAlDll, #x))); \ + if(!table->x) \ + { \ + Con::warnf("Failed to find entry point :%s\n", #x); \ + loadok = false; \ } @@ -86,11 +85,6 @@ constexpr auto MakeALCVer(int major, int minor) noexcept -> int { #define ALCAPIENTRY #endif -// Open AL Function table definition - -#ifndef _openAlInterface -#define _openAlInterface - // AL 1.0 did not define the ALchar and ALCchar types, so define them here // if they don't exist @@ -241,6 +235,11 @@ struct openAlInterface int ALCVer{ 0 }; LIB_HANDLE openaAlDll{ nullptr }; + String name; + + openAlInterface(const String& inName, LIB_HANDLE mod) + : name(inName), openaAlDll(mod) + {} virtual ~openAlInterface() { if (openaAlDll) @@ -249,9 +248,10 @@ struct openAlInterface }; -#endif +inline Vector ALDriverList; + -ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable); +void AddDriver(const char *name, LIB_HANDLE dllHandle); void LoadDriverList(); diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp index 1337c3be0b..d7e36057fb 100644 --- a/Engine/source/sfx/openal/aldlist.cpp +++ b/Engine/source/sfx/openal/aldlist.cpp @@ -37,84 +37,84 @@ /* * Init call */ -ALDeviceList::ALDeviceList( const openAlInterface &oalft ) +ALDeviceList::ALDeviceList() { - VECTOR_SET_ASSOCIATION( vDeviceInfo ); - - ALDEVICEINFO ALDeviceInfo; - char *devices; - int index; - const char *defaultDeviceName; - const char *actualDeviceName; - - dMemcpy( &ALFunction, &oalft, sizeof( openAlInterface ) ); - - // 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(); + // VECTOR_SET_ASSOCIATION( vDeviceInfo ); + + //ALDEVICEINFO ALDeviceInfo; + //char *devices; + //int index; + //const char *defaultDeviceName; + //const char *actualDeviceName; + + // dMemcpy( &ALFunction, &oalft, sizeof( openAlInterface ) ); + + // // 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(); } /* @@ -275,29 +275,30 @@ int ALDeviceList::GetNextFilteredDevice() */ 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; + return 0; + //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; } diff --git a/Engine/source/sfx/openal/aldlist.h b/Engine/source/sfx/openal/aldlist.h index fdb1d2939a..6a5f74e53a 100644 --- a/Engine/source/sfx/openal/aldlist.h +++ b/Engine/source/sfx/openal/aldlist.h @@ -27,7 +27,10 @@ #include "core/util/tVector.h" #include "core/stringTable.h" #include "sfx/openal/sfxALCaps.h" + +#ifndef _LOADOAL_H_ #include "LoadOAL.h" +#endif typedef struct { @@ -42,13 +45,12 @@ typedef struct class ALDeviceList { private: - openAlInterface ALFunction; Vector vDeviceInfo; S32 defaultDeviceIndex; S32 filterIndex; public: - ALDeviceList ( const openAlInterface &oalft ); + ALDeviceList ( ); ~ALDeviceList (); S32 GetNumDevices(); const char *GetDeviceName(S32 index); diff --git a/Engine/source/sfx/openal/sfxALDevice.h b/Engine/source/sfx/openal/sfxALDevice.h index d478552da3..926e002237 100644 --- a/Engine/source/sfx/openal/sfxALDevice.h +++ b/Engine/source/sfx/openal/sfxALDevice.h @@ -41,7 +41,7 @@ class SFXProvider; # include "sfx/openal/sfxALVoice.h" #endif -#ifndef _openAlInterface +#ifndef _LOADOAL_H_ # include "sfx/openal/LoadOAL.h" #endif diff --git a/Engine/source/sfx/openal/sfxALProvider.cpp b/Engine/source/sfx/openal/sfxALProvider.cpp index 748eabe986..ccc80749b6 100644 --- a/Engine/source/sfx/openal/sfxALProvider.cpp +++ b/Engine/source/sfx/openal/sfxALProvider.cpp @@ -36,11 +36,10 @@ class SFXALProvider : public SFXProvider public: SFXALProvider() - : SFXProvider( "OpenAL" ) { dMemset(&mOpenAL,0,sizeof(mOpenAL)); mALDL = NULL; } + : SFXProvider( "OpenAL" ) { mALDL = NULL; } virtual ~SFXALProvider(); protected: - openAlInterface mOpenAL; ALDeviceList *mALDL; struct ALDeviceInfo : SFXDeviceInfo @@ -78,12 +77,7 @@ void SFXALProvider::init() { LoadDriverList(); - if( LoadOAL10Library( NULL, mOpenAL ) != AL_TRUE ) - { - Con::printf( "SFXALProvider - OpenAL not available." ); - return; - } - mALDL = new ALDeviceList( mOpenAL ); + //mALDL = new ALDeviceList( mOpenAL ); // Did we get any devices? if ( mALDL->GetNumDevices() < 1 ) @@ -120,7 +114,7 @@ SFXDevice *SFXALProvider::createDevice( const String& deviceName, bool useHardwa // Do we find one to create? if (info) - return new SFXALDevice(this, mOpenAL, info->name, useHardware, maxBuffers); + //return new SFXALDevice(this, mOpenAL, info->name, useHardware, maxBuffers); return NULL; } diff --git a/Engine/source/sfx/openal/sfxALVoice.h b/Engine/source/sfx/openal/sfxALVoice.h index 605d465ed2..5fef80c2ee 100644 --- a/Engine/source/sfx/openal/sfxALVoice.h +++ b/Engine/source/sfx/openal/sfxALVoice.h @@ -26,7 +26,7 @@ #ifndef _SFXVOICE_H_ #include "sfx/sfxVoice.h" #endif -#ifndef _openAlInterface +#ifndef _LOADOAL_H_ #include "sfx/openal/LoadOAL.h" #endif #ifndef _PLATFORM_THREADS_MUTEX_H_ @@ -104,4 +104,4 @@ class SFXALVoice : public SFXVoice void setRolloffFactor( F32 factor ) override; }; -#endif // _SFXALVOICE_H_ \ No newline at end of file +#endif // _SFXALVOICE_H_ From debef23947acaa94d3635c3d422b2a9301b45dcf Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Thu, 30 Jan 2025 20:41:15 +0000 Subject: [PATCH 04/19] linux and mac loading fixes --- Engine/source/sfx/openal/LoadOAL.cpp | 10 +++++----- Engine/source/sfx/openal/LoadOAL.h | 6 ------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Engine/source/sfx/openal/LoadOAL.cpp b/Engine/source/sfx/openal/LoadOAL.cpp index ffbc15f288..bce0dff887 100644 --- a/Engine/source/sfx/openal/LoadOAL.cpp +++ b/Engine/source/sfx/openal/LoadOAL.cpp @@ -232,18 +232,18 @@ void LoadDriverList() struct dirent* entry; while ((entry = readdir(dir)) != nullptr) { - std::string fileName(entry->d_name); + String fileName = String::ToString(entry->d_name); #ifdef __linux__ if (fileName.find("oal.so") != std::string::npos) #elif __APPLE__ - if (fileName.find("openal.dylib") != std::string::npos) // Fix for macOS + if (fileName.find("openal.dylib") != String::NPos) // Fix for macOS #endif { - std::string fullPath = std::string(sys_path) + fileName; + String fullPath = String::ToString(sys_path) + fileName; driverPaths.push_back(fullPath); -} - } + } + } closedir(dir); } diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index 2159e568c9..26ffb61aeb 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -31,17 +31,11 @@ #include "core/util/tVector.h" #endif -#if defined(TORQUE_OS_MAC) -#undef AL_ALEXT_PROTOTYPES -# include -# include -#else # include # include # include # include # include -#endif #if defined(TORQUE_OS_WIN) #include From d58bdefd93337a785ad08882368dd74532c848a0 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Thu, 30 Jan 2025 15:06:27 +0000 Subject: [PATCH 05/19] oal loading update oal loading more to be added to this to get other drivers working build and run: backup commit before changing how devices are initialized --- Engine/lib/CMakeLists.txt | 4 - Engine/source/CMakeLists.txt | 3 + Engine/source/sfx/openal/LoadOAL.h | 285 +++++---- Engine/source/sfx/openal/aldlist.cpp | 4 +- Engine/source/sfx/openal/aldlist.h | 4 +- Engine/source/sfx/openal/sfxALBuffer.cpp | 4 +- Engine/source/sfx/openal/sfxALBuffer.h | 6 +- Engine/source/sfx/openal/sfxALDevice.cpp | 11 +- Engine/source/sfx/openal/sfxALDevice.h | 6 +- Engine/source/sfx/openal/sfxALProvider.cpp | 8 +- Engine/source/sfx/openal/sfxALVoice.cpp | 2 +- Engine/source/sfx/openal/sfxALVoice.h | 6 +- Engine/source/sfx/openal/win32/LoadOAL.cpp | 671 ++++----------------- Engine/source/sfx/sfxSystem.cpp | 4 +- 14 files changed, 337 insertions(+), 681 deletions(-) diff --git a/Engine/lib/CMakeLists.txt b/Engine/lib/CMakeLists.txt index 1000cba536..d293e03e67 100644 --- a/Engine/lib/CMakeLists.txt +++ b/Engine/lib/CMakeLists.txt @@ -14,10 +14,6 @@ else() advanced_option(AL_ALEXT_PROTOTYPES "Use Extended OpenAL options" ON) endif() -if(AL_ALEXT_PROTOTYPES) - addDef( "AL_ALEXT_PROTOTYPES" ) -endif() - #SDL set(SDL_SHARED ON CACHE BOOL "Build a shared version of the library" FORCE) set(SDL_STATIC OFF CACHE BOOL "Build a static version of the library" FORCE) diff --git a/Engine/source/CMakeLists.txt b/Engine/source/CMakeLists.txt index 35d9d81d70..fed34b8f5f 100644 --- a/Engine/source/CMakeLists.txt +++ b/Engine/source/CMakeLists.txt @@ -71,6 +71,9 @@ torqueAddSourceDirectories("ts" "ts/collada" "ts/assimp" "ts/loader" "ts/arch") # Handle SFX - OpenAL is handled as a module later on torqueAddSourceDirectories("sfx" "sfx/media" "sfx/null") if(TORQUE_SFX_OPENAL AND NOT TORQUE_DEDICATED) + if(AL_ALEXT_PROTOTYPES) + addDef( "AL_ALEXT_PROTOTYPES" ) + endif() torqueAddSourceDirectories("sfx/openal") if(WIN32) torqueAddSourceDirectories("sfx/openal/win32") diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index dc9cc5de81..9074e7cbf7 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -44,6 +44,40 @@ # include #endif +#if defined(TORQUE_OS_WIN) +#include +#define LIB_HANDLE HINSTANCE +#define LOAD_LIBRARY(path) LoadLibraryW(path) +#define GET_PROC_ADDRESS(lib, name) GetProcAddress(lib, name) +#define CLOSE_LIBRARY(lib) FreeLibrary(lib) +#define LIB_EXTENSION L".dll" +#else +#include +#define LIB_HANDLE void* +#define LOAD_LIBRARY(path) dlopen(path, RTLD_NOW) +#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 + +#define LOAD_REQUIRED(table, x) \ + table.x = reinterpret_cast(reinterpret_cast( \ + GET_PROC_ADDRESS(table.openaAlDll, #x))); \ + if(!table.x) \ + { \ + Con::warnf("Failed to find entry point :%s\n", #x); \ + loadok = false; \ + } + + +constexpr auto MakeALCVer(int major, int minor) noexcept -> int { + return (major << 8) | minor; +} + #ifndef ALAPIENTRY #define ALAPIENTRY #endif @@ -54,8 +88,8 @@ // Open AL Function table definition -#ifndef _OPENALFNTABLE -#define _OPENALFNTABLE +#ifndef _openAlInterface +#define _openAlInterface // AL 1.0 did not define the ALchar and ALCchar types, so define them here // if they don't exist @@ -68,110 +102,155 @@ #define ALCchar char #endif -typedef struct +struct openAlInterface { - 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; -#endif + 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 }; + LPALCGETSTRINGISOFT alcGetStringiSOFT{ nullptr }; + LPALCRESETDEVICESOFT alcResetDeviceSOFT{ nullptr }; + + int ALCVer{ 0 }; + LIB_HANDLE openaAlDll{ nullptr }; + + virtual ~openAlInterface() { + if (openaAlDll) + CLOSE_LIBRARY(openaAlDll); + } + +}; -} OPENALFNTABLE, *LPOPENALFNTABLE; #endif -ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable); -ALvoid UnloadOAL10Library(); +ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable); #endif // _LOADOAL_H_ diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp index f55a565699..1337c3be0b 100644 --- a/Engine/source/sfx/openal/aldlist.cpp +++ b/Engine/source/sfx/openal/aldlist.cpp @@ -37,7 +37,7 @@ /* * Init call */ -ALDeviceList::ALDeviceList( const OPENALFNTABLE& oalft ) +ALDeviceList::ALDeviceList( const openAlInterface &oalft ) { VECTOR_SET_ASSOCIATION( vDeviceInfo ); @@ -47,7 +47,7 @@ ALDeviceList::ALDeviceList( const OPENALFNTABLE& oalft ) const char *defaultDeviceName; const char *actualDeviceName; - dMemcpy( &ALFunction, &oalft, sizeof(OPENALFNTABLE) ); + dMemcpy( &ALFunction, &oalft, sizeof( openAlInterface ) ); // DeviceInfo vector stores, for each enumerated device, it's device name, selection status, spec version #, and extension support vDeviceInfo.clear(); diff --git a/Engine/source/sfx/openal/aldlist.h b/Engine/source/sfx/openal/aldlist.h index 20f1103616..449901d40e 100644 --- a/Engine/source/sfx/openal/aldlist.h +++ b/Engine/source/sfx/openal/aldlist.h @@ -43,13 +43,13 @@ typedef struct class ALDeviceList { private: - OPENALFNTABLE ALFunction; + openAlInterface ALFunction; Vector vDeviceInfo; S32 defaultDeviceIndex; S32 filterIndex; public: - ALDeviceList ( const OPENALFNTABLE &oalft ); + ALDeviceList ( const openAlInterface &oalft ); ~ALDeviceList (); S32 GetNumDevices(); const char *GetDeviceName(S32 index); diff --git a/Engine/source/sfx/openal/sfxALBuffer.cpp b/Engine/source/sfx/openal/sfxALBuffer.cpp index c276e2a3df..b1fd1ffb1c 100644 --- a/Engine/source/sfx/openal/sfxALBuffer.cpp +++ b/Engine/source/sfx/openal/sfxALBuffer.cpp @@ -30,7 +30,7 @@ //#define DEBUG_SPEW -SFXALBuffer* SFXALBuffer::create( const OPENALFNTABLE &oalft, +SFXALBuffer* SFXALBuffer::create( const openAlInterface &oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ) @@ -49,7 +49,7 @@ SFXALBuffer* SFXALBuffer::create( const OPENALFNTABLE &oalft, return buffer; } -SFXALBuffer::SFXALBuffer( const OPENALFNTABLE &oalft, +SFXALBuffer::SFXALBuffer( const openAlInterface &oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ) diff --git a/Engine/source/sfx/openal/sfxALBuffer.h b/Engine/source/sfx/openal/sfxALBuffer.h index 26864a3d06..e3ec180205 100644 --- a/Engine/source/sfx/openal/sfxALBuffer.h +++ b/Engine/source/sfx/openal/sfxALBuffer.h @@ -55,7 +55,7 @@ class SFXALBuffer : public SFXBuffer Vector< ALuint > mFreeBuffers; /// - SFXALBuffer( const OPENALFNTABLE &oalft, + SFXALBuffer( const openAlInterface &oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ); @@ -66,7 +66,7 @@ class SFXALBuffer : public SFXBuffer /// bool mUseHardware; - const OPENALFNTABLE &mOpenAL; + const openAlInterface &mOpenAL; /// ALenum _getALFormat() const @@ -108,7 +108,7 @@ class SFXALBuffer : public SFXBuffer public: - static SFXALBuffer* create( const OPENALFNTABLE &oalft, + static SFXALBuffer* create( const openAlInterface &oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ); diff --git a/Engine/source/sfx/openal/sfxALDevice.cpp b/Engine/source/sfx/openal/sfxALDevice.cpp index 765cb01fff..1f883e7816 100644 --- a/Engine/source/sfx/openal/sfxALDevice.cpp +++ b/Engine/source/sfx/openal/sfxALDevice.cpp @@ -106,7 +106,7 @@ S32 SFXALDevice::getMaxSourcesOld() //----------------------------------------------------------------------------- SFXALDevice::SFXALDevice( SFXProvider *provider, - const OPENALFNTABLE &openal, + const openAlInterface &openal, String name, bool useHardware, S32 maxBuffers ) @@ -190,14 +190,15 @@ SFXALDevice::~SFXALDevice() { _releaseAllResources(); ///cleanup our effects -#if defined(AL_ALEXT_PROTOTYPES) - mOpenAL.alDeleteAuxiliaryEffectSlots(4, effectSlot); - mOpenAL.alDeleteEffects(2, effect); -#endif +//#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 ); + } //----------------------------------------------------------------------------- diff --git a/Engine/source/sfx/openal/sfxALDevice.h b/Engine/source/sfx/openal/sfxALDevice.h index 3d2bf5e78e..d478552da3 100644 --- a/Engine/source/sfx/openal/sfxALDevice.h +++ b/Engine/source/sfx/openal/sfxALDevice.h @@ -41,7 +41,7 @@ class SFXProvider; # include "sfx/openal/sfxALVoice.h" #endif -#ifndef _OPENALFNTABLE +#ifndef _openAlInterface # include "sfx/openal/LoadOAL.h" #endif @@ -62,7 +62,7 @@ class SFXALDevice : public SFXDevice S32 getMaxSourcesOld(); SFXALDevice( SFXProvider *provider, - const OPENALFNTABLE &openal, + const openAlInterface& openal, String name, bool useHardware, S32 maxBuffers ); @@ -71,7 +71,7 @@ class SFXALDevice : public SFXDevice protected: - OPENALFNTABLE mOpenAL; + openAlInterface mOpenAL; ALCcontext *mContext; diff --git a/Engine/source/sfx/openal/sfxALProvider.cpp b/Engine/source/sfx/openal/sfxALProvider.cpp index b3a62c4bac..acde17408a 100644 --- a/Engine/source/sfx/openal/sfxALProvider.cpp +++ b/Engine/source/sfx/openal/sfxALProvider.cpp @@ -40,7 +40,7 @@ class SFXALProvider : public SFXProvider virtual ~SFXALProvider(); protected: - OPENALFNTABLE mOpenAL; + openAlInterface mOpenAL; ALDeviceList *mALDL; struct ALDeviceInfo : SFXDeviceInfo @@ -76,7 +76,7 @@ MODULE_END; void SFXALProvider::init() { - if( LoadOAL10Library( NULL, &mOpenAL ) != AL_TRUE ) + if( LoadOAL10Library( NULL, mOpenAL ) != AL_TRUE ) { Con::printf( "SFXALProvider - OpenAL not available." ); return; @@ -108,10 +108,8 @@ void SFXALProvider::init() SFXALProvider::~SFXALProvider() { - UnloadOAL10Library(); - if (mALDL) - delete mALDL; + delete mALDL; } SFXDevice* SFXALProvider::createDevice(const String& deviceName, bool useHardware, S32 maxBuffers) diff --git a/Engine/source/sfx/openal/sfxALVoice.cpp b/Engine/source/sfx/openal/sfxALVoice.cpp index 12267d3c0e..9546065c23 100644 --- a/Engine/source/sfx/openal/sfxALVoice.cpp +++ b/Engine/source/sfx/openal/sfxALVoice.cpp @@ -64,7 +64,7 @@ SFXALVoice* SFXALVoice::create( SFXALDevice* device, SFXALBuffer *buffer ) return voice; } -SFXALVoice::SFXALVoice( const OPENALFNTABLE &oalft, +SFXALVoice::SFXALVoice( const openAlInterface &oalft, SFXALBuffer *buffer, ALuint sourceName ) diff --git a/Engine/source/sfx/openal/sfxALVoice.h b/Engine/source/sfx/openal/sfxALVoice.h index 2f3dd8eca6..605d465ed2 100644 --- a/Engine/source/sfx/openal/sfxALVoice.h +++ b/Engine/source/sfx/openal/sfxALVoice.h @@ -26,7 +26,7 @@ #ifndef _SFXVOICE_H_ #include "sfx/sfxVoice.h" #endif -#ifndef _OPENALFNTABLE +#ifndef _openAlInterface #include "sfx/openal/LoadOAL.h" #endif #ifndef _PLATFORM_THREADS_MUTEX_H_ @@ -47,7 +47,7 @@ class SFXALVoice : public SFXVoice protected: - SFXALVoice( const OPENALFNTABLE &oalft, + SFXALVoice( const openAlInterface &oalft, SFXALBuffer *buffer, ALuint sourceName ); @@ -65,7 +65,7 @@ class SFXALVoice : public SFXVoice Mutex mMutex; - const OPENALFNTABLE &mOpenAL; + const openAlInterface &mOpenAL; /// SFXALBuffer* _getBuffer() const diff --git a/Engine/source/sfx/openal/win32/LoadOAL.cpp b/Engine/source/sfx/openal/win32/LoadOAL.cpp index 4c1888a695..15f1b8b073 100644 --- a/Engine/source/sfx/openal/win32/LoadOAL.cpp +++ b/Engine/source/sfx/openal/win32/LoadOAL.cpp @@ -24,578 +24,157 @@ #include #include "sfx/openal/LoadOAL.h" +#include "console/console.h" -HINSTANCE g_hOpenALDLL = NULL; -ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable) +ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable) { - if (!lpOALFnTable) - return AL_FALSE; - if (szOALFullPathName) - g_hOpenALDLL = LoadLibraryA(szOALFullPathName); + lpOALFnTable.openaAlDll = LoadLibraryA(szOALFullPathName); else { #ifdef TORQUE_DEBUG - g_hOpenALDLL = LoadLibraryA("openal32d.dll"); + lpOALFnTable.openaAlDll = LoadLibraryA("openal32d.dll"); #else - g_hOpenALDLL = LoadLibraryA("openal32.dll"); + lpOALFnTable.openaAlDll = LoadLibraryA("openal32.dll"); #endif } - if (!g_hOpenALDLL) + if (!lpOALFnTable.openaAlDll) return AL_FALSE; - memset(lpOALFnTable, 0, sizeof(OPENALFNTABLE)); + bool loadok = true; - // 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"); - } + LOAD_REQUIRED(lpOALFnTable, alcCreateContext); + LOAD_REQUIRED(lpOALFnTable, alcMakeContextCurrent); + LOAD_REQUIRED(lpOALFnTable, alcProcessContext); + LOAD_REQUIRED(lpOALFnTable, alcSuspendContext); + LOAD_REQUIRED(lpOALFnTable, alcDestroyContext); + LOAD_REQUIRED(lpOALFnTable, alcGetCurrentContext); + LOAD_REQUIRED(lpOALFnTable, alcGetContextsDevice); + LOAD_REQUIRED(lpOALFnTable, alcOpenDevice); + LOAD_REQUIRED(lpOALFnTable, alcCloseDevice); + LOAD_REQUIRED(lpOALFnTable, alcGetError); + LOAD_REQUIRED(lpOALFnTable, alcIsExtensionPresent); + LOAD_REQUIRED(lpOALFnTable, alcGetProcAddress); + LOAD_REQUIRED(lpOALFnTable, alcGetEnumValue); + LOAD_REQUIRED(lpOALFnTable, alcGetString); + LOAD_REQUIRED(lpOALFnTable, alcGetIntegerv); + LOAD_REQUIRED(lpOALFnTable, alcCaptureOpenDevice); + LOAD_REQUIRED(lpOALFnTable, alcCaptureCloseDevice); + LOAD_REQUIRED(lpOALFnTable, alcCaptureStart); + LOAD_REQUIRED(lpOALFnTable, alcCaptureStop); + LOAD_REQUIRED(lpOALFnTable, alcCaptureSamples); - 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"); + LOAD_REQUIRED(lpOALFnTable, alEnable); + LOAD_REQUIRED(lpOALFnTable, alDisable); + LOAD_REQUIRED(lpOALFnTable, alIsEnabled); + LOAD_REQUIRED(lpOALFnTable, alGetString); + LOAD_REQUIRED(lpOALFnTable, alGetBooleanv); + LOAD_REQUIRED(lpOALFnTable, alGetIntegerv); + LOAD_REQUIRED(lpOALFnTable, alGetFloatv); + LOAD_REQUIRED(lpOALFnTable, alGetDoublev); + LOAD_REQUIRED(lpOALFnTable, alGetBoolean); + LOAD_REQUIRED(lpOALFnTable, alGetInteger); + LOAD_REQUIRED(lpOALFnTable, alGetFloat); + LOAD_REQUIRED(lpOALFnTable, alGetDouble); + LOAD_REQUIRED(lpOALFnTable, alGetError); + LOAD_REQUIRED(lpOALFnTable, alIsExtensionPresent); + LOAD_REQUIRED(lpOALFnTable, alGetProcAddress); + LOAD_REQUIRED(lpOALFnTable, alGetEnumValue); + LOAD_REQUIRED(lpOALFnTable, alListenerf); + LOAD_REQUIRED(lpOALFnTable, alListener3f); + LOAD_REQUIRED(lpOALFnTable, alListenerfv); + LOAD_REQUIRED(lpOALFnTable, alListeneri); + LOAD_REQUIRED(lpOALFnTable, alListener3i); + LOAD_REQUIRED(lpOALFnTable, alListeneriv); + LOAD_REQUIRED(lpOALFnTable, alGetListenerf); + LOAD_REQUIRED(lpOALFnTable, alGetListener3f); + LOAD_REQUIRED(lpOALFnTable, alGetListenerfv); + LOAD_REQUIRED(lpOALFnTable, alGetListeneri); + LOAD_REQUIRED(lpOALFnTable, alGetListener3i); + LOAD_REQUIRED(lpOALFnTable, alGetListeneriv); + LOAD_REQUIRED(lpOALFnTable, alGenSources); + LOAD_REQUIRED(lpOALFnTable, alDeleteSources); + LOAD_REQUIRED(lpOALFnTable, alIsSource); + LOAD_REQUIRED(lpOALFnTable, alSourcef); + LOAD_REQUIRED(lpOALFnTable, alSource3f); + LOAD_REQUIRED(lpOALFnTable, alSourcefv); + LOAD_REQUIRED(lpOALFnTable, alSourcei); + LOAD_REQUIRED(lpOALFnTable, alSource3i); + LOAD_REQUIRED(lpOALFnTable, alSourceiv); + LOAD_REQUIRED(lpOALFnTable, alGetSourcef); + LOAD_REQUIRED(lpOALFnTable, alGetSource3f); + LOAD_REQUIRED(lpOALFnTable, alGetSourcefv); + LOAD_REQUIRED(lpOALFnTable, alGetSourcei); + LOAD_REQUIRED(lpOALFnTable, alGetSource3i); + LOAD_REQUIRED(lpOALFnTable, alGetSourceiv); + LOAD_REQUIRED(lpOALFnTable, alSourcePlayv); + LOAD_REQUIRED(lpOALFnTable, alSourceStopv); + LOAD_REQUIRED(lpOALFnTable, alSourceRewindv); + LOAD_REQUIRED(lpOALFnTable, alSourcePausev); + LOAD_REQUIRED(lpOALFnTable, alSourcePlay); + LOAD_REQUIRED(lpOALFnTable, alSourceStop); + LOAD_REQUIRED(lpOALFnTable, alSourceRewind); + LOAD_REQUIRED(lpOALFnTable, alSourcePause); + LOAD_REQUIRED(lpOALFnTable, alSourceQueueBuffers); + LOAD_REQUIRED(lpOALFnTable, alSourceUnqueueBuffers); + LOAD_REQUIRED(lpOALFnTable, alGenBuffers); + LOAD_REQUIRED(lpOALFnTable, alDeleteBuffers); + LOAD_REQUIRED(lpOALFnTable, alIsBuffer); + LOAD_REQUIRED(lpOALFnTable, alBufferData); + LOAD_REQUIRED(lpOALFnTable, alDopplerFactor); + LOAD_REQUIRED(lpOALFnTable, alDopplerVelocity); + LOAD_REQUIRED(lpOALFnTable, alSpeedOfSound); + LOAD_REQUIRED(lpOALFnTable, alDistanceModel); - lpOALFnTable->alGenFilters = (LPALGENFILTERS)GetProcAddress(g_hOpenALDLL, "alGenFilters"); - if (lpOALFnTable->alGenFilters == NULL) - { - OutputDebugStringA("Failed to retrieve 'alGenFilters' function address\n"); - return AL_FALSE; + if (loadok) + { + ALCint maj, min; + lpOALFnTable.alcGetIntegerv(nullptr, ALC_MAJOR_VERSION, 1, &maj); + lpOALFnTable.alcGetIntegerv(nullptr, ALC_MINOR_VERSION, 1, &min); + if (lpOALFnTable.alcGetError(nullptr) == ALC_NO_ERROR) + { + lpOALFnTable.ALCVer = MakeALCVer(maj, min); + } + else + { + Con::warnf("Failed to query ALC version assuming 1.0"); + lpOALFnTable.ALCVer = MakeALCVer(1, 0); + } } - - lpOALFnTable->alDeleteFilters = (LPALDELETEFILTERS)GetProcAddress(g_hOpenALDLL, "alDeleteFilters"); - if (lpOALFnTable->alGenFilters == NULL) + else { - OutputDebugStringA("Failed to retrieve 'alDeleteFilters' function address\n"); return AL_FALSE; } - lpOALFnTable->alFilteri = (LPALFILTERI)GetProcAddress(g_hOpenALDLL, "alFilteri"); - if (lpOALFnTable->alGenFilters == NULL) + // these are optional. + LOAD_REQUIRED(lpOALFnTable, alBufferf); + LOAD_REQUIRED(lpOALFnTable, alBuffer3f); + LOAD_REQUIRED(lpOALFnTable, alBufferfv); + LOAD_REQUIRED(lpOALFnTable, alBufferi); + LOAD_REQUIRED(lpOALFnTable, alBuffer3i); + LOAD_REQUIRED(lpOALFnTable, alBufferiv); + LOAD_REQUIRED(lpOALFnTable, alGetBufferf); + LOAD_REQUIRED(lpOALFnTable, alGetBuffer3f); + LOAD_REQUIRED(lpOALFnTable, alGetBufferfv); + LOAD_REQUIRED(lpOALFnTable, alGetBufferi); + LOAD_REQUIRED(lpOALFnTable, alGetBuffer3i); + LOAD_REQUIRED(lpOALFnTable, alGetBufferiv); + + if (loadok) { - OutputDebugStringA("Failed to retrieve 'alFilteri' function address\n"); - return AL_FALSE; + if (lpOALFnTable.alcIsExtensionPresent(nullptr, "ALC_EXT_thread_local_context")) + { + LOAD_REQUIRED(lpOALFnTable, alcSetThreadContext); + LOAD_REQUIRED(lpOALFnTable, alcGetThreadContext); + } } - - lpOALFnTable->alcGetStringiSOFT = (LPALCGETSTRINGISOFT)GetProcAddress(g_hOpenALDLL, "alcGetStringiSOFT"); - if (lpOALFnTable->alcGetStringiSOFT == NULL) + + if (!loadok) { - 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; - } -} diff --git a/Engine/source/sfx/sfxSystem.cpp b/Engine/source/sfx/sfxSystem.cpp index 37133de0db..0903536cfc 100644 --- a/Engine/source/sfx/sfxSystem.cpp +++ b/Engine/source/sfx/sfxSystem.cpp @@ -454,8 +454,8 @@ bool SFXSystem::createDevice( const String& providerName, const String& deviceNa mDevice->setRolloffFactor( mRolloffFactor ); //OpenAL requires slots for effects, this creates an empty function //that will run when a sfxdevice is created. - mDevice->openSlots(); - mDevice->setReverb( mReverb ); + //mDevice->openSlots(); + //mDevice->setReverb( mReverb ); // Signal system. From 12498cc1fad5108d36f5ced5db7c5d5025edc497 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Thu, 30 Jan 2025 18:04:33 +0000 Subject: [PATCH 06/19] remove internal name remove internal name property was just causing issues use actual device name loadOal is now cross platform, no longer a separate implementation for linux/mac etc --- Engine/source/CMakeLists.txt | 7 - .../source/sfx/openal/{win32 => }/LoadOAL.cpp | 88 ++- Engine/source/sfx/openal/LoadOAL.h | 2 + Engine/source/sfx/openal/aldlist.h | 1 - .../source/sfx/openal/linux/LoadOAL.linux.cpp | 616 ----------------- Engine/source/sfx/openal/mac/LoadOAL.mac.cpp | 618 ------------------ Engine/source/sfx/openal/sfxALProvider.cpp | 3 +- 7 files changed, 91 insertions(+), 1244 deletions(-) rename Engine/source/sfx/openal/{win32 => }/LoadOAL.cpp (78%) delete mode 100644 Engine/source/sfx/openal/linux/LoadOAL.linux.cpp delete mode 100644 Engine/source/sfx/openal/mac/LoadOAL.mac.cpp diff --git a/Engine/source/CMakeLists.txt b/Engine/source/CMakeLists.txt index fed34b8f5f..37b31addbf 100644 --- a/Engine/source/CMakeLists.txt +++ b/Engine/source/CMakeLists.txt @@ -75,13 +75,6 @@ if(TORQUE_SFX_OPENAL AND NOT TORQUE_DEDICATED) addDef( "AL_ALEXT_PROTOTYPES" ) endif() torqueAddSourceDirectories("sfx/openal") - if(WIN32) - torqueAddSourceDirectories("sfx/openal/win32") - elseif(UNIX AND NOT APPLE) - torqueAddSourceDirectories("sfx/openal/linux") - elseif(APPLE) - torqueAddSourceDirectories("sfx/openal/mac") - endif() endif() # Handle GFX torqueAddSourceDirectories("gfx" "gfx/Null" "gfx/test" "gfx/bitmap" "gfx/bitmap/loaders" "gfx/bitmap/loaders/ies" diff --git a/Engine/source/sfx/openal/win32/LoadOAL.cpp b/Engine/source/sfx/openal/LoadOAL.cpp similarity index 78% rename from Engine/source/sfx/openal/win32/LoadOAL.cpp rename to Engine/source/sfx/openal/LoadOAL.cpp index 15f1b8b073..c339625a05 100644 --- a/Engine/source/sfx/openal/win32/LoadOAL.cpp +++ b/Engine/source/sfx/openal/LoadOAL.cpp @@ -22,10 +22,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "sfx/openal/LoadOAL.h" #include "console/console.h" +#if defined(TORQUE_OS_WIN) +#include +#else +#include +#include +#endif ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable) { @@ -178,3 +183,84 @@ ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTabl return AL_TRUE; } +void LoadDriverList() +{ + Vector driverPaths; + + /// make sure our built dll is top of the list. +#if defined(TORQUE_OS_WIN) + +#ifdef TORQUE_DEBUG + driverPaths.push_back("openal32d.dll"); +#else + driverPaths.push_back("openal32.dll"); +#endif + + char sys_path[MAX_PATH]; + if (GetSystemDirectoryA(sys_path, MAX_PATH)) + { + String searchPath = String::ToString(sys_path) + "\\*oal.dll"; + + WIN32_FIND_DATAA fdata; + HANDLE srchHdl = FindFirstFileA(searchPath.c_str(), &fdata); + if (srchHdl == INVALID_HANDLE_VALUE) return; + + do { + String fullPath = String::ToString(sys_path) + "\\" + fdata.cFileName; + driverPaths.push_back(fullPath); + } while (FindNextFileA(srchHdl, &fdata)); + + FindClose(srchHdl); + } + +#else // Linux & macOS + const char* sys_path = "/usr/lib/"; + +#ifdef __linux__ + +#ifdef TORQUE_DEBUG + driverPaths.push_back("libopenald.so.1"); + driverPaths.push_back("libopenald.so"); +#else + driverPaths.push_back("libopenal.so.1"); + driverPaths.push_back("libopenal.so"); +#endif + + const char* pattern = "*oal.so" + +#elif __APPLE__ + +#ifdef TORQUE_DEBUG + driverPaths.push_back("@rpath/libopenald.1.dylib"); + driverPaths.push_back("@rpath/libopenald.1.23.1.dylib"); +#else + driverPaths.push_back("@rpath/libopenal.1.dylib"); + driverPaths.push_back("@rpath/libopenal.1.23.1.dylib"); +#endif + + const char* pattern = "*oal.dylib" + +#endif + + char search[1024]; + dSprintf(search, sizeof(search), "%s", sys_path, pattern); + + DIR* dir = opendir(search); + if (!dir) return; + + struct dirent* fEntry; + while ((fEntry = readdir(dir)) != nullptr) + { + if ((fStat.st_mode & S_IFMT) == S_IFDIR) + continue; + + char filename[BUFSIZ + 1]; + dSprintf(filename, sizeof(filename), "%s/%s", search, fEntry->d_name); // "construct" the file name + String fullPath = String::ToString(filename); + driverPaths.push_back(fullPath); + } + + closedir(dir); +#endif +} + diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index 9074e7cbf7..19ccaf8120 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -253,4 +253,6 @@ struct openAlInterface ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable); +void LoadDriverList(); + #endif // _LOADOAL_H_ diff --git a/Engine/source/sfx/openal/aldlist.h b/Engine/source/sfx/openal/aldlist.h index 449901d40e..fdb1d2939a 100644 --- a/Engine/source/sfx/openal/aldlist.h +++ b/Engine/source/sfx/openal/aldlist.h @@ -32,7 +32,6 @@ typedef struct { char strDeviceName[256]; - char strInternalDeviceName[256]; S32 iMajorVersion; S32 iMinorVersion; U32 uiSourceCount; diff --git a/Engine/source/sfx/openal/linux/LoadOAL.linux.cpp b/Engine/source/sfx/openal/linux/LoadOAL.linux.cpp deleted file mode 100644 index 0ac1a59b3e..0000000000 --- a/Engine/source/sfx/openal/linux/LoadOAL.linux.cpp +++ /dev/null @@ -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 -#include -#include -#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); -} diff --git a/Engine/source/sfx/openal/mac/LoadOAL.mac.cpp b/Engine/source/sfx/openal/mac/LoadOAL.mac.cpp deleted file mode 100644 index baf40d33be..0000000000 --- a/Engine/source/sfx/openal/mac/LoadOAL.mac.cpp +++ /dev/null @@ -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 -#include -#include -#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); -} diff --git a/Engine/source/sfx/openal/sfxALProvider.cpp b/Engine/source/sfx/openal/sfxALProvider.cpp index acde17408a..d470494eac 100644 --- a/Engine/source/sfx/openal/sfxALProvider.cpp +++ b/Engine/source/sfx/openal/sfxALProvider.cpp @@ -76,6 +76,8 @@ MODULE_END; void SFXALProvider::init() { + LoadDriverList(); + if( LoadOAL10Library( NULL, mOpenAL ) != AL_TRUE ) { Con::printf( "SFXALProvider - OpenAL not available." ); @@ -97,7 +99,6 @@ void SFXALProvider::init() { ALDeviceInfo* info = new ALDeviceInfo; - //info->internalName = String( mALDL->GetInternalDeviceName( i ) ); info->name = String( mALDL->GetDeviceName( i ) ); mDeviceInfo.push_back( info ); From 48ea7bf255b1040d91a687ac5f479f0cef0edbc8 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Thu, 30 Jan 2025 20:34:05 +0000 Subject: [PATCH 07/19] more groundwork drivers now saved to a list sfxInit class start of mirroring gfx layer. --- Engine/source/sfx/SFXInit.cpp | 41 +++ Engine/source/sfx/SFXInit.h | 18 ++ Engine/source/sfx/openal/LoadOAL.cpp | 284 ++++++++++----------- Engine/source/sfx/openal/LoadOAL.h | 44 ++-- Engine/source/sfx/openal/aldlist.cpp | 205 +++++++-------- Engine/source/sfx/openal/aldlist.h | 6 +- Engine/source/sfx/openal/sfxALDevice.h | 2 +- Engine/source/sfx/openal/sfxALProvider.cpp | 12 +- Engine/source/sfx/openal/sfxALVoice.h | 4 +- 9 files changed, 334 insertions(+), 282 deletions(-) create mode 100644 Engine/source/sfx/SFXInit.cpp create mode 100644 Engine/source/sfx/SFXInit.h diff --git a/Engine/source/sfx/SFXInit.cpp b/Engine/source/sfx/SFXInit.cpp new file mode 100644 index 0000000000..9043ef1c80 --- /dev/null +++ b/Engine/source/sfx/SFXInit.cpp @@ -0,0 +1,41 @@ +//----------------------------------------------------------------------------- +// 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/SFXInit.h" + +#include "console/console.h" +#include "core/module.h" + +MODULE_BEGIN(SFXNEW) + +MODULE_INIT +{ + +} + +MODULE_SHUTDOWN +{ + +} + +MODULE_END; diff --git a/Engine/source/sfx/SFXInit.h b/Engine/source/sfx/SFXInit.h new file mode 100644 index 0000000000..a9d8891702 --- /dev/null +++ b/Engine/source/sfx/SFXInit.h @@ -0,0 +1,18 @@ +#pragma once + +#ifndef _SFXINIT_H_ +#define _SFXINIT_H_ + +#ifndef _ENGINEOBJECT_H_ +#include "console/engineObject.h" +#endif + +class SFXInit +{ + DECLARE_STATIC_CLASS(SFXInit) + +public: + +}; + +#endif // !_SFXINIT_H_ diff --git a/Engine/source/sfx/openal/LoadOAL.cpp b/Engine/source/sfx/openal/LoadOAL.cpp index c339625a05..ffbc15f288 100644 --- a/Engine/source/sfx/openal/LoadOAL.cpp +++ b/Engine/source/sfx/openal/LoadOAL.cpp @@ -32,155 +32,135 @@ #include #endif -ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable) +void AddDriver(const char* name, LIB_HANDLE dllHandle) { - if (szOALFullPathName) - lpOALFnTable.openaAlDll = LoadLibraryA(szOALFullPathName); - else - { -#ifdef TORQUE_DEBUG - lpOALFnTable.openaAlDll = LoadLibraryA("openal32d.dll"); -#else - lpOALFnTable.openaAlDll = LoadLibraryA("openal32.dll"); -#endif - } - if (!lpOALFnTable.openaAlDll) - return AL_FALSE; + openAlInterface* oal = new openAlInterface(name, dllHandle); bool loadok = true; - LOAD_REQUIRED(lpOALFnTable, alcCreateContext); - LOAD_REQUIRED(lpOALFnTable, alcMakeContextCurrent); - LOAD_REQUIRED(lpOALFnTable, alcProcessContext); - LOAD_REQUIRED(lpOALFnTable, alcSuspendContext); - LOAD_REQUIRED(lpOALFnTable, alcDestroyContext); - LOAD_REQUIRED(lpOALFnTable, alcGetCurrentContext); - LOAD_REQUIRED(lpOALFnTable, alcGetContextsDevice); - LOAD_REQUIRED(lpOALFnTable, alcOpenDevice); - LOAD_REQUIRED(lpOALFnTable, alcCloseDevice); - LOAD_REQUIRED(lpOALFnTable, alcGetError); - LOAD_REQUIRED(lpOALFnTable, alcIsExtensionPresent); - LOAD_REQUIRED(lpOALFnTable, alcGetProcAddress); - LOAD_REQUIRED(lpOALFnTable, alcGetEnumValue); - LOAD_REQUIRED(lpOALFnTable, alcGetString); - LOAD_REQUIRED(lpOALFnTable, alcGetIntegerv); - LOAD_REQUIRED(lpOALFnTable, alcCaptureOpenDevice); - LOAD_REQUIRED(lpOALFnTable, alcCaptureCloseDevice); - LOAD_REQUIRED(lpOALFnTable, alcCaptureStart); - LOAD_REQUIRED(lpOALFnTable, alcCaptureStop); - LOAD_REQUIRED(lpOALFnTable, alcCaptureSamples); - - LOAD_REQUIRED(lpOALFnTable, alEnable); - LOAD_REQUIRED(lpOALFnTable, alDisable); - LOAD_REQUIRED(lpOALFnTable, alIsEnabled); - LOAD_REQUIRED(lpOALFnTable, alGetString); - LOAD_REQUIRED(lpOALFnTable, alGetBooleanv); - LOAD_REQUIRED(lpOALFnTable, alGetIntegerv); - LOAD_REQUIRED(lpOALFnTable, alGetFloatv); - LOAD_REQUIRED(lpOALFnTable, alGetDoublev); - LOAD_REQUIRED(lpOALFnTable, alGetBoolean); - LOAD_REQUIRED(lpOALFnTable, alGetInteger); - LOAD_REQUIRED(lpOALFnTable, alGetFloat); - LOAD_REQUIRED(lpOALFnTable, alGetDouble); - LOAD_REQUIRED(lpOALFnTable, alGetError); - LOAD_REQUIRED(lpOALFnTable, alIsExtensionPresent); - LOAD_REQUIRED(lpOALFnTable, alGetProcAddress); - LOAD_REQUIRED(lpOALFnTable, alGetEnumValue); - LOAD_REQUIRED(lpOALFnTable, alListenerf); - LOAD_REQUIRED(lpOALFnTable, alListener3f); - LOAD_REQUIRED(lpOALFnTable, alListenerfv); - LOAD_REQUIRED(lpOALFnTable, alListeneri); - LOAD_REQUIRED(lpOALFnTable, alListener3i); - LOAD_REQUIRED(lpOALFnTable, alListeneriv); - LOAD_REQUIRED(lpOALFnTable, alGetListenerf); - LOAD_REQUIRED(lpOALFnTable, alGetListener3f); - LOAD_REQUIRED(lpOALFnTable, alGetListenerfv); - LOAD_REQUIRED(lpOALFnTable, alGetListeneri); - LOAD_REQUIRED(lpOALFnTable, alGetListener3i); - LOAD_REQUIRED(lpOALFnTable, alGetListeneriv); - LOAD_REQUIRED(lpOALFnTable, alGenSources); - LOAD_REQUIRED(lpOALFnTable, alDeleteSources); - LOAD_REQUIRED(lpOALFnTable, alIsSource); - LOAD_REQUIRED(lpOALFnTable, alSourcef); - LOAD_REQUIRED(lpOALFnTable, alSource3f); - LOAD_REQUIRED(lpOALFnTable, alSourcefv); - LOAD_REQUIRED(lpOALFnTable, alSourcei); - LOAD_REQUIRED(lpOALFnTable, alSource3i); - LOAD_REQUIRED(lpOALFnTable, alSourceiv); - LOAD_REQUIRED(lpOALFnTable, alGetSourcef); - LOAD_REQUIRED(lpOALFnTable, alGetSource3f); - LOAD_REQUIRED(lpOALFnTable, alGetSourcefv); - LOAD_REQUIRED(lpOALFnTable, alGetSourcei); - LOAD_REQUIRED(lpOALFnTable, alGetSource3i); - LOAD_REQUIRED(lpOALFnTable, alGetSourceiv); - LOAD_REQUIRED(lpOALFnTable, alSourcePlayv); - LOAD_REQUIRED(lpOALFnTable, alSourceStopv); - LOAD_REQUIRED(lpOALFnTable, alSourceRewindv); - LOAD_REQUIRED(lpOALFnTable, alSourcePausev); - LOAD_REQUIRED(lpOALFnTable, alSourcePlay); - LOAD_REQUIRED(lpOALFnTable, alSourceStop); - LOAD_REQUIRED(lpOALFnTable, alSourceRewind); - LOAD_REQUIRED(lpOALFnTable, alSourcePause); - LOAD_REQUIRED(lpOALFnTable, alSourceQueueBuffers); - LOAD_REQUIRED(lpOALFnTable, alSourceUnqueueBuffers); - LOAD_REQUIRED(lpOALFnTable, alGenBuffers); - LOAD_REQUIRED(lpOALFnTable, alDeleteBuffers); - LOAD_REQUIRED(lpOALFnTable, alIsBuffer); - LOAD_REQUIRED(lpOALFnTable, alBufferData); - LOAD_REQUIRED(lpOALFnTable, alDopplerFactor); - LOAD_REQUIRED(lpOALFnTable, alDopplerVelocity); - LOAD_REQUIRED(lpOALFnTable, alSpeedOfSound); - LOAD_REQUIRED(lpOALFnTable, alDistanceModel); + 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); if (loadok) { ALCint maj, min; - lpOALFnTable.alcGetIntegerv(nullptr, ALC_MAJOR_VERSION, 1, &maj); - lpOALFnTable.alcGetIntegerv(nullptr, ALC_MINOR_VERSION, 1, &min); - if (lpOALFnTable.alcGetError(nullptr) == ALC_NO_ERROR) + oal->alcGetIntegerv(nullptr, ALC_MAJOR_VERSION, 1, &maj); + oal->alcGetIntegerv(nullptr, ALC_MINOR_VERSION, 1, &min); + if (oal->alcGetError(nullptr) == ALC_NO_ERROR) { - lpOALFnTable.ALCVer = MakeALCVer(maj, min); + oal->ALCVer = MakeALCVer(maj, min); } else { Con::warnf("Failed to query ALC version assuming 1.0"); - lpOALFnTable.ALCVer = MakeALCVer(1, 0); + oal->ALCVer = MakeALCVer(1, 0); } } - else - { - return AL_FALSE; - } // these are optional. - LOAD_REQUIRED(lpOALFnTable, alBufferf); - LOAD_REQUIRED(lpOALFnTable, alBuffer3f); - LOAD_REQUIRED(lpOALFnTable, alBufferfv); - LOAD_REQUIRED(lpOALFnTable, alBufferi); - LOAD_REQUIRED(lpOALFnTable, alBuffer3i); - LOAD_REQUIRED(lpOALFnTable, alBufferiv); - LOAD_REQUIRED(lpOALFnTable, alGetBufferf); - LOAD_REQUIRED(lpOALFnTable, alGetBuffer3f); - LOAD_REQUIRED(lpOALFnTable, alGetBufferfv); - LOAD_REQUIRED(lpOALFnTable, alGetBufferi); - LOAD_REQUIRED(lpOALFnTable, alGetBuffer3i); - LOAD_REQUIRED(lpOALFnTable, alGetBufferiv); + 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); if (loadok) { - if (lpOALFnTable.alcIsExtensionPresent(nullptr, "ALC_EXT_thread_local_context")) + if (oal->alcIsExtensionPresent(nullptr, "ALC_EXT_thread_local_context")) { - LOAD_REQUIRED(lpOALFnTable, alcSetThreadContext); - LOAD_REQUIRED(lpOALFnTable, alcGetThreadContext); + LOAD_REQUIRED(oal, alcSetThreadContext); + LOAD_REQUIRED(oal, alcGetThreadContext); } - } - if (!loadok) - { - return AL_FALSE; + ALDriverList.push_back(oal); } - - return AL_TRUE; } void LoadDriverList() @@ -226,8 +206,6 @@ void LoadDriverList() driverPaths.push_back("libopenal.so"); #endif - const char* pattern = "*oal.so" - #elif __APPLE__ #ifdef TORQUE_DEBUG @@ -238,29 +216,47 @@ void LoadDriverList() driverPaths.push_back("@rpath/libopenal.1.23.1.dylib"); #endif - const char* pattern = "*oal.dylib" - #endif + + const char* searchDirs[] = { + "/usr/lib/", + "/usr/local/lib/", + "/Library/Audio/Plug-Ins/HAL/" + }; + + for (const char* sys_path : searchDirs) + { + DIR* dir = opendir(sys_path); + if (!dir) continue; + + struct dirent* entry; + while ((entry = readdir(dir)) != nullptr) + { + std::string fileName(entry->d_name); - char search[1024]; - dSprintf(search, sizeof(search), "%s", sys_path, pattern); +#ifdef __linux__ + if (fileName.find("oal.so") != std::string::npos) +#elif __APPLE__ + if (fileName.find("openal.dylib") != std::string::npos) // Fix for macOS +#endif + { + std::string fullPath = std::string(sys_path) + fileName; + driverPaths.push_back(fullPath); +} + } - DIR* dir = opendir(search); - if (!dir) return; + closedir(dir); + } +#endif - struct dirent* fEntry; - while ((fEntry = readdir(dir)) != nullptr) + for(String driver : driverPaths) { - if ((fStat.st_mode & S_IFMT) == S_IFDIR) - continue; - - char filename[BUFSIZ + 1]; - dSprintf(filename, sizeof(filename), "%s/%s", search, fEntry->d_name); // "construct" the file name - String fullPath = String::ToString(filename); - driverPaths.push_back(fullPath); + LIB_HANDLE mod = LOAD_LIBRARY(driver); + if (mod) + { + AddDriver(driver, mod); + } } - closedir(dir); -#endif } diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index 19ccaf8120..2159e568c9 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -24,30 +24,29 @@ #define _LOADOAL_H_ #ifndef _PLATFORM_H_ -# include "platform/platform.h" +#include "platform/platform.h" +#endif + +#ifndef _TVECTOR_H_ +#include "core/util/tVector.h" #endif #if defined(TORQUE_OS_MAC) #undef AL_ALEXT_PROTOTYPES # include # include -#elif defined(TORQUE_OS_LINUX) +#else # include # include # include # include # include -#else -# include -# include -# include -# include #endif #if defined(TORQUE_OS_WIN) #include #define LIB_HANDLE HINSTANCE -#define LOAD_LIBRARY(path) LoadLibraryW(path) +#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" @@ -64,13 +63,13 @@ #endif #endif -#define LOAD_REQUIRED(table, x) \ - table.x = reinterpret_cast(reinterpret_cast( \ - GET_PROC_ADDRESS(table.openaAlDll, #x))); \ - if(!table.x) \ - { \ - Con::warnf("Failed to find entry point :%s\n", #x); \ - loadok = false; \ +#define LOAD_REQUIRED(table, x) \ + table->x = reinterpret_castx)>(reinterpret_cast( \ + GET_PROC_ADDRESS(table->openaAlDll, #x))); \ + if(!table->x) \ + { \ + Con::warnf("Failed to find entry point :%s\n", #x); \ + loadok = false; \ } @@ -86,11 +85,6 @@ constexpr auto MakeALCVer(int major, int minor) noexcept -> int { #define ALCAPIENTRY #endif -// Open AL Function table definition - -#ifndef _openAlInterface -#define _openAlInterface - // AL 1.0 did not define the ALchar and ALCchar types, so define them here // if they don't exist @@ -241,6 +235,11 @@ struct openAlInterface int ALCVer{ 0 }; LIB_HANDLE openaAlDll{ nullptr }; + String name; + + openAlInterface(const String& inName, LIB_HANDLE mod) + : name(inName), openaAlDll(mod) + {} virtual ~openAlInterface() { if (openaAlDll) @@ -249,9 +248,10 @@ struct openAlInterface }; -#endif +inline Vector ALDriverList; + -ALboolean LoadOAL10Library(char *szOALFullPathName, openAlInterface& lpOALFnTable); +void AddDriver(const char *name, LIB_HANDLE dllHandle); void LoadDriverList(); diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp index 1337c3be0b..d7e36057fb 100644 --- a/Engine/source/sfx/openal/aldlist.cpp +++ b/Engine/source/sfx/openal/aldlist.cpp @@ -37,84 +37,84 @@ /* * Init call */ -ALDeviceList::ALDeviceList( const openAlInterface &oalft ) +ALDeviceList::ALDeviceList() { - VECTOR_SET_ASSOCIATION( vDeviceInfo ); - - ALDEVICEINFO ALDeviceInfo; - char *devices; - int index; - const char *defaultDeviceName; - const char *actualDeviceName; - - dMemcpy( &ALFunction, &oalft, sizeof( openAlInterface ) ); - - // 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(); + // VECTOR_SET_ASSOCIATION( vDeviceInfo ); + + //ALDEVICEINFO ALDeviceInfo; + //char *devices; + //int index; + //const char *defaultDeviceName; + //const char *actualDeviceName; + + // dMemcpy( &ALFunction, &oalft, sizeof( openAlInterface ) ); + + // // 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(); } /* @@ -275,29 +275,30 @@ int ALDeviceList::GetNextFilteredDevice() */ 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; + return 0; + //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; } diff --git a/Engine/source/sfx/openal/aldlist.h b/Engine/source/sfx/openal/aldlist.h index fdb1d2939a..6a5f74e53a 100644 --- a/Engine/source/sfx/openal/aldlist.h +++ b/Engine/source/sfx/openal/aldlist.h @@ -27,7 +27,10 @@ #include "core/util/tVector.h" #include "core/stringTable.h" #include "sfx/openal/sfxALCaps.h" + +#ifndef _LOADOAL_H_ #include "LoadOAL.h" +#endif typedef struct { @@ -42,13 +45,12 @@ typedef struct class ALDeviceList { private: - openAlInterface ALFunction; Vector vDeviceInfo; S32 defaultDeviceIndex; S32 filterIndex; public: - ALDeviceList ( const openAlInterface &oalft ); + ALDeviceList ( ); ~ALDeviceList (); S32 GetNumDevices(); const char *GetDeviceName(S32 index); diff --git a/Engine/source/sfx/openal/sfxALDevice.h b/Engine/source/sfx/openal/sfxALDevice.h index d478552da3..926e002237 100644 --- a/Engine/source/sfx/openal/sfxALDevice.h +++ b/Engine/source/sfx/openal/sfxALDevice.h @@ -41,7 +41,7 @@ class SFXProvider; # include "sfx/openal/sfxALVoice.h" #endif -#ifndef _openAlInterface +#ifndef _LOADOAL_H_ # include "sfx/openal/LoadOAL.h" #endif diff --git a/Engine/source/sfx/openal/sfxALProvider.cpp b/Engine/source/sfx/openal/sfxALProvider.cpp index d470494eac..7cb5c40fbc 100644 --- a/Engine/source/sfx/openal/sfxALProvider.cpp +++ b/Engine/source/sfx/openal/sfxALProvider.cpp @@ -36,11 +36,10 @@ class SFXALProvider : public SFXProvider public: SFXALProvider() - : SFXProvider( "OpenAL" ) { dMemset(&mOpenAL,0,sizeof(mOpenAL)); mALDL = NULL; } + : SFXProvider( "OpenAL" ) { mALDL = NULL; } virtual ~SFXALProvider(); protected: - openAlInterface mOpenAL; ALDeviceList *mALDL; struct ALDeviceInfo : SFXDeviceInfo @@ -78,12 +77,7 @@ void SFXALProvider::init() { LoadDriverList(); - if( LoadOAL10Library( NULL, mOpenAL ) != AL_TRUE ) - { - Con::printf( "SFXALProvider - OpenAL not available." ); - return; - } - mALDL = new ALDeviceList( mOpenAL ); + //mALDL = new ALDeviceList( mOpenAL ); // Did we get any devices? if ( mALDL->GetNumDevices() < 1 ) @@ -120,7 +114,7 @@ SFXDevice* SFXALProvider::createDevice(const String& deviceName, bool useHardwar // Do we find one to create? if (info) - return new SFXALDevice(this, mOpenAL, info->name, useHardware, maxBuffers); + //return new SFXALDevice(this, mOpenAL, info->name, useHardware, maxBuffers); return NULL; } diff --git a/Engine/source/sfx/openal/sfxALVoice.h b/Engine/source/sfx/openal/sfxALVoice.h index 605d465ed2..5fef80c2ee 100644 --- a/Engine/source/sfx/openal/sfxALVoice.h +++ b/Engine/source/sfx/openal/sfxALVoice.h @@ -26,7 +26,7 @@ #ifndef _SFXVOICE_H_ #include "sfx/sfxVoice.h" #endif -#ifndef _openAlInterface +#ifndef _LOADOAL_H_ #include "sfx/openal/LoadOAL.h" #endif #ifndef _PLATFORM_THREADS_MUTEX_H_ @@ -104,4 +104,4 @@ class SFXALVoice : public SFXVoice void setRolloffFactor( F32 factor ) override; }; -#endif // _SFXALVOICE_H_ \ No newline at end of file +#endif // _SFXALVOICE_H_ From 43ea8e638f4d827624c8c445a8fbf22ff7097fcb Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Thu, 30 Jan 2025 20:41:15 +0000 Subject: [PATCH 08/19] linux and mac loading fixes --- Engine/source/sfx/openal/LoadOAL.cpp | 10 +++++----- Engine/source/sfx/openal/LoadOAL.h | 6 ------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Engine/source/sfx/openal/LoadOAL.cpp b/Engine/source/sfx/openal/LoadOAL.cpp index ffbc15f288..bce0dff887 100644 --- a/Engine/source/sfx/openal/LoadOAL.cpp +++ b/Engine/source/sfx/openal/LoadOAL.cpp @@ -232,18 +232,18 @@ void LoadDriverList() struct dirent* entry; while ((entry = readdir(dir)) != nullptr) { - std::string fileName(entry->d_name); + String fileName = String::ToString(entry->d_name); #ifdef __linux__ if (fileName.find("oal.so") != std::string::npos) #elif __APPLE__ - if (fileName.find("openal.dylib") != std::string::npos) // Fix for macOS + if (fileName.find("openal.dylib") != String::NPos) // Fix for macOS #endif { - std::string fullPath = std::string(sys_path) + fileName; + String fullPath = String::ToString(sys_path) + fileName; driverPaths.push_back(fullPath); -} - } + } + } closedir(dir); } diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index 2159e568c9..26ffb61aeb 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -31,17 +31,11 @@ #include "core/util/tVector.h" #endif -#if defined(TORQUE_OS_MAC) -#undef AL_ALEXT_PROTOTYPES -# include -# include -#else # include # include # include # include # include -#endif #if defined(TORQUE_OS_WIN) #include From c054e0edcfb7d66e97b6fcd0938d47ea47aa6307 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sat, 1 Feb 2025 12:53:07 +0000 Subject: [PATCH 09/19] change everything to use a pointer to the al driver --- CMakeLists.txt | 6 + Engine/source/CMakeLists.txt | 45 ------ Engine/source/sfx/openal/LoadOAL.cpp | 21 +-- Engine/source/sfx/openal/LoadOAL.h | 23 +-- Engine/source/sfx/openal/aldlist.cpp | 174 ++++++++++----------- Engine/source/sfx/openal/sfxALBuffer.cpp | 44 +++--- Engine/source/sfx/openal/sfxALBuffer.h | 8 +- Engine/source/sfx/openal/sfxALDevice.cpp | 162 +++++++++---------- Engine/source/sfx/openal/sfxALDevice.h | 4 +- Engine/source/sfx/openal/sfxALProvider.cpp | 11 +- Engine/source/sfx/openal/sfxALVoice.cpp | 62 ++++---- Engine/source/sfx/openal/sfxALVoice.h | 4 +- 12 files changed, 268 insertions(+), 296 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edac6b4c5d..37d25759b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,11 @@ set(TORQUE_APP_GAME_DIRECTORY "${TORQUE_APP_ROOT_DIRECTORY}/game") set(TORQUE_LIB_ROOT_DIRECTORY "${CMAKE_SOURCE_DIR}/Engine/lib") set(TORQUE_LIB_TARG_DIRECTORY "${CMAKE_BINARY_DIR}/Engine/lib") set(TORQUE_SOURCE_DIRECTROY "${CMAKE_SOURCE_DIR}/Engine/source") +set(TORQUE_LIB_OUTPUT "${TORQUE_APP_DIRECTORY}") + +if(APPLE) +set(TORQUE_LIB_OUTPUT "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks") +endif(APPLE) # Ensure all possible configurations end up in the project directory set(CMAKE_INSTALL_PREFIX "${TORQUE_APP_ROOT_DIRECTORY}" CACHE STRING "" FORCE) @@ -32,6 +37,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Tools/CMake/finders") foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${TORQUE_APP_GAME_DIRECTORY}" ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${TORQUE_LIB_OUTPUT}") endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES ) # Detect CPU Information diff --git a/Engine/source/CMakeLists.txt b/Engine/source/CMakeLists.txt index 37b31addbf..83a5b89795 100644 --- a/Engine/source/CMakeLists.txt +++ b/Engine/source/CMakeLists.txt @@ -531,48 +531,3 @@ if(TORQUE_TESTING) endif(TORQUE_TESTING) append_defs() - -# Process library binaries - these are coming from modules that are providing links to external, precompiled code that should be included -# with the executable. This is done because on Windows, the .lib is separate from the .dll so we can't automatically scan for shared -# objects in our link libraries in that case. -foreach (LIBRARY_BINARY ${TORQUE_ADDITIONAL_LIBRARY_BINARIES}) - if (APPLE) - # For OSX, we want these binaries to be copied to the Frameworks directory - add_custom_command(TARGET ${TORQUE_APP_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks" - COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_BINARY} "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks/$(CONFIGURATION)") - else() - # All other platforms expect the file next to the executable - add_custom_command(TARGET ${TORQUE_APP_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_BINARY} "${TORQUE_APP_GAME_DIRECTORY}") - endif (APPLE) -endforeach() - -# Process link libraries for dynamic links - we do this on OSX/Linux to ensure the binaries end up in the correct App directory -# as in the root CMake we force everything to be in game. This is necessary because on these platforms these are considered "libraries" -# and not runtime binaries like we configure in the root CMake. We don't globally set library outputs to avoid outputting eg. a files to -# our game directory. -if (UNIX) - get_target_property(GAME_LINK_LIBRARIES ${TORQUE_APP_NAME} LINK_LIBRARIES) - foreach (GAME_LINK_LIBRARY ${GAME_LINK_LIBRARIES}) - # For eg. OSX some links are not valid targets - for example frameworks provided by OS - if (TARGET ${GAME_LINK_LIBRARY}) - get_target_property(LINK_LIBRARY_TYPE ${GAME_LINK_LIBRARY} TYPE) - # Only pay attention to shared libraries and make them output to the app resources - if ("${LINK_LIBRARY_TYPE}" STREQUAL "SHARED_LIBRARY") - if (APPLE) - set_target_properties(${GAME_LINK_LIBRARY} PROPERTIES - XCODE_ATTRIBUTE_SKIP_INSTALL YES - ) - add_custom_command(TARGET ${TORQUE_APP_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks" - COMMAND ${CMAKE_COMMAND} -E copy "$" "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks/$" - COMMAND ${CMAKE_COMMAND} -E create_symlink "$" "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks/$" - COMMAND ${CMAKE_COMMAND} -E create_symlink "$" "${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.app/Contents/Frameworks/lib$.1.dylib" - ) - else() - set_target_properties(${GAME_LINK_LIBRARY} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${TORQUE_APP_GAME_DIRECTORY}") - endif(APPLE) - endif() - endif() - endforeach() -endif (UNIX) diff --git a/Engine/source/sfx/openal/LoadOAL.cpp b/Engine/source/sfx/openal/LoadOAL.cpp index bce0dff887..ea98cef50f 100644 --- a/Engine/source/sfx/openal/LoadOAL.cpp +++ b/Engine/source/sfx/openal/LoadOAL.cpp @@ -150,7 +150,8 @@ void AddDriver(const char* name, LIB_HANDLE dllHandle) LOAD_REQUIRED(oal, alGetBufferi); LOAD_REQUIRED(oal, alGetBuffer3i); LOAD_REQUIRED(oal, alGetBufferiv); - + +#if defined(AL_ALEXT_PROTOTYPES) if (loadok) { if (oal->alcIsExtensionPresent(nullptr, "ALC_EXT_thread_local_context")) @@ -161,6 +162,12 @@ void AddDriver(const char* name, LIB_HANDLE dllHandle) ALDriverList.push_back(oal); } +#else + if (loadok) + { + ALDriverList.push_back(oal); + } +#endif } void LoadDriverList() @@ -199,21 +206,17 @@ void LoadDriverList() #ifdef __linux__ #ifdef TORQUE_DEBUG - driverPaths.push_back("libopenald.so.1"); driverPaths.push_back("libopenald.so"); #else - driverPaths.push_back("libopenal.so.1"); driverPaths.push_back("libopenal.so"); #endif #elif __APPLE__ #ifdef TORQUE_DEBUG - driverPaths.push_back("@rpath/libopenald.1.dylib"); - driverPaths.push_back("@rpath/libopenald.1.23.1.dylib"); + driverPaths.push_back("@rpath/libopenald.dylib"); #else - driverPaths.push_back("@rpath/libopenal.1.dylib"); - driverPaths.push_back("@rpath/libopenal.1.23.1.dylib"); + driverPaths.push_back("@rpath/libopenal.dylib"); #endif #endif @@ -235,9 +238,9 @@ void LoadDriverList() String fileName = String::ToString(entry->d_name); #ifdef __linux__ - if (fileName.find("oal.so") != std::string::npos) + if (fileName.endsWith("oal.so")) #elif __APPLE__ - if (fileName.find("openal.dylib") != String::NPos) // Fix for macOS + if (fileName.endsWith("openal.dylib")) // Fix for macOS #endif { String fullPath = String::ToString(sys_path) + fileName; diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index 26ffb61aeb..40c395f915 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -31,11 +31,13 @@ #include "core/util/tVector.h" #endif -# include -# include -# include -# include -# include +// Since openal is deprecated and we pack the lib into the sandbox on mac, all +// platforms now support all of these. +#include +#include +#include +#include +#include #if defined(TORQUE_OS_WIN) #include @@ -113,9 +115,6 @@ struct openAlInterface LPALCCAPTURESTOP alcCaptureStop{ nullptr }; LPALCCAPTURESAMPLES alcCaptureSamples{ nullptr }; - PFNALCSETTHREADCONTEXTPROC alcSetThreadContext{ nullptr }; - PFNALCGETTHREADCONTEXTPROC alcGetThreadContext{ nullptr }; - LPALENABLE alEnable{ nullptr }; LPALDISABLE alDisable{ nullptr }; LPALISENABLED alIsEnabled{ nullptr }; @@ -190,6 +189,10 @@ struct openAlInterface LPALSPEEDOFSOUND alSpeedOfSound{ nullptr }; LPALDISTANCEMODEL alDistanceModel{ nullptr }; +#if defined(AL_ALEXT_PROTOTYPES) + PFNALCSETTHREADCONTEXTPROC alcSetThreadContext{ nullptr }; + PFNALCGETTHREADCONTEXTPROC alcGetThreadContext{ nullptr }; + /* Functions to load after first context creation. */ LPALGENFILTERS alGenFilters{ nullptr }; LPALDELETEFILTERS alDeleteFilters{ nullptr }; @@ -226,7 +229,9 @@ struct openAlInterface LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv{ nullptr }; LPALCGETSTRINGISOFT alcGetStringiSOFT{ nullptr }; LPALCRESETDEVICESOFT alcResetDeviceSOFT{ nullptr }; - +#endif + + int ALCVer{ 0 }; LIB_HANDLE openaAlDll{ nullptr }; String name; diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp index d7e36057fb..1cd033e473 100644 --- a/Engine/source/sfx/openal/aldlist.cpp +++ b/Engine/source/sfx/openal/aldlist.cpp @@ -25,96 +25,90 @@ #include "core/strings/stringFunctions.h" #include "aldlist.h" -#if defined(TORQUE_OS_MAC) -#include -#elif defined(TORQUE_OS_LINUX) -#include -#else -#include -#endif - /* * Init call */ ALDeviceList::ALDeviceList() { - // VECTOR_SET_ASSOCIATION( vDeviceInfo ); - - //ALDEVICEINFO ALDeviceInfo; - //char *devices; - //int index; - //const char *defaultDeviceName; - //const char *actualDeviceName; - - // dMemcpy( &ALFunction, &oalft, sizeof( openAlInterface ) ); - - // // 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(); + VECTOR_SET_ASSOCIATION( vDeviceInfo ); + + ALDEVICEINFO ALDeviceInfo; + char *devices; + int index; + const char *defaultDeviceName; + const char *actualDeviceName; + + // this needs to be executed from outside of this class, for now to maintain functionality + + openAlInterface* ALFunction = ALDriverList[0]; + + // 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(); } /* @@ -280,23 +274,23 @@ unsigned int ALDeviceList::GetMaxNumSources() //U32 iSourceCount = 0; //// Clear AL Error Code - //ALFunction.alGetError(); + //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) + // 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) + //ALFunction->alDeleteSources(iSourceCount, uiSources); + //if (ALFunction->alGetError() != AL_NO_ERROR) //{ // for (U32 i = 0; i < 256; i++) // { - // ALFunction.alDeleteSources(1, &uiSources[i]); + // ALFunction->alDeleteSources(1, &uiSources[i]); // } //} diff --git a/Engine/source/sfx/openal/sfxALBuffer.cpp b/Engine/source/sfx/openal/sfxALBuffer.cpp index b1fd1ffb1c..ffaeca7f18 100644 --- a/Engine/source/sfx/openal/sfxALBuffer.cpp +++ b/Engine/source/sfx/openal/sfxALBuffer.cpp @@ -30,7 +30,7 @@ //#define DEBUG_SPEW -SFXALBuffer* SFXALBuffer::create( const openAlInterface &oalft, +SFXALBuffer* SFXALBuffer::create( openAlInterface* oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ) @@ -49,7 +49,7 @@ SFXALBuffer* SFXALBuffer::create( const openAlInterface &oalft, return buffer; } -SFXALBuffer::SFXALBuffer( const openAlInterface &oalft, +SFXALBuffer::SFXALBuffer( openAlInterface* oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ) @@ -61,7 +61,7 @@ SFXALBuffer::SFXALBuffer( const openAlInterface &oalft, // Set up device buffers. if( !isStreaming() ) - mOpenAL.alGenBuffers( 1, &mALBuffer ); + mOpenAL->alGenBuffers( 1, &mALBuffer ); } SFXALBuffer::~SFXALBuffer() @@ -70,13 +70,13 @@ SFXALBuffer::~SFXALBuffer() _getUniqueVoice()->stop(); // Release buffers. - if ( mOpenAL.alIsBuffer( mALBuffer )) - mOpenAL.alDeleteBuffers( 1, &mALBuffer ); + if ( mOpenAL->alIsBuffer( mALBuffer )) + mOpenAL->alDeleteBuffers( 1, &mALBuffer ); while( mFreeBuffers.size() ) { ALuint buffer = mFreeBuffers.last(); - mOpenAL.alDeleteBuffers( 1, &buffer ); + mOpenAL->alDeleteBuffers( 1, &buffer ); mFreeBuffers.pop_back(); } } @@ -98,7 +98,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, + mOpenAL->alBufferData( mALBuffer, alFormat, packet->data, packet->mSizeActual, getFormat().getSamplesPerSecond() ); destructSingle( packet ); @@ -112,19 +112,19 @@ void SFXALBuffer::write( SFXInternal::SFXStreamPacket* const* packets, U32 num ) ALuint source = _getUniqueVoice()->mSourceName; ALint numProcessed; - mOpenAL.alGetSourcei( source, AL_BUFFERS_PROCESSED, &numProcessed ); + mOpenAL->alGetSourcei( source, AL_BUFFERS_PROCESSED, &numProcessed ); for( U32 i = 0; i < numProcessed; ++ i ) { // Unqueue the buffer. ALuint buffer; - mOpenAL.alSourceUnqueueBuffers( source, 1, &buffer ); + mOpenAL->alSourceUnqueueBuffers( source, 1, &buffer ); // Update the sample offset on the voice. ALint size; - mOpenAL.alGetBufferi( buffer, AL_SIZE, &size ); + mOpenAL->alGetBufferi( buffer, AL_SIZE, &size ); _getUniqueVoice()->mSampleOffset += size / getFormat().getBytesPerSample(); // Push the buffer onto the freelist. @@ -147,22 +147,22 @@ void SFXALBuffer::write( SFXInternal::SFXStreamPacket* const* packets, U32 num ) mFreeBuffers.pop_back(); } else - mOpenAL.alGenBuffers( 1, &buffer ); + mOpenAL->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( mOpenAL->alIsBuffer( buffer ), "SFXALBuffer::write() - buffer invalid" ); - mOpenAL.alBufferData( buffer, alFormat, + mOpenAL->alBufferData( buffer, alFormat, packet->data, packet->mSizeActual, getFormat().getSamplesPerSecond() ); destructSingle( packet ); // Queue the buffer. - mOpenAL.alSourceQueueBuffers( source, 1, &buffer ); + mOpenAL->alSourceQueueBuffers( source, 1, &buffer ); } } @@ -183,12 +183,12 @@ void SFXALBuffer::_flush() ALuint source = _getUniqueVoice()->mSourceName; ALint numQueued; - mOpenAL.alGetSourcei( source, AL_BUFFERS_QUEUED, &numQueued ); + mOpenAL->alGetSourcei( source, AL_BUFFERS_QUEUED, &numQueued ); for( U32 i = 0; i < numQueued; ++ i ) { ALuint buffer; - mOpenAL.alSourceUnqueueBuffers( source, 1, &buffer ); + mOpenAL->alSourceUnqueueBuffers( source, 1, &buffer ); mFreeBuffers.push_back( buffer ); } @@ -203,20 +203,20 @@ void SFXALBuffer::_flush() // issues any concurrent state changes on the voice resulting in us losing state here. ALuint newSource; - mOpenAL.alGenSources( 1, &newSource ); + mOpenAL->alGenSources( 1, &newSource ); #define COPY_F( name ) \ { \ F32 val; \ - mOpenAL.alGetSourcef( source, name, &val ); \ - mOpenAL.alSourcef( source, name, val ); \ + mOpenAL->alGetSourcef( source, name, &val ); \ + mOpenAL->alSourcef( source, name, val ); \ } #define COPY_FV( name ) \ { \ VectorF val; \ - mOpenAL.alGetSourcefv( source, name, val ); \ - mOpenAL.alSourcefv( source, name, val ); \ + mOpenAL->alGetSourcefv( source, name, val ); \ + mOpenAL->alSourcefv( source, name, val ); \ } COPY_F( AL_REFERENCE_DISTANCE ); @@ -232,7 +232,7 @@ void SFXALBuffer::_flush() COPY_FV( AL_DIRECTION ); _getUniqueVoice()->mSourceName = newSource; - mOpenAL.alDeleteSources( 1, &source ); + mOpenAL->alDeleteSources( 1, &source ); #endif } diff --git a/Engine/source/sfx/openal/sfxALBuffer.h b/Engine/source/sfx/openal/sfxALBuffer.h index e3ec180205..b145cc8e78 100644 --- a/Engine/source/sfx/openal/sfxALBuffer.h +++ b/Engine/source/sfx/openal/sfxALBuffer.h @@ -55,7 +55,7 @@ class SFXALBuffer : public SFXBuffer Vector< ALuint > mFreeBuffers; /// - SFXALBuffer( const openAlInterface &oalft, + SFXALBuffer( openAlInterface* oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ); @@ -66,7 +66,7 @@ class SFXALBuffer : public SFXBuffer /// bool mUseHardware; - const openAlInterface &mOpenAL; + openAlInterface* mOpenAL; /// ALenum _getALFormat() const @@ -108,7 +108,7 @@ class SFXALBuffer : public SFXBuffer public: - static SFXALBuffer* create( const openAlInterface &oalft, + static SFXALBuffer* create( openAlInterface* oalft, const ThreadSafeRef< SFXStream >& stream, SFXDescription* description, bool useHardware ); @@ -116,4 +116,4 @@ class SFXALBuffer : public SFXBuffer virtual ~SFXALBuffer(); }; -#endif // _SFXALBUFFER_H_ \ No newline at end of file +#endif // _SFXALBUFFER_H_ diff --git a/Engine/source/sfx/openal/sfxALDevice.cpp b/Engine/source/sfx/openal/sfxALDevice.cpp index 1f883e7816..23058d4f0c 100644 --- a/Engine/source/sfx/openal/sfxALDevice.cpp +++ b/Engine/source/sfx/openal/sfxALDevice.cpp @@ -35,39 +35,39 @@ void SFXALDevice::printALInfo(ALCdevice* device) const ALCchar* devname = NULL; Con::printBlankLine(); - if (mOpenAL.alcIsExtensionPresent(device, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE) + if (mOpenAL->alcIsExtensionPresent(device, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE) { - devname = mOpenAL.alcGetString(device, ALC_ALL_DEVICES_SPECIFIER); + devname = mOpenAL->alcGetString(device, ALC_ALL_DEVICES_SPECIFIER); } else { - devname = mOpenAL.alcGetString(device, ALC_DEVICE_SPECIFIER); + devname = mOpenAL->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); + mOpenAL->alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major); + mOpenAL->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)); + Con::printf("%s", mOpenAL->alcGetString(device, ALC_EXTENSIONS)); - U32 err = mOpenAL.alcGetError(device); + U32 err = mOpenAL->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", mOpenAL->alcGetString(device, err)); } } S32 SFXALDevice::getMaxSources() { - mOpenAL.alGetError(); + mOpenAL->alGetError(); ALCint nummono; - mOpenAL.alcGetIntegerv(mDevice, ALC_MONO_SOURCES, 1, &nummono); + mOpenAL->alcGetIntegerv(mDevice, ALC_MONO_SOURCES, 1, &nummono); if(nummono == 0) nummono = getMaxSourcesOld(); @@ -81,21 +81,21 @@ S32 SFXALDevice::getMaxSourcesOld() S32 sourceCount = 0; // clear errors. - mOpenAL.alGetError(); + mOpenAL->alGetError(); for(sourceCount = 0; sourceCount < 256; sourceCount++) { - mOpenAL.alGenSources(1,&uiSource[sourceCount]); - if(mOpenAL.alGetError() != AL_NO_ERROR) + mOpenAL->alGenSources(1,&uiSource[sourceCount]); + if(mOpenAL->alGetError() != AL_NO_ERROR) break; } - mOpenAL.alDeleteSources(sourceCount, uiSource); - if(mOpenAL.alGetError() != AL_NO_ERROR) + mOpenAL->alDeleteSources(sourceCount, uiSource); + if(mOpenAL->alGetError() != AL_NO_ERROR) { for(U32 i = 0; i < 256; i++) { - mOpenAL.alDeleteSources(1,&uiSource[i]); + mOpenAL->alDeleteSources(1,&uiSource[i]); } } @@ -106,7 +106,7 @@ S32 SFXALDevice::getMaxSourcesOld() //----------------------------------------------------------------------------- SFXALDevice::SFXALDevice( SFXProvider *provider, - const openAlInterface &openal, + openAlInterface* openal, String name, bool useHardware, S32 maxBuffers ) @@ -133,25 +133,25 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, printALInfo(NULL); - mDevice = mOpenAL.alcOpenDevice( name ); - U32 err = mOpenAL.alcGetError(mDevice); + mDevice = mOpenAL->alcOpenDevice( name ); + U32 err = mOpenAL->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", mOpenAL->alcGetString(mDevice, err)); if( mDevice ) { - mContext = mOpenAL.alcCreateContext( mDevice, attribs ); + mContext = mOpenAL->alcCreateContext( mDevice, attribs ); if( mContext ) - mOpenAL.alcMakeContextCurrent( mContext ); + mOpenAL->alcMakeContextCurrent( mContext ); #if defined(AL_ALEXT_PROTOTYPES) - mOpenAL.alcGetIntegerv(mDevice, ALC_MAX_AUXILIARY_SENDS, 1, &iSends); + mOpenAL->alcGetIntegerv(mDevice, ALC_MAX_AUXILIARY_SENDS, 1, &iSends); #endif - err = mOpenAL.alcGetError( mDevice ); + 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", mOpenAL->alcGetString( mDevice, err ) ); } AssertFatal( mDevice != NULL && mContext != NULL, "Failed to create OpenAL device and/or context!" ); @@ -191,13 +191,13 @@ SFXALDevice::~SFXALDevice() _releaseAllResources(); ///cleanup our effects //#if defined(AL_ALEXT_PROTOTYPES) -// mOpenAL.alDeleteAuxiliaryEffectSlots(4, effectSlot); -// mOpenAL.alDeleteEffects(2, effect); +// mOpenAL->alDeleteAuxiliaryEffectSlots(4, effectSlot); +// mOpenAL->alDeleteEffects(2, effect); //#endif ///cleanup of effects ends - mOpenAL.alcMakeContextCurrent( NULL ); - mOpenAL.alcDestroyContext( mContext ); - mOpenAL.alcCloseDevice( mDevice ); + mOpenAL->alcMakeContextCurrent( NULL ); + mOpenAL->alcDestroyContext( mContext ); + mOpenAL->alcCloseDevice( mDevice ); } @@ -259,13 +259,13 @@ 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] ); + 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); + mOpenAL->alListenerf(AL_METERS_PER_UNIT, 1.0f); #endif } @@ -276,19 +276,19 @@ void SFXALDevice::setDistanceModel( SFXDistanceModel model ) switch( model ) { case SFXDistanceModelLinear: - mOpenAL.alDistanceModel( AL_LINEAR_DISTANCE_CLAMPED ); + mOpenAL->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 ); + mOpenAL->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); + mOpenAL->alDistanceModel(AL_EXPONENT_DISTANCE_CLAMPED); if (mUserRolloffFactor != mRolloffFactor) _setRolloffFactor(mUserRolloffFactor); break; @@ -304,7 +304,7 @@ void SFXALDevice::setDistanceModel( SFXDistanceModel model ) void SFXALDevice::setDopplerFactor( F32 factor ) { - mOpenAL.alDopplerFactor( factor ); + mOpenAL->alDopplerFactor( factor ); } //----------------------------------------------------------------------------- @@ -314,7 +314,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 ); + mOpenAL->alSourcef( ( ( SFXALVoice* ) mVoices[ i ] )->mSourceName, AL_ROLLOFF_FACTOR, factor ); } //----------------------------------------------------------------------------- @@ -334,12 +334,12 @@ void SFXALDevice::openSlots() { for (uLoop = 0; uLoop < 4; uLoop++) { - mOpenAL.alGenAuxiliaryEffectSlots(1, &effectSlot[uLoop]); + mOpenAL->alGenAuxiliaryEffectSlots(1, &effectSlot[uLoop]); } for (uLoop = 0; uLoop < 2; uLoop++) { - mOpenAL.alGenEffects(1, &effect[uLoop]); + mOpenAL->alGenEffects(1, &effect[uLoop]); } ///debug string output so we know our slots are open Platform::outputDebugString("Slots Open"); @@ -377,37 +377,37 @@ void SFXALDevice::setReverb(const SFXReverbProperties& reverb) prop.flRoomRolloffFactor = reverb.flRoomRolloffFactor; prop.iDecayHFLimit = reverb.iDecayHFLimit; - if (mOpenAL.alGetEnumValue("AL_EFFECT_EAXREVERB") != 0) + 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); + 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]); + 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"); } @@ -415,22 +415,22 @@ void SFXALDevice::setReverb(const SFXReverbProperties& reverb) { /// 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]); + 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]); } diff --git a/Engine/source/sfx/openal/sfxALDevice.h b/Engine/source/sfx/openal/sfxALDevice.h index 926e002237..1d63b13f4c 100644 --- a/Engine/source/sfx/openal/sfxALDevice.h +++ b/Engine/source/sfx/openal/sfxALDevice.h @@ -62,7 +62,7 @@ class SFXALDevice : public SFXDevice S32 getMaxSourcesOld(); SFXALDevice( SFXProvider *provider, - const openAlInterface& openal, + openAlInterface* openal, String name, bool useHardware, S32 maxBuffers ); @@ -71,7 +71,7 @@ class SFXALDevice : public SFXDevice protected: - openAlInterface mOpenAL; + openAlInterface* mOpenAL; ALCcontext *mContext; diff --git a/Engine/source/sfx/openal/sfxALProvider.cpp b/Engine/source/sfx/openal/sfxALProvider.cpp index 7cb5c40fbc..7dc0396921 100644 --- a/Engine/source/sfx/openal/sfxALProvider.cpp +++ b/Engine/source/sfx/openal/sfxALProvider.cpp @@ -78,7 +78,15 @@ void SFXALProvider::init() LoadDriverList(); //mALDL = new ALDeviceList( mOpenAL ); + + if(ALDriverList.size() < 1) + { + Con::printf("SFXALProvider - No valid openal drivers."); + return; + } + mALDL = new ALDeviceList(); + // Did we get any devices? if ( mALDL->GetNumDevices() < 1 ) { @@ -112,9 +120,10 @@ SFXDevice* SFXALProvider::createDevice(const String& deviceName, bool useHardwar ALDeviceInfo* info = dynamic_cast (_findDeviceInfo(deviceName)); + // Do we find one to create? if (info) - //return new SFXALDevice(this, mOpenAL, info->name, useHardware, maxBuffers); + return new SFXALDevice(this, ALDriverList[0], info->name, useHardware, maxBuffers); return NULL; } diff --git a/Engine/source/sfx/openal/sfxALVoice.cpp b/Engine/source/sfx/openal/sfxALVoice.cpp index 9546065c23..711c07f2f0 100644 --- a/Engine/source/sfx/openal/sfxALVoice.cpp +++ b/Engine/source/sfx/openal/sfxALVoice.cpp @@ -28,7 +28,7 @@ #ifdef TORQUE_DEBUG # define AL_SANITY_CHECK() \ - AssertFatal( mOpenAL.alIsSource( mSourceName ), "AL Source Sanity Check Failed!" ); + AssertFatal( mOpenAL->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!" ); + device->mOpenAL->alGenSources( 1, &sourceName ); + AssertFatal( device->mOpenAL->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,10 +52,10 @@ 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 ) ); + device->mOpenAL->alSourcei( sourceName, AL_SOURCE_RELATIVE, ( buffer->mIs3d ? AL_FALSE : AL_TRUE ) ); if( buffer->mIs3d ) - device->mOpenAL.alSourcef( sourceName, AL_ROLLOFF_FACTOR, device->mRolloffFactor ); + device->mOpenAL->alSourcef( sourceName, AL_ROLLOFF_FACTOR, device->mRolloffFactor ); SFXALVoice *voice = new SFXALVoice( device->mOpenAL, buffer, @@ -64,7 +64,7 @@ SFXALVoice* SFXALVoice::create( SFXALDevice* device, SFXALBuffer *buffer ) return voice; } -SFXALVoice::SFXALVoice( const openAlInterface &oalft, +SFXALVoice::SFXALVoice( openAlInterface* oalft, SFXALBuffer *buffer, ALuint sourceName ) @@ -79,7 +79,7 @@ SFXALVoice::SFXALVoice( const openAlInterface &oalft, SFXALVoice::~SFXALVoice() { - mOpenAL.alDeleteSources( 1, &mSourceName ); + mOpenAL->alDeleteSources( 1, &mSourceName ); } void SFXALVoice::_lateBindStaticBufferIfNecessary() @@ -87,9 +87,9 @@ void SFXALVoice::_lateBindStaticBufferIfNecessary() if( !mBuffer->isStreaming() ) { ALint bufferId; - mOpenAL.alGetSourcei( mSourceName, AL_BUFFER, &bufferId ); + mOpenAL->alGetSourcei( mSourceName, AL_BUFFER, &bufferId ); if( !bufferId ) - mOpenAL.alSourcei( mSourceName, AL_BUFFER, _getBuffer()->mALBuffer ); + mOpenAL->alSourcei( mSourceName, AL_BUFFER, _getBuffer()->mALBuffer ); } } @@ -99,7 +99,7 @@ SFXStatus SFXALVoice::_status() const AL_SANITY_CHECK(); ALint state; - mOpenAL.alGetSourcei( mSourceName, AL_SOURCE_STATE, &state ); + mOpenAL->alGetSourcei( mSourceName, AL_SOURCE_STATE, &state ); switch( state ) { @@ -120,16 +120,16 @@ void SFXALVoice::_play() #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); + mOpenAL->alSource3i(mSourceName, AL_AUXILIARY_SEND_FILTER, 1, 0, AL_FILTER_NULL); #endif - mOpenAL.alSourcePlay( mSourceName ); + mOpenAL->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 ); + mOpenAL->alSourcef( mSourceName, AL_SAMPLE_OFFSET, mResumeAtSampleOffset ); mResumeAtSampleOffset = -1.0f; } } @@ -142,12 +142,12 @@ void SFXALVoice::_pause() Platform::outputDebugString( "[SFXALVoice] Pausing playback" ); #endif - mOpenAL.alSourcePause( mSourceName ); + mOpenAL->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 ); + mOpenAL->alGetSourcef( mSourceName, AL_SAMPLE_OFFSET, &mResumeAtSampleOffset ); } void SFXALVoice::_stop() @@ -158,7 +158,7 @@ void SFXALVoice::_stop() Platform::outputDebugString( "[SFXALVoice] Stopping playback" ); #endif - mOpenAL.alSourceStop( mSourceName ); + mOpenAL->alSourceStop( mSourceName ); mSampleOffset = 0; mResumeAtSampleOffset = -1.0f; @@ -169,7 +169,7 @@ void SFXALVoice::_seek( U32 sample ) AL_SANITY_CHECK(); _lateBindStaticBufferIfNecessary(); - mOpenAL.alSourcei( mSourceName, AL_SAMPLE_OFFSET, sample ); + mOpenAL->alSourcei( mSourceName, AL_SAMPLE_OFFSET, sample ); mResumeAtSampleOffset = -1.0f; } @@ -183,7 +183,7 @@ U32 SFXALVoice::_tell() const mBuffer->write( NULL, 0 ); ALint pos; - mOpenAL.alGetSourcei( mSourceName, AL_SAMPLE_OFFSET, &pos ); + mOpenAL->alGetSourcei( mSourceName, AL_SAMPLE_OFFSET, &pos ); return ( pos + mSampleOffset ); } @@ -191,17 +191,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 ); + mOpenAL->alSourcef( mSourceName, AL_REFERENCE_DISTANCE, min ); + mOpenAL->alSourcef( mSourceName, AL_MAX_DISTANCE, max ); } void SFXALVoice::play( bool looping ) { AL_SANITY_CHECK(); - mOpenAL.alSourceStop( mSourceName ); + mOpenAL->alSourceStop( mSourceName ); if( !mBuffer->isStreaming() ) - mOpenAL.alSourcei( mSourceName, AL_LOOPING, ( looping ? AL_TRUE : AL_FALSE ) ); + mOpenAL->alSourcei( mSourceName, AL_LOOPING, ( looping ? AL_TRUE : AL_FALSE ) ); Parent::play( looping ); } @@ -213,7 +213,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 ); + mOpenAL->alSourcefv( mSourceName, AL_VELOCITY, velocity ); } void SFXALVoice::setTransform( const MatrixF& transform ) @@ -227,34 +227,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 ); + mOpenAL->alSourcefv( mSourceName, AL_POSITION, pos ); + mOpenAL->alSourcefv( mSourceName, AL_DIRECTION, dir ); } void SFXALVoice::setVolume( F32 volume ) { AL_SANITY_CHECK(); - mOpenAL.alSourcef( mSourceName, AL_GAIN, volume ); + mOpenAL->alSourcef( mSourceName, AL_GAIN, volume ); } void SFXALVoice::setPitch( F32 pitch ) { AL_SANITY_CHECK(); - mOpenAL.alSourcef( mSourceName, AL_PITCH, pitch ); + mOpenAL->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 ); + mOpenAL->alSourcef( mSourceName, AL_CONE_INNER_ANGLE, innerAngle ); + mOpenAL->alSourcef( mSourceName, AL_CONE_OUTER_ANGLE, outerAngle ); + mOpenAL->alSourcef( mSourceName, AL_CONE_OUTER_GAIN, outerVolume ); } void SFXALVoice::setRolloffFactor( F32 factor ) { - mOpenAL.alSourcef( mSourceName, AL_ROLLOFF_FACTOR, factor ); + mOpenAL->alSourcef( mSourceName, AL_ROLLOFF_FACTOR, factor ); } diff --git a/Engine/source/sfx/openal/sfxALVoice.h b/Engine/source/sfx/openal/sfxALVoice.h index 5fef80c2ee..18b29a545a 100644 --- a/Engine/source/sfx/openal/sfxALVoice.h +++ b/Engine/source/sfx/openal/sfxALVoice.h @@ -47,7 +47,7 @@ class SFXALVoice : public SFXVoice protected: - SFXALVoice( const openAlInterface &oalft, + SFXALVoice( openAlInterface* oalft, SFXALBuffer *buffer, ALuint sourceName ); @@ -65,7 +65,7 @@ class SFXALVoice : public SFXVoice Mutex mMutex; - const openAlInterface &mOpenAL; + openAlInterface* mOpenAL; /// SFXALBuffer* _getBuffer() const From c1d7052daff4c03ca637b38274dddb4b27757303 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sat, 1 Feb 2025 14:03:18 +0000 Subject: [PATCH 10/19] Update LoadOAL.h --- Engine/source/sfx/openal/LoadOAL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index 40c395f915..097dd595cf 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -49,7 +49,7 @@ #else #include #define LIB_HANDLE void* -#define LOAD_LIBRARY(path) dlopen(path, RTLD_NOW) +#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__ From 2d6b79817c8bf66f4d7c1c519751ca116c8d742e Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 4 Feb 2025 09:16:41 +0000 Subject: [PATCH 11/19] fix dependencies linux --- .github/workflows/build-linux-gcc.yml | 7 +++++++ Engine/source/sfx/SFXInit.h | 24 ++++++++++++++++++++++++ Engine/source/sfx/sfxDevice.h | 18 +++++++++++++----- Tools/CMake/finders/findFLAC.cmake | 13 ------------- Tools/CMake/finders/findOGG.cmake | 13 ------------- Tools/CMake/finders/findOPUS.cmake | 13 ------------- Tools/CMake/finders/findPCRE.cmake | 13 ------------- Tools/CMake/finders/findVorbis.cmake | 13 ------------- Tools/CMake/finders/findZlib.cmake | 14 -------------- 9 files changed, 44 insertions(+), 84 deletions(-) delete mode 100644 Tools/CMake/finders/findFLAC.cmake delete mode 100644 Tools/CMake/finders/findOGG.cmake delete mode 100644 Tools/CMake/finders/findOPUS.cmake delete mode 100644 Tools/CMake/finders/findPCRE.cmake delete mode 100644 Tools/CMake/finders/findVorbis.cmake delete mode 100644 Tools/CMake/finders/findZlib.cmake diff --git a/.github/workflows/build-linux-gcc.yml b/.github/workflows/build-linux-gcc.yml index 8382d27a2b..4176e066e4 100644 --- a/.github/workflows/build-linux-gcc.yml +++ b/.github/workflows/build-linux-gcc.yml @@ -61,6 +61,13 @@ jobs: libx11-dev \ libxxf86vm-dev \ libopenal-dev \ + libasound2-dev \ + libpipewire-0.3-dev \ + portaudio19-dev \ + oss4-dev \ + libjack-dev \ + libpulse-dev \ + libdbus-1-dev \ libfreetype6-dev \ libxcursor-dev \ libxinerama-dev \ diff --git a/Engine/source/sfx/SFXInit.h b/Engine/source/sfx/SFXInit.h index a9d8891702..4b6fcb3057 100644 --- a/Engine/source/sfx/SFXInit.h +++ b/Engine/source/sfx/SFXInit.h @@ -1,8 +1,32 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- #pragma once #ifndef _SFXINIT_H_ #define _SFXINIT_H_ +#ifndef _SFXDEVICE_H_ +#include "sfx/sfxDevice.h" +#endif #ifndef _ENGINEOBJECT_H_ #include "console/engineObject.h" #endif diff --git a/Engine/source/sfx/sfxDevice.h b/Engine/source/sfx/sfxDevice.h index a2389f587a..b4dc562bf2 100644 --- a/Engine/source/sfx/sfxDevice.h +++ b/Engine/source/sfx/sfxDevice.h @@ -24,18 +24,26 @@ #define _SFXDEVICE_H_ #ifndef _PLATFORM_H_ - #include "platform/platform.h" +#include "platform/platform.h" #endif #ifndef _TVECTOR_H_ - #include "core/util/tVector.h" +#include "core/util/tVector.h" #endif #ifndef _SFXCOMMON_H_ - #include "sfx/sfxCommon.h" +#include "sfx/sfxCommon.h" #endif #ifndef _THREADSAFEREF_H_ - #include "platform/threads/threadSafeRefCount.h" +#include "platform/threads/threadSafeRefCount.h" +#endif +#ifndef _TDICTIONARY_H_ +#include "core/util/tDictionary.h" +#endif +#ifndef _TSIGNAL_H_ +#include "core/util/tSignal.h" +#endif +#ifndef _PLATFORM_PLATFORMTIMER_H_ +#include "platform/platformTimer.h" #endif - class SFXProvider; class SFXListener; diff --git a/Tools/CMake/finders/findFLAC.cmake b/Tools/CMake/finders/findFLAC.cmake deleted file mode 100644 index a77e4901bf..0000000000 --- a/Tools/CMake/finders/findFLAC.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET FLAC) - set(FLAC_FOUND TRUE) - set(FLAC_INCLUDE_DIRS $) - set(FLAC_LIBRARIES FLAC) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET FLAC::FLAC) - add_library(FLAC::FLAC ALIAS FLAC) - endif() -else() - set(FLAC_FOUND FALSE) - message(FATAL_ERROR "Flac was not added with add_subdirectory before calling find_package(FLAC).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findOGG.cmake b/Tools/CMake/finders/findOGG.cmake deleted file mode 100644 index 3cdb22111c..0000000000 --- a/Tools/CMake/finders/findOGG.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET ogg) - set(OGG_FOUND TRUE) - set(OGG_INCLUDE_DIRS $) - set(OGG_LIBRARIES ogg) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET OGG::OGG) - add_library(OGG::OGG ALIAS ogg) - endif() -else() - set(OGG_FOUND FALSE) - message(FATAL_ERROR "Ogg was not added with add_subdirectory before calling find_package(Ogg).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findOPUS.cmake b/Tools/CMake/finders/findOPUS.cmake deleted file mode 100644 index 0ed268a3d3..0000000000 --- a/Tools/CMake/finders/findOPUS.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET opus) - set(OPUS_FOUND TRUE) - set(OPUS_INCLUDE_DIRS $) - set(OPUS_LIBRARIES opus) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET OPUS::OPUS) - add_library(OPUS::OPUS ALIAS opus) - endif() -else() - set(OPUS_FOUND FALSE) - message(FATAL_ERROR "Opus was not added with add_subdirectory before calling find_package(Opus).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findPCRE.cmake b/Tools/CMake/finders/findPCRE.cmake deleted file mode 100644 index 9db8c09f00..0000000000 --- a/Tools/CMake/finders/findPCRE.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET pcre) - set(PCRE_FOUND TRUE) - set(PCRE_INCLUDE_DIRS $) - set(PCRE_LIBRARIES pcre) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET PCRE::PCRE) - add_library(PCRE::PCRE ALIAS pcre) - endif() -else() - set(PCRE_FOUND FALSE) - message(FATAL_ERROR "PCRE was not added with add_subdirectory before calling find_package(PCRE).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findVorbis.cmake b/Tools/CMake/finders/findVorbis.cmake deleted file mode 100644 index 4fd196bf32..0000000000 --- a/Tools/CMake/finders/findVorbis.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET vorbis) - set(VORBIS_FOUND TRUE) - set(VORBIS_INCLUDE_DIRS $) - set(VORBIS_LIBRARIES vorbis) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET VORBIS::VORBIS) - add_library(VORBIS::VORBIS ALIAS vorbis) - endif() -else() - set(VORBIS_FOUND FALSE) - message(FATAL_ERROR "Vorbis was not added with add_subdirectory before calling find_package(Vorbis).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findZlib.cmake b/Tools/CMake/finders/findZlib.cmake deleted file mode 100644 index b3a4999e96..0000000000 --- a/Tools/CMake/finders/findZlib.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# Ensure zlib has been added before using this module -if(TARGET zlib) - set(ZLIB_FOUND TRUE) - set(ZLIB_INCLUDE_DIRS $) - set(ZLIB_LIBRARIES zlib) - message(STATUS "Using Torques build of zlib.") - # Provide an alias for consistency with modern CMake - if(NOT TARGET ZLIB::ZLIB) - add_library(ZLIB::ZLIB ALIAS zlib) - endif() -else() - set(ZLIB_FOUND FALSE) - message(FATAL_ERROR "Zlib was not added with add_subdirectory before calling find_package(ZLIB).") -endif() \ No newline at end of file From 566c61cf0c298216ca5e2c0e1913917210a3d117 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 4 Feb 2025 09:17:04 +0000 Subject: [PATCH 12/19] update finders for linux --- Tools/CMake/finders/FindFLAC.cmake | 13 +++++++++++++ Tools/CMake/finders/FindOGG.cmake | 13 +++++++++++++ Tools/CMake/finders/FindOPUS.cmake | 13 +++++++++++++ Tools/CMake/finders/FindPCRE.cmake | 13 +++++++++++++ Tools/CMake/finders/FindSDL2.cmake | 14 ++++++++++++++ Tools/CMake/finders/FindVorbis.cmake | 13 +++++++++++++ Tools/CMake/finders/FindZlib.cmake | 14 ++++++++++++++ 7 files changed, 93 insertions(+) create mode 100644 Tools/CMake/finders/FindFLAC.cmake create mode 100644 Tools/CMake/finders/FindOGG.cmake create mode 100644 Tools/CMake/finders/FindOPUS.cmake create mode 100644 Tools/CMake/finders/FindPCRE.cmake create mode 100644 Tools/CMake/finders/FindSDL2.cmake create mode 100644 Tools/CMake/finders/FindVorbis.cmake create mode 100644 Tools/CMake/finders/FindZlib.cmake diff --git a/Tools/CMake/finders/FindFLAC.cmake b/Tools/CMake/finders/FindFLAC.cmake new file mode 100644 index 0000000000..a77e4901bf --- /dev/null +++ b/Tools/CMake/finders/FindFLAC.cmake @@ -0,0 +1,13 @@ +if(TARGET FLAC) + set(FLAC_FOUND TRUE) + set(FLAC_INCLUDE_DIRS $) + set(FLAC_LIBRARIES FLAC) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET FLAC::FLAC) + add_library(FLAC::FLAC ALIAS FLAC) + endif() +else() + set(FLAC_FOUND FALSE) + message(FATAL_ERROR "Flac was not added with add_subdirectory before calling find_package(FLAC).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindOGG.cmake b/Tools/CMake/finders/FindOGG.cmake new file mode 100644 index 0000000000..3cdb22111c --- /dev/null +++ b/Tools/CMake/finders/FindOGG.cmake @@ -0,0 +1,13 @@ +if(TARGET ogg) + set(OGG_FOUND TRUE) + set(OGG_INCLUDE_DIRS $) + set(OGG_LIBRARIES ogg) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET OGG::OGG) + add_library(OGG::OGG ALIAS ogg) + endif() +else() + set(OGG_FOUND FALSE) + message(FATAL_ERROR "Ogg was not added with add_subdirectory before calling find_package(Ogg).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindOPUS.cmake b/Tools/CMake/finders/FindOPUS.cmake new file mode 100644 index 0000000000..0ed268a3d3 --- /dev/null +++ b/Tools/CMake/finders/FindOPUS.cmake @@ -0,0 +1,13 @@ +if(TARGET opus) + set(OPUS_FOUND TRUE) + set(OPUS_INCLUDE_DIRS $) + set(OPUS_LIBRARIES opus) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET OPUS::OPUS) + add_library(OPUS::OPUS ALIAS opus) + endif() +else() + set(OPUS_FOUND FALSE) + message(FATAL_ERROR "Opus was not added with add_subdirectory before calling find_package(Opus).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindPCRE.cmake b/Tools/CMake/finders/FindPCRE.cmake new file mode 100644 index 0000000000..9db8c09f00 --- /dev/null +++ b/Tools/CMake/finders/FindPCRE.cmake @@ -0,0 +1,13 @@ +if(TARGET pcre) + set(PCRE_FOUND TRUE) + set(PCRE_INCLUDE_DIRS $) + set(PCRE_LIBRARIES pcre) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET PCRE::PCRE) + add_library(PCRE::PCRE ALIAS pcre) + endif() +else() + set(PCRE_FOUND FALSE) + message(FATAL_ERROR "PCRE was not added with add_subdirectory before calling find_package(PCRE).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindSDL2.cmake b/Tools/CMake/finders/FindSDL2.cmake new file mode 100644 index 0000000000..4070534a30 --- /dev/null +++ b/Tools/CMake/finders/FindSDL2.cmake @@ -0,0 +1,14 @@ +# Ensure SDL2 has been added before using this module +if(TARGET SDL2) + set(SDL2_FOUND TRUE) + set(SDL2_INCLUDE_DIRS $) + set(SDL2_LIBRARIES SDL2) + message(STATUS "Using Torques build of SDL2.") + # Provide an alias for consistency with modern CMake + if(NOT TARGET SDL2::SDL2) + add_library(SDL2::SDL2 ALIAS SDL2) + endif() +else() + set(SDL2_FOUND FALSE) + message(FATAL_ERROR "SDL2 was not added with add_subdirectory before calling find_package(SDL2).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindVorbis.cmake b/Tools/CMake/finders/FindVorbis.cmake new file mode 100644 index 0000000000..4fd196bf32 --- /dev/null +++ b/Tools/CMake/finders/FindVorbis.cmake @@ -0,0 +1,13 @@ +if(TARGET vorbis) + set(VORBIS_FOUND TRUE) + set(VORBIS_INCLUDE_DIRS $) + set(VORBIS_LIBRARIES vorbis) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET VORBIS::VORBIS) + add_library(VORBIS::VORBIS ALIAS vorbis) + endif() +else() + set(VORBIS_FOUND FALSE) + message(FATAL_ERROR "Vorbis was not added with add_subdirectory before calling find_package(Vorbis).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindZlib.cmake b/Tools/CMake/finders/FindZlib.cmake new file mode 100644 index 0000000000..b3a4999e96 --- /dev/null +++ b/Tools/CMake/finders/FindZlib.cmake @@ -0,0 +1,14 @@ +# Ensure zlib has been added before using this module +if(TARGET zlib) + set(ZLIB_FOUND TRUE) + set(ZLIB_INCLUDE_DIRS $) + set(ZLIB_LIBRARIES zlib) + message(STATUS "Using Torques build of zlib.") + # Provide an alias for consistency with modern CMake + if(NOT TARGET ZLIB::ZLIB) + add_library(ZLIB::ZLIB ALIAS zlib) + endif() +else() + set(ZLIB_FOUND FALSE) + message(FATAL_ERROR "Zlib was not added with add_subdirectory before calling find_package(ZLIB).") +endif() \ No newline at end of file From 593754ec6fa5fbfcc076ec074f8946c124cabc76 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 4 Feb 2025 09:23:00 +0000 Subject: [PATCH 13/19] Revert "fix dependencies linux" This reverts commit 2d6b79817c8bf66f4d7c1c519751ca116c8d742e. --- .github/workflows/build-linux-gcc.yml | 7 ------- Engine/source/sfx/SFXInit.h | 24 ------------------------ Engine/source/sfx/sfxDevice.h | 18 +++++------------- Tools/CMake/finders/findFLAC.cmake | 13 +++++++++++++ Tools/CMake/finders/findOGG.cmake | 13 +++++++++++++ Tools/CMake/finders/findOPUS.cmake | 13 +++++++++++++ Tools/CMake/finders/findPCRE.cmake | 13 +++++++++++++ Tools/CMake/finders/findVorbis.cmake | 13 +++++++++++++ Tools/CMake/finders/findZlib.cmake | 14 ++++++++++++++ 9 files changed, 84 insertions(+), 44 deletions(-) create mode 100644 Tools/CMake/finders/findFLAC.cmake create mode 100644 Tools/CMake/finders/findOGG.cmake create mode 100644 Tools/CMake/finders/findOPUS.cmake create mode 100644 Tools/CMake/finders/findPCRE.cmake create mode 100644 Tools/CMake/finders/findVorbis.cmake create mode 100644 Tools/CMake/finders/findZlib.cmake diff --git a/.github/workflows/build-linux-gcc.yml b/.github/workflows/build-linux-gcc.yml index 4176e066e4..8382d27a2b 100644 --- a/.github/workflows/build-linux-gcc.yml +++ b/.github/workflows/build-linux-gcc.yml @@ -61,13 +61,6 @@ jobs: libx11-dev \ libxxf86vm-dev \ libopenal-dev \ - libasound2-dev \ - libpipewire-0.3-dev \ - portaudio19-dev \ - oss4-dev \ - libjack-dev \ - libpulse-dev \ - libdbus-1-dev \ libfreetype6-dev \ libxcursor-dev \ libxinerama-dev \ diff --git a/Engine/source/sfx/SFXInit.h b/Engine/source/sfx/SFXInit.h index 4b6fcb3057..a9d8891702 100644 --- a/Engine/source/sfx/SFXInit.h +++ b/Engine/source/sfx/SFXInit.h @@ -1,32 +1,8 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- #pragma once #ifndef _SFXINIT_H_ #define _SFXINIT_H_ -#ifndef _SFXDEVICE_H_ -#include "sfx/sfxDevice.h" -#endif #ifndef _ENGINEOBJECT_H_ #include "console/engineObject.h" #endif diff --git a/Engine/source/sfx/sfxDevice.h b/Engine/source/sfx/sfxDevice.h index b4dc562bf2..a2389f587a 100644 --- a/Engine/source/sfx/sfxDevice.h +++ b/Engine/source/sfx/sfxDevice.h @@ -24,27 +24,19 @@ #define _SFXDEVICE_H_ #ifndef _PLATFORM_H_ -#include "platform/platform.h" + #include "platform/platform.h" #endif #ifndef _TVECTOR_H_ -#include "core/util/tVector.h" + #include "core/util/tVector.h" #endif #ifndef _SFXCOMMON_H_ -#include "sfx/sfxCommon.h" + #include "sfx/sfxCommon.h" #endif #ifndef _THREADSAFEREF_H_ -#include "platform/threads/threadSafeRefCount.h" -#endif -#ifndef _TDICTIONARY_H_ -#include "core/util/tDictionary.h" -#endif -#ifndef _TSIGNAL_H_ -#include "core/util/tSignal.h" -#endif -#ifndef _PLATFORM_PLATFORMTIMER_H_ -#include "platform/platformTimer.h" + #include "platform/threads/threadSafeRefCount.h" #endif + class SFXProvider; class SFXListener; class SFXBuffer; diff --git a/Tools/CMake/finders/findFLAC.cmake b/Tools/CMake/finders/findFLAC.cmake new file mode 100644 index 0000000000..a77e4901bf --- /dev/null +++ b/Tools/CMake/finders/findFLAC.cmake @@ -0,0 +1,13 @@ +if(TARGET FLAC) + set(FLAC_FOUND TRUE) + set(FLAC_INCLUDE_DIRS $) + set(FLAC_LIBRARIES FLAC) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET FLAC::FLAC) + add_library(FLAC::FLAC ALIAS FLAC) + endif() +else() + set(FLAC_FOUND FALSE) + message(FATAL_ERROR "Flac was not added with add_subdirectory before calling find_package(FLAC).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findOGG.cmake b/Tools/CMake/finders/findOGG.cmake new file mode 100644 index 0000000000..3cdb22111c --- /dev/null +++ b/Tools/CMake/finders/findOGG.cmake @@ -0,0 +1,13 @@ +if(TARGET ogg) + set(OGG_FOUND TRUE) + set(OGG_INCLUDE_DIRS $) + set(OGG_LIBRARIES ogg) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET OGG::OGG) + add_library(OGG::OGG ALIAS ogg) + endif() +else() + set(OGG_FOUND FALSE) + message(FATAL_ERROR "Ogg was not added with add_subdirectory before calling find_package(Ogg).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findOPUS.cmake b/Tools/CMake/finders/findOPUS.cmake new file mode 100644 index 0000000000..0ed268a3d3 --- /dev/null +++ b/Tools/CMake/finders/findOPUS.cmake @@ -0,0 +1,13 @@ +if(TARGET opus) + set(OPUS_FOUND TRUE) + set(OPUS_INCLUDE_DIRS $) + set(OPUS_LIBRARIES opus) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET OPUS::OPUS) + add_library(OPUS::OPUS ALIAS opus) + endif() +else() + set(OPUS_FOUND FALSE) + message(FATAL_ERROR "Opus was not added with add_subdirectory before calling find_package(Opus).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findPCRE.cmake b/Tools/CMake/finders/findPCRE.cmake new file mode 100644 index 0000000000..9db8c09f00 --- /dev/null +++ b/Tools/CMake/finders/findPCRE.cmake @@ -0,0 +1,13 @@ +if(TARGET pcre) + set(PCRE_FOUND TRUE) + set(PCRE_INCLUDE_DIRS $) + set(PCRE_LIBRARIES pcre) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET PCRE::PCRE) + add_library(PCRE::PCRE ALIAS pcre) + endif() +else() + set(PCRE_FOUND FALSE) + message(FATAL_ERROR "PCRE was not added with add_subdirectory before calling find_package(PCRE).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findVorbis.cmake b/Tools/CMake/finders/findVorbis.cmake new file mode 100644 index 0000000000..4fd196bf32 --- /dev/null +++ b/Tools/CMake/finders/findVorbis.cmake @@ -0,0 +1,13 @@ +if(TARGET vorbis) + set(VORBIS_FOUND TRUE) + set(VORBIS_INCLUDE_DIRS $) + set(VORBIS_LIBRARIES vorbis) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET VORBIS::VORBIS) + add_library(VORBIS::VORBIS ALIAS vorbis) + endif() +else() + set(VORBIS_FOUND FALSE) + message(FATAL_ERROR "Vorbis was not added with add_subdirectory before calling find_package(Vorbis).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findZlib.cmake b/Tools/CMake/finders/findZlib.cmake new file mode 100644 index 0000000000..b3a4999e96 --- /dev/null +++ b/Tools/CMake/finders/findZlib.cmake @@ -0,0 +1,14 @@ +# Ensure zlib has been added before using this module +if(TARGET zlib) + set(ZLIB_FOUND TRUE) + set(ZLIB_INCLUDE_DIRS $) + set(ZLIB_LIBRARIES zlib) + message(STATUS "Using Torques build of zlib.") + # Provide an alias for consistency with modern CMake + if(NOT TARGET ZLIB::ZLIB) + add_library(ZLIB::ZLIB ALIAS zlib) + endif() +else() + set(ZLIB_FOUND FALSE) + message(FATAL_ERROR "Zlib was not added with add_subdirectory before calling find_package(ZLIB).") +endif() \ No newline at end of file From fff4ac00511cd994a1b2cb10ef4df118c8c30a00 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 4 Feb 2025 09:23:06 +0000 Subject: [PATCH 14/19] Revert "update finders for linux" This reverts commit 566c61cf0c298216ca5e2c0e1913917210a3d117. --- Tools/CMake/finders/FindFLAC.cmake | 13 ------------- Tools/CMake/finders/FindOGG.cmake | 13 ------------- Tools/CMake/finders/FindOPUS.cmake | 13 ------------- Tools/CMake/finders/FindPCRE.cmake | 13 ------------- Tools/CMake/finders/FindSDL2.cmake | 14 -------------- Tools/CMake/finders/FindVorbis.cmake | 13 ------------- Tools/CMake/finders/FindZlib.cmake | 14 -------------- 7 files changed, 93 deletions(-) delete mode 100644 Tools/CMake/finders/FindFLAC.cmake delete mode 100644 Tools/CMake/finders/FindOGG.cmake delete mode 100644 Tools/CMake/finders/FindOPUS.cmake delete mode 100644 Tools/CMake/finders/FindPCRE.cmake delete mode 100644 Tools/CMake/finders/FindSDL2.cmake delete mode 100644 Tools/CMake/finders/FindVorbis.cmake delete mode 100644 Tools/CMake/finders/FindZlib.cmake diff --git a/Tools/CMake/finders/FindFLAC.cmake b/Tools/CMake/finders/FindFLAC.cmake deleted file mode 100644 index a77e4901bf..0000000000 --- a/Tools/CMake/finders/FindFLAC.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET FLAC) - set(FLAC_FOUND TRUE) - set(FLAC_INCLUDE_DIRS $) - set(FLAC_LIBRARIES FLAC) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET FLAC::FLAC) - add_library(FLAC::FLAC ALIAS FLAC) - endif() -else() - set(FLAC_FOUND FALSE) - message(FATAL_ERROR "Flac was not added with add_subdirectory before calling find_package(FLAC).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindOGG.cmake b/Tools/CMake/finders/FindOGG.cmake deleted file mode 100644 index 3cdb22111c..0000000000 --- a/Tools/CMake/finders/FindOGG.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET ogg) - set(OGG_FOUND TRUE) - set(OGG_INCLUDE_DIRS $) - set(OGG_LIBRARIES ogg) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET OGG::OGG) - add_library(OGG::OGG ALIAS ogg) - endif() -else() - set(OGG_FOUND FALSE) - message(FATAL_ERROR "Ogg was not added with add_subdirectory before calling find_package(Ogg).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindOPUS.cmake b/Tools/CMake/finders/FindOPUS.cmake deleted file mode 100644 index 0ed268a3d3..0000000000 --- a/Tools/CMake/finders/FindOPUS.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET opus) - set(OPUS_FOUND TRUE) - set(OPUS_INCLUDE_DIRS $) - set(OPUS_LIBRARIES opus) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET OPUS::OPUS) - add_library(OPUS::OPUS ALIAS opus) - endif() -else() - set(OPUS_FOUND FALSE) - message(FATAL_ERROR "Opus was not added with add_subdirectory before calling find_package(Opus).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindPCRE.cmake b/Tools/CMake/finders/FindPCRE.cmake deleted file mode 100644 index 9db8c09f00..0000000000 --- a/Tools/CMake/finders/FindPCRE.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET pcre) - set(PCRE_FOUND TRUE) - set(PCRE_INCLUDE_DIRS $) - set(PCRE_LIBRARIES pcre) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET PCRE::PCRE) - add_library(PCRE::PCRE ALIAS pcre) - endif() -else() - set(PCRE_FOUND FALSE) - message(FATAL_ERROR "PCRE was not added with add_subdirectory before calling find_package(PCRE).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindSDL2.cmake b/Tools/CMake/finders/FindSDL2.cmake deleted file mode 100644 index 4070534a30..0000000000 --- a/Tools/CMake/finders/FindSDL2.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# Ensure SDL2 has been added before using this module -if(TARGET SDL2) - set(SDL2_FOUND TRUE) - set(SDL2_INCLUDE_DIRS $) - set(SDL2_LIBRARIES SDL2) - message(STATUS "Using Torques build of SDL2.") - # Provide an alias for consistency with modern CMake - if(NOT TARGET SDL2::SDL2) - add_library(SDL2::SDL2 ALIAS SDL2) - endif() -else() - set(SDL2_FOUND FALSE) - message(FATAL_ERROR "SDL2 was not added with add_subdirectory before calling find_package(SDL2).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindVorbis.cmake b/Tools/CMake/finders/FindVorbis.cmake deleted file mode 100644 index 4fd196bf32..0000000000 --- a/Tools/CMake/finders/FindVorbis.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET vorbis) - set(VORBIS_FOUND TRUE) - set(VORBIS_INCLUDE_DIRS $) - set(VORBIS_LIBRARIES vorbis) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET VORBIS::VORBIS) - add_library(VORBIS::VORBIS ALIAS vorbis) - endif() -else() - set(VORBIS_FOUND FALSE) - message(FATAL_ERROR "Vorbis was not added with add_subdirectory before calling find_package(Vorbis).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindZlib.cmake b/Tools/CMake/finders/FindZlib.cmake deleted file mode 100644 index b3a4999e96..0000000000 --- a/Tools/CMake/finders/FindZlib.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# Ensure zlib has been added before using this module -if(TARGET zlib) - set(ZLIB_FOUND TRUE) - set(ZLIB_INCLUDE_DIRS $) - set(ZLIB_LIBRARIES zlib) - message(STATUS "Using Torques build of zlib.") - # Provide an alias for consistency with modern CMake - if(NOT TARGET ZLIB::ZLIB) - add_library(ZLIB::ZLIB ALIAS zlib) - endif() -else() - set(ZLIB_FOUND FALSE) - message(FATAL_ERROR "Zlib was not added with add_subdirectory before calling find_package(ZLIB).") -endif() \ No newline at end of file From 8dff836d54463e9bdaccaa7c7b3ba7e5f24cfd96 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 4 Feb 2025 09:28:44 +0000 Subject: [PATCH 15/19] Reapply "fix dependencies linux" This reverts commit 593754ec6fa5fbfcc076ec074f8946c124cabc76. --- .github/workflows/build-linux-gcc.yml | 7 +++++++ Engine/source/sfx/SFXInit.h | 24 ++++++++++++++++++++++++ Engine/source/sfx/sfxDevice.h | 18 +++++++++++++----- Tools/CMake/finders/findFLAC.cmake | 13 ------------- Tools/CMake/finders/findOGG.cmake | 13 ------------- Tools/CMake/finders/findOPUS.cmake | 13 ------------- Tools/CMake/finders/findPCRE.cmake | 13 ------------- Tools/CMake/finders/findVorbis.cmake | 13 ------------- Tools/CMake/finders/findZlib.cmake | 14 -------------- 9 files changed, 44 insertions(+), 84 deletions(-) delete mode 100644 Tools/CMake/finders/findFLAC.cmake delete mode 100644 Tools/CMake/finders/findOGG.cmake delete mode 100644 Tools/CMake/finders/findOPUS.cmake delete mode 100644 Tools/CMake/finders/findPCRE.cmake delete mode 100644 Tools/CMake/finders/findVorbis.cmake delete mode 100644 Tools/CMake/finders/findZlib.cmake diff --git a/.github/workflows/build-linux-gcc.yml b/.github/workflows/build-linux-gcc.yml index 8382d27a2b..4176e066e4 100644 --- a/.github/workflows/build-linux-gcc.yml +++ b/.github/workflows/build-linux-gcc.yml @@ -61,6 +61,13 @@ jobs: libx11-dev \ libxxf86vm-dev \ libopenal-dev \ + libasound2-dev \ + libpipewire-0.3-dev \ + portaudio19-dev \ + oss4-dev \ + libjack-dev \ + libpulse-dev \ + libdbus-1-dev \ libfreetype6-dev \ libxcursor-dev \ libxinerama-dev \ diff --git a/Engine/source/sfx/SFXInit.h b/Engine/source/sfx/SFXInit.h index a9d8891702..4b6fcb3057 100644 --- a/Engine/source/sfx/SFXInit.h +++ b/Engine/source/sfx/SFXInit.h @@ -1,8 +1,32 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- #pragma once #ifndef _SFXINIT_H_ #define _SFXINIT_H_ +#ifndef _SFXDEVICE_H_ +#include "sfx/sfxDevice.h" +#endif #ifndef _ENGINEOBJECT_H_ #include "console/engineObject.h" #endif diff --git a/Engine/source/sfx/sfxDevice.h b/Engine/source/sfx/sfxDevice.h index a2389f587a..b4dc562bf2 100644 --- a/Engine/source/sfx/sfxDevice.h +++ b/Engine/source/sfx/sfxDevice.h @@ -24,18 +24,26 @@ #define _SFXDEVICE_H_ #ifndef _PLATFORM_H_ - #include "platform/platform.h" +#include "platform/platform.h" #endif #ifndef _TVECTOR_H_ - #include "core/util/tVector.h" +#include "core/util/tVector.h" #endif #ifndef _SFXCOMMON_H_ - #include "sfx/sfxCommon.h" +#include "sfx/sfxCommon.h" #endif #ifndef _THREADSAFEREF_H_ - #include "platform/threads/threadSafeRefCount.h" +#include "platform/threads/threadSafeRefCount.h" +#endif +#ifndef _TDICTIONARY_H_ +#include "core/util/tDictionary.h" +#endif +#ifndef _TSIGNAL_H_ +#include "core/util/tSignal.h" +#endif +#ifndef _PLATFORM_PLATFORMTIMER_H_ +#include "platform/platformTimer.h" #endif - class SFXProvider; class SFXListener; diff --git a/Tools/CMake/finders/findFLAC.cmake b/Tools/CMake/finders/findFLAC.cmake deleted file mode 100644 index a77e4901bf..0000000000 --- a/Tools/CMake/finders/findFLAC.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET FLAC) - set(FLAC_FOUND TRUE) - set(FLAC_INCLUDE_DIRS $) - set(FLAC_LIBRARIES FLAC) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET FLAC::FLAC) - add_library(FLAC::FLAC ALIAS FLAC) - endif() -else() - set(FLAC_FOUND FALSE) - message(FATAL_ERROR "Flac was not added with add_subdirectory before calling find_package(FLAC).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findOGG.cmake b/Tools/CMake/finders/findOGG.cmake deleted file mode 100644 index 3cdb22111c..0000000000 --- a/Tools/CMake/finders/findOGG.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET ogg) - set(OGG_FOUND TRUE) - set(OGG_INCLUDE_DIRS $) - set(OGG_LIBRARIES ogg) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET OGG::OGG) - add_library(OGG::OGG ALIAS ogg) - endif() -else() - set(OGG_FOUND FALSE) - message(FATAL_ERROR "Ogg was not added with add_subdirectory before calling find_package(Ogg).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findOPUS.cmake b/Tools/CMake/finders/findOPUS.cmake deleted file mode 100644 index 0ed268a3d3..0000000000 --- a/Tools/CMake/finders/findOPUS.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET opus) - set(OPUS_FOUND TRUE) - set(OPUS_INCLUDE_DIRS $) - set(OPUS_LIBRARIES opus) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET OPUS::OPUS) - add_library(OPUS::OPUS ALIAS opus) - endif() -else() - set(OPUS_FOUND FALSE) - message(FATAL_ERROR "Opus was not added with add_subdirectory before calling find_package(Opus).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findPCRE.cmake b/Tools/CMake/finders/findPCRE.cmake deleted file mode 100644 index 9db8c09f00..0000000000 --- a/Tools/CMake/finders/findPCRE.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET pcre) - set(PCRE_FOUND TRUE) - set(PCRE_INCLUDE_DIRS $) - set(PCRE_LIBRARIES pcre) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET PCRE::PCRE) - add_library(PCRE::PCRE ALIAS pcre) - endif() -else() - set(PCRE_FOUND FALSE) - message(FATAL_ERROR "PCRE was not added with add_subdirectory before calling find_package(PCRE).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findVorbis.cmake b/Tools/CMake/finders/findVorbis.cmake deleted file mode 100644 index 4fd196bf32..0000000000 --- a/Tools/CMake/finders/findVorbis.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(TARGET vorbis) - set(VORBIS_FOUND TRUE) - set(VORBIS_INCLUDE_DIRS $) - set(VORBIS_LIBRARIES vorbis) - - # Provide an alias for consistency with modern CMake - if(NOT TARGET VORBIS::VORBIS) - add_library(VORBIS::VORBIS ALIAS vorbis) - endif() -else() - set(VORBIS_FOUND FALSE) - message(FATAL_ERROR "Vorbis was not added with add_subdirectory before calling find_package(Vorbis).") -endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findZlib.cmake b/Tools/CMake/finders/findZlib.cmake deleted file mode 100644 index b3a4999e96..0000000000 --- a/Tools/CMake/finders/findZlib.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# Ensure zlib has been added before using this module -if(TARGET zlib) - set(ZLIB_FOUND TRUE) - set(ZLIB_INCLUDE_DIRS $) - set(ZLIB_LIBRARIES zlib) - message(STATUS "Using Torques build of zlib.") - # Provide an alias for consistency with modern CMake - if(NOT TARGET ZLIB::ZLIB) - add_library(ZLIB::ZLIB ALIAS zlib) - endif() -else() - set(ZLIB_FOUND FALSE) - message(FATAL_ERROR "Zlib was not added with add_subdirectory before calling find_package(ZLIB).") -endif() \ No newline at end of file From f262f5cc166c4f4760882ed697675704b65a381d Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 4 Feb 2025 09:28:37 +0000 Subject: [PATCH 16/19] Reapply "update finders for linux" This reverts commit fff4ac00511cd994a1b2cb10ef4df118c8c30a00. --- Tools/CMake/finders/FindFLAC.cmake | 13 +++++++++++++ Tools/CMake/finders/FindOGG.cmake | 13 +++++++++++++ Tools/CMake/finders/FindOPUS.cmake | 13 +++++++++++++ Tools/CMake/finders/FindPCRE.cmake | 13 +++++++++++++ Tools/CMake/finders/FindSDL2.cmake | 14 ++++++++++++++ Tools/CMake/finders/FindVorbis.cmake | 13 +++++++++++++ Tools/CMake/finders/FindZlib.cmake | 14 ++++++++++++++ 7 files changed, 93 insertions(+) create mode 100644 Tools/CMake/finders/FindFLAC.cmake create mode 100644 Tools/CMake/finders/FindOGG.cmake create mode 100644 Tools/CMake/finders/FindOPUS.cmake create mode 100644 Tools/CMake/finders/FindPCRE.cmake create mode 100644 Tools/CMake/finders/FindSDL2.cmake create mode 100644 Tools/CMake/finders/FindVorbis.cmake create mode 100644 Tools/CMake/finders/FindZlib.cmake diff --git a/Tools/CMake/finders/FindFLAC.cmake b/Tools/CMake/finders/FindFLAC.cmake new file mode 100644 index 0000000000..a77e4901bf --- /dev/null +++ b/Tools/CMake/finders/FindFLAC.cmake @@ -0,0 +1,13 @@ +if(TARGET FLAC) + set(FLAC_FOUND TRUE) + set(FLAC_INCLUDE_DIRS $) + set(FLAC_LIBRARIES FLAC) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET FLAC::FLAC) + add_library(FLAC::FLAC ALIAS FLAC) + endif() +else() + set(FLAC_FOUND FALSE) + message(FATAL_ERROR "Flac was not added with add_subdirectory before calling find_package(FLAC).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindOGG.cmake b/Tools/CMake/finders/FindOGG.cmake new file mode 100644 index 0000000000..3cdb22111c --- /dev/null +++ b/Tools/CMake/finders/FindOGG.cmake @@ -0,0 +1,13 @@ +if(TARGET ogg) + set(OGG_FOUND TRUE) + set(OGG_INCLUDE_DIRS $) + set(OGG_LIBRARIES ogg) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET OGG::OGG) + add_library(OGG::OGG ALIAS ogg) + endif() +else() + set(OGG_FOUND FALSE) + message(FATAL_ERROR "Ogg was not added with add_subdirectory before calling find_package(Ogg).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindOPUS.cmake b/Tools/CMake/finders/FindOPUS.cmake new file mode 100644 index 0000000000..0ed268a3d3 --- /dev/null +++ b/Tools/CMake/finders/FindOPUS.cmake @@ -0,0 +1,13 @@ +if(TARGET opus) + set(OPUS_FOUND TRUE) + set(OPUS_INCLUDE_DIRS $) + set(OPUS_LIBRARIES opus) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET OPUS::OPUS) + add_library(OPUS::OPUS ALIAS opus) + endif() +else() + set(OPUS_FOUND FALSE) + message(FATAL_ERROR "Opus was not added with add_subdirectory before calling find_package(Opus).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindPCRE.cmake b/Tools/CMake/finders/FindPCRE.cmake new file mode 100644 index 0000000000..9db8c09f00 --- /dev/null +++ b/Tools/CMake/finders/FindPCRE.cmake @@ -0,0 +1,13 @@ +if(TARGET pcre) + set(PCRE_FOUND TRUE) + set(PCRE_INCLUDE_DIRS $) + set(PCRE_LIBRARIES pcre) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET PCRE::PCRE) + add_library(PCRE::PCRE ALIAS pcre) + endif() +else() + set(PCRE_FOUND FALSE) + message(FATAL_ERROR "PCRE was not added with add_subdirectory before calling find_package(PCRE).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindSDL2.cmake b/Tools/CMake/finders/FindSDL2.cmake new file mode 100644 index 0000000000..4070534a30 --- /dev/null +++ b/Tools/CMake/finders/FindSDL2.cmake @@ -0,0 +1,14 @@ +# Ensure SDL2 has been added before using this module +if(TARGET SDL2) + set(SDL2_FOUND TRUE) + set(SDL2_INCLUDE_DIRS $) + set(SDL2_LIBRARIES SDL2) + message(STATUS "Using Torques build of SDL2.") + # Provide an alias for consistency with modern CMake + if(NOT TARGET SDL2::SDL2) + add_library(SDL2::SDL2 ALIAS SDL2) + endif() +else() + set(SDL2_FOUND FALSE) + message(FATAL_ERROR "SDL2 was not added with add_subdirectory before calling find_package(SDL2).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindVorbis.cmake b/Tools/CMake/finders/FindVorbis.cmake new file mode 100644 index 0000000000..4fd196bf32 --- /dev/null +++ b/Tools/CMake/finders/FindVorbis.cmake @@ -0,0 +1,13 @@ +if(TARGET vorbis) + set(VORBIS_FOUND TRUE) + set(VORBIS_INCLUDE_DIRS $) + set(VORBIS_LIBRARIES vorbis) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET VORBIS::VORBIS) + add_library(VORBIS::VORBIS ALIAS vorbis) + endif() +else() + set(VORBIS_FOUND FALSE) + message(FATAL_ERROR "Vorbis was not added with add_subdirectory before calling find_package(Vorbis).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/FindZlib.cmake b/Tools/CMake/finders/FindZlib.cmake new file mode 100644 index 0000000000..b3a4999e96 --- /dev/null +++ b/Tools/CMake/finders/FindZlib.cmake @@ -0,0 +1,14 @@ +# Ensure zlib has been added before using this module +if(TARGET zlib) + set(ZLIB_FOUND TRUE) + set(ZLIB_INCLUDE_DIRS $) + set(ZLIB_LIBRARIES zlib) + message(STATUS "Using Torques build of zlib.") + # Provide an alias for consistency with modern CMake + if(NOT TARGET ZLIB::ZLIB) + add_library(ZLIB::ZLIB ALIAS zlib) + endif() +else() + set(ZLIB_FOUND FALSE) + message(FATAL_ERROR "Zlib was not added with add_subdirectory before calling find_package(ZLIB).") +endif() \ No newline at end of file From 2197d52d29561cedde89a9ffccf25157a06e91f2 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 4 Feb 2025 09:33:17 +0000 Subject: [PATCH 17/19] Update aldlist.cpp --- Engine/source/sfx/openal/aldlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp index 77cdf1cbfc..a0866dd0e1 100644 --- a/Engine/source/sfx/openal/aldlist.cpp +++ b/Engine/source/sfx/openal/aldlist.cpp @@ -32,7 +32,7 @@ */ ALDeviceList::ALDeviceList() { - // VECTOR_SET_ASSOCIATION( vDeviceInfo ); + VECTOR_SET_ASSOCIATION( vDeviceInfo ); ALDEVICEINFO ALDeviceInfo; char *devices; From c2847d63d74a4f5f579bedf3bdec7b849b876bb5 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sun, 9 Feb 2025 11:26:21 +0000 Subject: [PATCH 18/19] SFXInit Completed Refactor of SFX Initialization Committing in stages so history is preserved next up is device initialization. --- Engine/source/gfx/gfxAPI.h | 18 +- Engine/source/sfx/SFXInit.cpp | 101 ++++++- Engine/source/sfx/SFXInit.h | 25 ++ Engine/source/sfx/null/sfxNullDevice.cpp | 6 +- Engine/source/sfx/null/sfxNullDevice.h | 2 +- Engine/source/sfx/null/sfxNullProvider.cpp | 73 ++--- Engine/source/sfx/openal/LoadOAL.cpp | 49 ++-- Engine/source/sfx/openal/LoadOAL.h | 13 +- Engine/source/sfx/openal/aldlist.cpp | 299 ------------------- Engine/source/sfx/openal/aldlist.h | 72 ----- Engine/source/sfx/openal/sfxALDevice.cpp | 6 +- Engine/source/sfx/openal/sfxALDevice.h | 4 +- Engine/source/sfx/openal/sfxALProvider.cpp | 174 ++++++----- Engine/source/sfx/sfxApi.cpp | 115 ++++++++ Engine/source/sfx/sfxApi.h | 21 ++ Engine/source/sfx/sfxCommon.h | 94 +----- Engine/source/sfx/sfxDevice.cpp | 35 ++- Engine/source/sfx/sfxDevice.h | 21 +- Engine/source/sfx/sfxEnums.h | 86 ++++++ Engine/source/sfx/sfxParameter.h | 3 + Engine/source/sfx/sfxProvider.cpp | 63 ---- Engine/source/sfx/sfxProvider.h | 77 +---- Engine/source/sfx/sfxSystem.cpp | 325 +++++++-------------- Engine/source/sfx/sfxSystem.h | 8 +- 24 files changed, 697 insertions(+), 993 deletions(-) delete mode 100644 Engine/source/sfx/openal/aldlist.cpp delete mode 100644 Engine/source/sfx/openal/aldlist.h create mode 100644 Engine/source/sfx/sfxApi.cpp create mode 100644 Engine/source/sfx/sfxApi.h create mode 100644 Engine/source/sfx/sfxEnums.h diff --git a/Engine/source/gfx/gfxAPI.h b/Engine/source/gfx/gfxAPI.h index 2c7f420d05..6dc5aa4749 100644 --- a/Engine/source/gfx/gfxAPI.h +++ b/Engine/source/gfx/gfxAPI.h @@ -48,14 +48,14 @@ DefineEnumType( GFXAdapterType ); DECLARE_STRUCT( GFXVideoMode ); -DefineConsoleType( TypeGFXAdapterType, GFXAdapterType ); -DefineConsoleType( TypeGFXBlend, GFXBlend ); -DefineConsoleType( TypeGFXCmpFunc, GFXCmpFunc ); -DefineConsoleType( TypeGFXTextureAddressMode, GFXTextureAddressMode ); -DefineConsoleType( TypeGFXFormat, GFXFormat ); -DefineConsoleType( TypeGFXTextureFilterType, GFXTextureFilterType ); -DefineConsoleType( TypeGFXCullMode, GFXCullMode ); -DefineConsoleType( TypeGFXStencilOp, GFXStencilOp ); -DefineConsoleType( TypeGFXBlendOp, GFXBlendOp ); +DefineConsoleType( TypeGFXAdapterType, GFXAdapterType ) +DefineConsoleType( TypeGFXBlend, GFXBlend ) +DefineConsoleType( TypeGFXCmpFunc, GFXCmpFunc ) +DefineConsoleType( TypeGFXTextureAddressMode, GFXTextureAddressMode ) +DefineConsoleType( TypeGFXFormat, GFXFormat ) +DefineConsoleType( TypeGFXTextureFilterType, GFXTextureFilterType ) +DefineConsoleType( TypeGFXCullMode, GFXCullMode ) +DefineConsoleType( TypeGFXStencilOp, GFXStencilOp ) +DefineConsoleType( TypeGFXBlendOp, GFXBlendOp ) #endif // !_GFXAPI_H_ diff --git a/Engine/source/sfx/SFXInit.cpp b/Engine/source/sfx/SFXInit.cpp index 9043ef1c80..06cec83206 100644 --- a/Engine/source/sfx/SFXInit.cpp +++ b/Engine/source/sfx/SFXInit.cpp @@ -26,16 +26,111 @@ #include "console/console.h" #include "core/module.h" +Vector SFXInit::smProviders(__FILE__, __LINE__); +SFXInit::RegisterProviderSignal* SFXInit::smRegisterProviderSignal; + MODULE_BEGIN(SFXNEW) -MODULE_INIT + MODULE_INIT_BEFORE(Sim) + MODULE_SHUTDOWN_BEFORE(Sim) + + MODULE_INIT + { + SFXInit::init(); + if (engineAPI::gUseConsoleInterop) + SFXDevice::initConsole(); +} + + MODULE_SHUTDOWN + { + SFXDevice::destroy(); + SFXInit::cleanup(); + } + +MODULE_END; + +IMPLEMENT_STATIC_CLASS(SFXInit, SFXAPI, + "Functions for tracking SFX providers and adapters and initializing them into devices." +); + +ConsoleDoc( + "@class SFXInit\n" + "@ingroup SFX\n" + "@brief Functions for tracking SFX providers and adapters and initializing them into devices.\n" +); + +inline static void _SFXInitReportProviders(Vector& providers) +{ + for (SFXProvider* provider : providers) + { + switch (provider->mType) + { + case SFXProviderType::OpenAL: + Con::printf(" OpenAL Provider found"); + break; + case SFXProviderType::NullProvider: + Con::printf(" NULL Provider found"); + break; + case SFXProviderType::XAudio: + Con::printf(" XAudio Provider found"); + break; + case SFXProviderType::DirectSound: + Con::printf(" DirectSound Provider found"); + break; + default: + Con::printf(" Unknown Provider found"); + break; + } + } +} + +SFXInit::RegisterProviderSignal& SFXInit::getRegisterProviderSignal() { + if (smRegisterProviderSignal) + return *smRegisterProviderSignal; + smRegisterProviderSignal = new RegisterProviderSignal(); + return *smRegisterProviderSignal; } -MODULE_SHUTDOWN +void SFXInit::init() { + // init only once. + static bool doneOnce = false; + if (doneOnce) + return; + doneOnce = true; + Con::printf("SFX Init:"); + SFXInit::enumerateProviders(); + + if (!smProviders.size()) + Con::errorf("Could not find audio provider"); + + _SFXInitReportProviders(smProviders); + + Con::printf(""); } -MODULE_END; +void SFXInit::cleanup() +{ + while (smProviders.size()) + { + SFXProvider* prov = smProviders.last(); + smProviders.decrement(); + delete prov; + } + + if (smRegisterProviderSignal) + SAFE_DELETE(smRegisterProviderSignal); +} + +void SFXInit::enumerateProviders() +{ + if (smProviders.size()) + { + return; + } + + getRegisterProviderSignal().trigger(SFXInit::smProviders); +} diff --git a/Engine/source/sfx/SFXInit.h b/Engine/source/sfx/SFXInit.h index 4b6fcb3057..3003d94320 100644 --- a/Engine/source/sfx/SFXInit.h +++ b/Engine/source/sfx/SFXInit.h @@ -27,6 +27,12 @@ #ifndef _SFXDEVICE_H_ #include "sfx/sfxDevice.h" #endif + +#ifndef _SFXAPI_H_ +#include "sfx/sfxApi.h" +#endif // !_SFXAPI_H_ + + #ifndef _ENGINEOBJECT_H_ #include "console/engineObject.h" #endif @@ -36,6 +42,25 @@ class SFXInit DECLARE_STATIC_CLASS(SFXInit) public: + typedef Signal&)> RegisterProviderSignal; + static RegisterProviderSignal& getRegisterProviderSignal(); + /// + /// Initializes the SFX system this will loop through providers and create devices linked to it. + /// + static void init(); + + /// + /// Cleanup all our providers. + /// + static void cleanup(); + + static void enumerateProviders(); + +private: + /// List of known providers. + static Vector smProviders; + static RegisterProviderSignal* smRegisterProviderSignal; + }; diff --git a/Engine/source/sfx/null/sfxNullDevice.cpp b/Engine/source/sfx/null/sfxNullDevice.cpp index 6b53e29b73..390653a986 100644 --- a/Engine/source/sfx/null/sfxNullDevice.cpp +++ b/Engine/source/sfx/null/sfxNullDevice.cpp @@ -28,11 +28,11 @@ SFXNullDevice::SFXNullDevice( SFXProvider* provider, String name, bool useHardware, - S32 maxBuffers ) + S32 maxSources ) - : SFXDevice( name, provider, useHardware, maxBuffers ) + : SFXDevice( name, provider, useHardware, maxSources ) { - mMaxBuffers = getMax( maxBuffers, 8 ); + mMaxBuffers = getMax( maxSources, 8 ); } SFXNullDevice::~SFXNullDevice() diff --git a/Engine/source/sfx/null/sfxNullDevice.h b/Engine/source/sfx/null/sfxNullDevice.h index 299b53cd82..39973f9d2c 100644 --- a/Engine/source/sfx/null/sfxNullDevice.h +++ b/Engine/source/sfx/null/sfxNullDevice.h @@ -48,7 +48,7 @@ class SFXNullDevice : public SFXDevice SFXNullDevice( SFXProvider* provider, String name, bool useHardware, - S32 maxBuffers ); + S32 maxSources ); virtual ~SFXNullDevice(); diff --git a/Engine/source/sfx/null/sfxNullProvider.cpp b/Engine/source/sfx/null/sfxNullProvider.cpp index a41dda4c81..d7bba85c81 100644 --- a/Engine/source/sfx/null/sfxNullProvider.cpp +++ b/Engine/source/sfx/null/sfxNullProvider.cpp @@ -24,75 +24,48 @@ #include "sfx/null/sfxNullDevice.h" #include "core/strings/stringFunctions.h" #include "core/module.h" +#include "sfx/SFXInit.h" - -class SFXNullProvider : public SFXProvider +struct SFXNullProvider : public SFXProvider { -public: - - SFXNullProvider() - : SFXProvider( "Null" ) {} - virtual ~SFXNullProvider(); - -protected: - void addDeviceDesc( const String& name, const String& desc ); - void init() override; - -public: - - SFXDevice* createDevice( const String& deviceName, bool useHardware, S32 maxBuffers ) override; - + SFXDevice* createDevice( const String& deviceName, bool useHardware, S32 maxSources ) override; + static void enumerateDriversAndDevices(Vector& providerList); }; -MODULE_BEGIN( SFXNull ) - - MODULE_INIT_BEFORE( SFX ) - MODULE_SHUTDOWN_AFTER( SFX ) - - SFXNullProvider* mProvider; - - MODULE_INIT - { - mProvider = new SFXNullProvider; - } - - MODULE_SHUTDOWN +class SFXNullRegisterProvider +{ +public: + SFXNullRegisterProvider() { - delete mProvider; + SFXInit::getRegisterProviderSignal().notify(&SFXNullProvider::enumerateDriversAndDevices); } +}; -MODULE_END; +static SFXNullRegisterProvider pSFXNULLRegisterProvider; -void SFXNullProvider::init() +void SFXNullProvider::enumerateDriversAndDevices(Vector& providerList) { - regProvider( this ); - addDeviceDesc( "Null", "SFX Null Device" ); -} + SFXNullProvider* nullPro = new SFXNullProvider(); + nullPro->mType = SFXProviderType::NullProvider; -SFXNullProvider::~SFXNullProvider() -{ -} - - -void SFXNullProvider::addDeviceDesc( const String& name, const String& desc ) -{ SFXDeviceInfo* info = new SFXDeviceInfo; - info->internalName = desc; - info->name = "Null Device"; - info->driver = name; + info->name = "SFX Null Device"; info->hasHardware = false; - info->maxBuffers = 8; + info->maxSources = 8; + info->type = SFXDeviceType::Output; + + nullPro->mDeviceInfo.push_back( info ); - mDeviceInfo.push_back( info ); + providerList.push_back(nullPro); } -SFXDevice* SFXNullProvider::createDevice( const String& deviceName, bool useHardware, S32 maxBuffers ) +SFXDevice* SFXNullProvider::createDevice( const String& deviceName, bool useHardware, S32 maxSources ) { - SFXDeviceInfo* info = _findDeviceInfo( deviceName ); + SFXDeviceInfo* info = mDeviceInfo[0]; // Do we find one to create? if ( info ) - return new SFXNullDevice( this, info->internalName, useHardware, maxBuffers ); + return new SFXNullDevice( this, info->name, useHardware, maxSources ); return NULL; } diff --git a/Engine/source/sfx/openal/LoadOAL.cpp b/Engine/source/sfx/openal/LoadOAL.cpp index ea98cef50f..66b52f6c3b 100644 --- a/Engine/source/sfx/openal/LoadOAL.cpp +++ b/Engine/source/sfx/openal/LoadOAL.cpp @@ -1,26 +1,25 @@ -/* - * 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. - */ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- +// Based on Openal-soft router code. #include "sfx/openal/LoadOAL.h" #include "console/console.h" @@ -32,9 +31,9 @@ #include #endif -void AddDriver(const char* name, LIB_HANDLE dllHandle) +void AddDriver(const Torque::Path& name, LIB_HANDLE dllHandle) { - openAlInterface* oal = new openAlInterface(name, dllHandle); + openAlInterface* oal = new openAlInterface(name.getFileName(), dllHandle); bool loadok = true; diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index 097dd595cf..9f6bac8a47 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -31,7 +31,11 @@ #include "core/util/tVector.h" #endif -// Since openal is deprecated and we pack the lib into the sandbox on mac, all +#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 #include @@ -227,11 +231,8 @@ struct openAlInterface LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv{ nullptr }; LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti{ nullptr }; LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv{ nullptr }; - LPALCGETSTRINGISOFT alcGetStringiSOFT{ nullptr }; - LPALCRESETDEVICESOFT alcResetDeviceSOFT{ nullptr }; #endif - - + int ALCVer{ 0 }; LIB_HANDLE openaAlDll{ nullptr }; String name; @@ -250,7 +251,7 @@ struct openAlInterface inline Vector ALDriverList; -void AddDriver(const char *name, LIB_HANDLE dllHandle); +void AddDriver(const Torque::Path& name, LIB_HANDLE dllHandle); void LoadDriverList(); diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp deleted file mode 100644 index a0866dd0e1..0000000000 --- a/Engine/source/sfx/openal/aldlist.cpp +++ /dev/null @@ -1,299 +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" - - -/* - * Init call - */ -ALDeviceList::ALDeviceList() -{ - VECTOR_SET_ASSOCIATION( vDeviceInfo ); - - ALDEVICEINFO ALDeviceInfo; - char *devices; - int index; - const char *defaultDeviceName; - const char *actualDeviceName; - - // this needs to be executed from outside of this class, for now to maintain functionality - - openAlInterface* ALFunction = ALDriverList[0]; - - // 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() -{ - return 0; - //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; -} diff --git a/Engine/source/sfx/openal/aldlist.h b/Engine/source/sfx/openal/aldlist.h deleted file mode 100644 index 6a5f74e53a..0000000000 --- a/Engine/source/sfx/openal/aldlist.h +++ /dev/null @@ -1,72 +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" - -#ifndef _LOADOAL_H_ -#include "LoadOAL.h" -#endif - -typedef struct -{ - char strDeviceName[256]; - S32 iMajorVersion; - S32 iMinorVersion; - U32 uiSourceCount; - S32 iCapsFlags; - bool bSelected; -} ALDEVICEINFO, *LPALDEVICEINFO; - -class ALDeviceList -{ -private: - Vector vDeviceInfo; - S32 defaultDeviceIndex; - S32 filterIndex; - -public: - ALDeviceList ( ); - ~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 diff --git a/Engine/source/sfx/openal/sfxALDevice.cpp b/Engine/source/sfx/openal/sfxALDevice.cpp index 23058d4f0c..ba5a57dc03 100644 --- a/Engine/source/sfx/openal/sfxALDevice.cpp +++ b/Engine/source/sfx/openal/sfxALDevice.cpp @@ -109,8 +109,8 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, openAlInterface* openal, String name, bool useHardware, - S32 maxBuffers ) - : Parent( name, provider, useHardware, maxBuffers ), + S32 maxSources ) + : Parent( name, provider, useHardware, maxSources ), mOpenAL( openal ), mContext( NULL ), mDevice( NULL ), @@ -119,7 +119,7 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, mRolloffFactor( 1.0f ), mUserRolloffFactor(1.0f) { - mMaxBuffers = getMax( maxBuffers, 8 ); + mMaxBuffers = getMax( maxSources, 8 ); // TODO: The OpenAL device doesn't set the primary buffer // $pref::SFX::frequency or $pref::SFX::bitrate! diff --git a/Engine/source/sfx/openal/sfxALDevice.h b/Engine/source/sfx/openal/sfxALDevice.h index 1d63b13f4c..c489f9e83a 100644 --- a/Engine/source/sfx/openal/sfxALDevice.h +++ b/Engine/source/sfx/openal/sfxALDevice.h @@ -23,8 +23,6 @@ #ifndef _SFXALDEVICE_H_ #define _SFXALDEVICE_H_ -class SFXProvider; - #ifndef _SFXDEVICE_H_ # include "sfx/sfxDevice.h" #endif @@ -65,7 +63,7 @@ class SFXALDevice : public SFXDevice openAlInterface* openal, String name, bool useHardware, - S32 maxBuffers ); + S32 maxSources ); virtual ~SFXALDevice(); diff --git a/Engine/source/sfx/openal/sfxALProvider.cpp b/Engine/source/sfx/openal/sfxALProvider.cpp index 7dc0396921..4777002513 100644 --- a/Engine/source/sfx/openal/sfxALProvider.cpp +++ b/Engine/source/sfx/openal/sfxALProvider.cpp @@ -19,111 +19,151 @@ // 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" +#include "sfx/SFXInit.h" - -class SFXALProvider : public SFXProvider +struct SFXALProvider : public SFXProvider { -public: - - SFXALProvider() - : SFXProvider( "OpenAL" ) { mALDL = NULL; } - virtual ~SFXALProvider(); - -protected: - ALDeviceList *mALDL; + typedef Delegate CreateALDevice; + static void enumerateDriversAndDevices(Vector& providerList); struct ALDeviceInfo : SFXDeviceInfo { - + U32 driverIdx = 0; }; - void init() override; - -public: - SFXDevice *createDevice( const String& deviceName, bool useHardware, S32 maxBuffers ) override; + SFXDevice *createDevice( const String& deviceName, bool useHardware, S32 maxSources ) override; + virtual ~SFXALProvider(); }; -MODULE_BEGIN( OpenAL ) - - MODULE_INIT_BEFORE( SFX ) - MODULE_SHUTDOWN_AFTER( SFX ) - - SFXALProvider* mProvider = NULL; - - MODULE_INIT - { - mProvider = new SFXALProvider; - } - - MODULE_SHUTDOWN +class SFXALRegisterProvider +{ +public: + SFXALRegisterProvider() { - delete mProvider; + SFXInit::getRegisterProviderSignal().notify(&SFXALProvider::enumerateDriversAndDevices); } +}; -MODULE_END; +static SFXALRegisterProvider pSFXALRegisterProvider; -void SFXALProvider::init() +SFXALProvider::~SFXALProvider() +{ +} + +void SFXALProvider::enumerateDriversAndDevices(Vector &providerList) { LoadDriverList(); - //mALDL = new ALDeviceList( mOpenAL ); - - if(ALDriverList.size() < 1) + if (ALDriverList.size() < 1) { Con::printf("SFXALProvider - No valid openal drivers."); return; } - mALDL = new ALDeviceList(); - - // 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"; + SFXALProvider* alProvider = new SFXALProvider(); + alProvider->mType = SFXProviderType::OpenAL; + alProvider->mName = "OpenAL"; - for( S32 i = 0; i < mALDL->GetNumDevices(); i++ ) + U32 driverIdx = 0; + U32 deviceIdx = 0; + for (openAlInterface* alDriver : ALDriverList) { - ALDeviceInfo* info = new ALDeviceInfo; - - info->name = String( mALDL->GetDeviceName( i ) ); - - mDeviceInfo.push_back( info ); + if (alDriver->alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE) + { + char* devices, *defaultDeviceName; + if (alDriver->alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") == AL_TRUE) { + devices = (char*)alDriver->alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); + defaultDeviceName = (char*)alDriver->alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER); + } + else { + devices = (char*)alDriver->alcGetString(NULL, ALC_DEVICE_SPECIFIER); + defaultDeviceName = (char*)alDriver->alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); + } + + // add default device first so it is top of the list. + if (defaultDeviceName != NULL) + { + // make sure we can create it + ALCdevice* device = alDriver->alcOpenDevice(defaultDeviceName); + if (device) + { + ALCcontext* ctx = alDriver->alcCreateContext(device, nullptr); + if (ctx) + { + ALDeviceInfo* devInfo = new ALDeviceInfo; + devInfo->driverIdx = driverIdx; + devInfo->deviceIdx = deviceIdx; + devInfo->name = String(defaultDeviceName); + devInfo->type = SFXDeviceType::Output; + + alProvider->mDeviceInfo.push_back(devInfo); + deviceIdx++; + alDriver->alcMakeContextCurrent(nullptr); + alDriver->alcDestroyContext(ctx); + } + + alDriver->alcCloseDevice(device); + } + } + + const char* ptr = devices; + while (*ptr != 0) + { + for (SFXDeviceInfo* dev : alProvider->mDeviceInfo) + { + if (String::compare(dev->name.c_str(), ptr) == 0) + { + ptr += dev->name.length() + 1; + continue; + } + } + + ALCdevice* device = alDriver->alcOpenDevice(ptr); + if (device) + { + ALCcontext* ctx = alDriver->alcCreateContext(device, nullptr); + if (ctx) + { + alDriver->alcMakeContextCurrent(ctx); + + ALDeviceInfo* devInfo = new ALDeviceInfo; + devInfo->driverIdx = driverIdx; + devInfo->deviceIdx = deviceIdx; + devInfo->name = String(ptr); + devInfo->type = SFXDeviceType::Output; + + alProvider->mDeviceInfo.push_back(devInfo); + deviceIdx++; + ptr += devInfo->name.length() + 1; + + alDriver->alcMakeContextCurrent(nullptr); + alDriver->alcDestroyContext(ctx); + } + + alDriver->alcCloseDevice(device); + } + } + } + + driverIdx++; } - regProvider( this ); -} -SFXALProvider::~SFXALProvider() -{ - if (mALDL) - delete mALDL; + providerList.push_back(alProvider); } -SFXDevice* SFXALProvider::createDevice(const String& deviceName, bool useHardware, S32 maxBuffers) +SFXDevice* SFXALProvider::createDevice(const String& deviceName, bool useHardware, S32 maxSources) { - ALDeviceInfo* info = dynamic_cast - (_findDeviceInfo(deviceName)); - - - // Do we find one to create? - if (info) - return new SFXALDevice(this, ALDriverList[0], info->name, useHardware, maxBuffers); - return NULL; } diff --git a/Engine/source/sfx/sfxApi.cpp b/Engine/source/sfx/sfxApi.cpp new file mode 100644 index 0000000000..0be8508075 --- /dev/null +++ b/Engine/source/sfx/sfxApi.cpp @@ -0,0 +1,115 @@ +#include "sfx/sfxApi.h" + +IMPLEMENT_SCOPE(SFXAPI, SFX, , + "Sound subystem."); + +ImplementEnumType(SFXStatus, + "Playback status of sound source.\n" + "@ingroup SFX") + { SFXStatusPlaying, "Playing", + "The source is currently playing." + }, + { SFXStatusStopped, "Stopped", + "Playback of the source is stopped. When transitioning to Playing state, playback will start at the beginning " + "of the source." }, + { SFXStatusPaused, "Paused", + "Playback of the source is paused. Resuming playback will play from the current playback position." }, +EndImplementEnumType; + +ImplementEnumType(SFXDistanceModel, + "Type of volume distance attenuation curve.\n" + "The distance model determines the falloff curve applied to the volume of 3D sounds over distance.\n\n" + "@ref SFXSource_volume\n\n" + "@ref SFX_3d\n\n" + "@ingroup SFX") + { SFXDistanceModelLinear, "Linear", + "Volume attenuates linearly from the references distance onwards to max distance where it reaches zero." + }, + { SFXDistanceModelLogarithmic, "Logarithmic", + "Volume attenuates logarithmically starting from the reference distance and halving every reference distance step from there on. " + "Attenuation stops at max distance but volume won't reach zero." }, + { SFXDistanceModelExponent, "Exponential", + "Volume attenuates exponentially starting from the reference distance and attenuating every reference distance step by the rolloff factor. " + "Attenuation stops at max distance but volume won't reach zero." }, +EndImplementEnumType; + +ImplementEnumType(SFXChannel, + "Channels are individual properties of sound sources that may be animated over time.\n\n" + "@see SFXParameter\n\n" + "@ref SFX_interactive\n\n" + "@ingroup SFX") + { SFXChannelVolume, "Volume", + "Channel controls volume level of attached sound sources.\n" + "@see SFXDescription::volume" + }, + { SFXChannelPitch, "Pitch", + "Channel controls pitch of attached sound sources.\n" + "@see SFXDescription::pitch" }, + { SFXChannelPriority, "Priority", + "Channel controls virtualizaton priority level of attached sound sources.\n" + "@see SFXDescription::priority" }, + { SFXChannelPositionX, "PositionX", + "Channel controls X coordinate of 3D sound position of attached sources." }, + { SFXChannelPositionY, "PositionY", + "Channel controls Y coordinate of 3D sound position of attached sources." }, + { SFXChannelPositionZ, "PositionZ", + "Channel controls Z coordinate of 3D sound position of attached sources." }, + { SFXChannelRotationX, "RotationX", + "Channel controls X rotation (in degrees) of 3D sound orientation of attached sources." }, + { SFXChannelRotationY, "RotationY", + "Channel controls Y rotation (in degrees) of 3D sound orientation of attached sources." }, + { SFXChannelRotationZ, "RotationZ", + "Channel controls Z rotation (in degrees) of 3D sound orientation of attached sources." }, + { SFXChannelVelocityX, "VelocityX", + "Channel controls X coordinate of 3D sound velocity vector of attached sources." }, + { SFXChannelVelocityY, "VelocityY", + "Channel controls Y coordinate of 3D sound velocity vector of attached sources." }, + { SFXChannelVelocityZ, "VelocityZ", + "Channel controls Z coordinate of 3D sound velocity vector of attached sources." }, + { SFXChannelMinDistance, "ReferenceDistance", + "Channel controls reference distance of 3D sound of attached sources.\n" + "@see SFXDescription::referenceDistance" }, + { SFXChannelMaxDistance, "MaxDistance", + "Channel controls max volume attenuation distance of 3D sound of attached sources.\n" + "@see SFXDescription::maxDistance" }, + { SFXChannelConeInsideAngle, "ConeInsideAngle", + "Channel controls angle (in degrees) of 3D sound inner volume cone of attached sources.\n" + "@see SFXDescription::coneInsideAngle" }, + { SFXChannelConeOutsideAngle, "ConeOutsideAngle", + "Channel controls angle (in degrees) of 3D sound outer volume cone of attached sources.\n" + "@see SFXDescription::coneOutsideAngle" }, + { SFXChannelConeOutsideVolume, "ConeOutsideVolume", + "Channel controls volume outside of 3D sound outer cone of attached sources.\n" + "@see SFXDescription::coneOutsideVolume" }, + { SFXChannelCursor, "Cursor", + "Channel controls playback cursor of attached sound sources.\n\n" + "@note Be aware that different types of sound sources interpret play cursor positions differently " + "or do not actually have play cursors (these sources will ignore the channel)." }, + { SFXChannelStatus, "Status", + "Channel controls playback status of attached sound sources.\n\n" + "The channel's value is rounded down to the nearest integer and interpreted in the following way:\n" + "- 1: Play\n" + "- 2: Stop\n" + "- 3: Pause\n\n" }, + { SFXChannelUser0, "User0", + "Channel available for custom use. By default ignored by sources.\n\n" + "@see SFXSource::onParameterValueChange" }, + { SFXChannelUser1, "User1", + "Channel available for custom use. By default ignored by sources.\n\n" + "@see SFXSource::onParameterValueChange" }, + { SFXChannelUser2, "User2", + "Channel available for custom use. By default ignored by sources.\n\n" + "@see SFXSource::onParameterValueChange" }, + { SFXChannelUser3, "User3", + "Channel available for custom use. By default ignored by sources.\n\n" + "@see SFXSource::onParameterValueChange" } +EndImplementEnumType; + +ImplementEnumType(SFXProviderType, + "The sfx provider.\n" + "@ingroup SFX") + { SFXProviderType::OpenAL, "OpenAL", "Openal Provider." }, + { SFXProviderType::DirectSound, "DirectSound", "DirectSound Provider." }, + { SFXProviderType::XAudio, "XAudio", "XAudio Provider." }, + { SFXProviderType::NullProvider, "NullProvider","NullProvider Provider." } +EndImplementEnumType; diff --git a/Engine/source/sfx/sfxApi.h b/Engine/source/sfx/sfxApi.h new file mode 100644 index 0000000000..02340fe2a6 --- /dev/null +++ b/Engine/source/sfx/sfxApi.h @@ -0,0 +1,21 @@ +#pragma once +#ifndef _SFXAPI_H_ +#define _SFXAPI_H_ + +#ifndef _ENGINEAPI_H_ +#include "console/engineAPI.h" +#endif + +#ifndef _SFXENUMS_H_ +#include "sfx/sfxEnums.h" +#endif + +DECLARE_SCOPE(SFXAPI); + +DefineEnumType(SFXChannel); +DefineEnumType(SFXDistanceModel); +DefineEnumType(SFXStatus); +DefineEnumType(SFXProviderType); + + +#endif // !_SFXAPI_H_ diff --git a/Engine/source/sfx/sfxCommon.h b/Engine/source/sfx/sfxCommon.h index 784f612f63..1c4c8582b7 100644 --- a/Engine/source/sfx/sfxCommon.h +++ b/Engine/source/sfx/sfxCommon.h @@ -45,47 +45,14 @@ #include "console/dynamicTypes.h" #endif +#ifndef _SFXENUMS_H_ +#include "sfx/sfxEnums.h" +#endif class SFXEnvironment; class SFXPlayList; - -//----------------------------------------------------------------------------- -// SFXStatus. -//----------------------------------------------------------------------------- - - -/// The sound playback state. -enum SFXStatus -{ - /// Initial state; no operation yet performed on sound. - SFXStatusNull, - - /// Sound is playing. - SFXStatusPlaying, - - /// Sound has been stopped. - SFXStatusStopped, - - /// Sound is paused. - SFXStatusPaused, - - /// Sound stream is starved and playback blocked. - SFXStatusBlocked, - - /// Temporary state while transitioning to another state. This is used when multiple - /// threads concurrently maintain a status and need to perform a sequence of actions before - /// being able to fully go from a previous to a new current state. In this case, the - /// transition state marks the status as being under update on another thread. - /// - /// @note Not all places that use SFXStatus actually use this state. - SFXStatusTransition, -}; - -DefineEnumType( SFXStatus ); - - inline const char* SFXStatusToString( SFXStatus status ) { switch ( status ) @@ -103,61 +70,6 @@ inline const char* SFXStatusToString( SFXStatus status ) return "null"; } - -//----------------------------------------------------------------------------- -// SFXChannel. -//----------------------------------------------------------------------------- - - -/// Animatable channels in the SFX system. -enum SFXChannel -{ - SFXChannelVolume, - SFXChannelPitch, - SFXChannelPriority, - SFXChannelPositionX, - SFXChannelPositionY, - SFXChannelPositionZ, - SFXChannelRotationX, - SFXChannelRotationY, - SFXChannelRotationZ, - SFXChannelVelocityX, - SFXChannelVelocityY, - SFXChannelVelocityZ, - SFXChannelMinDistance, - SFXChannelMaxDistance, - SFXChannelConeInsideAngle, - SFXChannelConeOutsideAngle, - SFXChannelConeOutsideVolume, - SFXChannelCursor, - SFXChannelStatus, - SFXChannelUser0, - SFXChannelUser1, - SFXChannelUser2, - SFXChannelUser3, - - /// Total number of animatable channels. - SFX_NUM_CHANNELS -}; - -DefineEnumType( SFXChannel ); - - -//----------------------------------------------------------------------------- -// SFXDistanceModel. -//----------------------------------------------------------------------------- - - -/// Rolloff curve used for distance volume attenuation of 3D sounds. -enum SFXDistanceModel -{ - SFXDistanceModelLinear, ///< Volume decreases linearly from min to max where it reaches zero. - SFXDistanceModelLogarithmic, ///< Volume halves every min distance steps starting from min distance; attenuation stops at max distance. - SFXDistanceModelExponent, /// exponential falloff for distance attenuation. -}; - -DefineEnumType( SFXDistanceModel ); - /// Compute the distance attenuation based on the given distance model. /// /// @param minDistance Reference distance; attenuation starts here. diff --git a/Engine/source/sfx/sfxDevice.cpp b/Engine/source/sfx/sfxDevice.cpp index a069b05648..7e31e66b65 100644 --- a/Engine/source/sfx/sfxDevice.cpp +++ b/Engine/source/sfx/sfxDevice.cpp @@ -28,14 +28,24 @@ #include "console/console.h" #include "console/consoleTypes.h" +SFXDevice* SFXDevice::smSFXDevice = NULL; //----------------------------------------------------------------------------- -SFXDevice::SFXDevice( const String& name, SFXProvider* provider, bool useHardware, S32 maxBuffers ) +void SFXDevice::initConsole() +{ +} + +bool SFXDevice::destroy() +{ + return false; +} + +SFXDevice::SFXDevice( const String& name, SFXProvider* provider, bool useHardware, S32 maxSources ) : mName( name ), mProvider( provider ), mUseHardware( useHardware ), - mMaxBuffers( maxBuffers ), + mMaxBuffers( maxSources ), mCaps( 0 ), mStatNumBuffers( 0 ), mStatNumVoices( 0 ), @@ -69,16 +79,14 @@ SFXDevice::~SFXDevice() void SFXDevice::_releaseAllResources() { - using namespace SFXInternal; - // Kill the update thread, if there is one. // Do this first so that further buffer processing // can be done synchronously by us. - ThreadSafeRef< SFXUpdateThread > sfxThread = UPDATE_THREAD(); + ThreadSafeRef< SFXInternal::SFXUpdateThread > sfxThread = SFXInternal::UPDATE_THREAD(); if( sfxThread != NULL ) { - gUpdateThread = NULL; // Kill the global reference. + SFXInternal::gUpdateThread = NULL; // Kill the global reference. sfxThread->stop(); sfxThread->triggerUpdate(); @@ -108,14 +116,14 @@ void SFXDevice::_releaseAllResources() // Flush all asynchronous requests. - THREAD_POOL().flushWorkItems(); + SFXInternal::THREAD_POOL().flushWorkItems(); // Clean out the buffer update list and kill // all buffers that surfaced on the dead list. // Now the sound buffers are really gone. - UPDATE_LIST().process(); - PurgeDeadBuffers(); + SFXInternal::UPDATE_LIST().process(); + SFXInternal::PurgeDeadBuffers(); // Clean out stats. @@ -128,18 +136,16 @@ void SFXDevice::_releaseAllResources() void SFXDevice::update() { - using namespace SFXInternal; - // If we don't have an update thread, do the // updates now on the main thread. - if( !UPDATE_THREAD() ) - UPDATE_LIST().process( MAIN_THREAD_PROCESS_TIMEOUT ); + if( !SFXInternal::UPDATE_THREAD() ) + SFXInternal::UPDATE_LIST().process(SFXInternal::MAIN_THREAD_PROCESS_TIMEOUT ); // Clean out buffers that have surfaced on the dead // buffer list. - PurgeDeadBuffers(); + SFXInternal::PurgeDeadBuffers(); } //----------------------------------------------------------------------------- @@ -182,7 +188,6 @@ void SFXDevice::_removeBuffer( SFXBuffer* buffer ) void SFXDevice::_addVoice( SFXVoice* voice ) { AssertFatal( voice, "SFXDevice::_addVoice() - Got a null voice!" ); - using namespace SFXInternal; // Bind the voice to its buffer. This is deferred up to here in order // to only bind voices that have been successfully constructed. diff --git a/Engine/source/sfx/sfxDevice.h b/Engine/source/sfx/sfxDevice.h index b4dc562bf2..b91fc83524 100644 --- a/Engine/source/sfx/sfxDevice.h +++ b/Engine/source/sfx/sfxDevice.h @@ -45,7 +45,10 @@ #include "platform/platformTimer.h" #endif -class SFXProvider; +#ifndef _SFXPROVIDER_H_ +#include "sfx/sfxProvider.h" +#endif + class SFXListener; class SFXBuffer; class SFXVoice; @@ -54,7 +57,8 @@ class SFXDevice; class SFXStream; class SFXDescription; - +// Global macro +#define SFXNEW SFXDevice::get() /// Abstract base class for back-end sound API implementations. class SFXDevice @@ -72,7 +76,16 @@ class SFXDevice CAPS_DSPEffects = BIT( 3 ), ///< Device implements DSP effects (SFXDSPManager). CAPS_MultiListener = BIT( 4 ), ///< Device supports multiple listeners. }; - + + static SFXDevice* get() { return smSFXDevice; } + static void initConsole(); + static bool destroy(); +private: + /// @name Device management variables + /// @{ + static SFXDevice* smSFXDevice; ///< Global SFXDevice + /// @} + protected: typedef Vector< SFXBuffer* > BufferVector; @@ -81,7 +94,7 @@ class SFXDevice typedef BufferVector::iterator BufferIterator; typedef VoiceVector::iterator VoiceIterator; - SFXDevice( const String& name, SFXProvider* provider, bool useHardware, S32 maxBuffers ); + SFXDevice( const String& name, SFXProvider* provider, bool useHardware, S32 maxSources ); /// The name of this device. String mName; diff --git a/Engine/source/sfx/sfxEnums.h b/Engine/source/sfx/sfxEnums.h new file mode 100644 index 0000000000..a3583fb90d --- /dev/null +++ b/Engine/source/sfx/sfxEnums.h @@ -0,0 +1,86 @@ +#pragma once +#ifndef _SFXENUMS_H_ + +enum SFXProviderType +{ + OpenAL, + XAudio, + DirectSound, + NullProvider, + SFXProviderType_Count +}; + +enum SFXDeviceType +{ + Output, + Input +}; + +/// The sound playback state. +enum SFXStatus +{ + /// Initial state; no operation yet performed on sound. + SFXStatusNull, + + /// Sound is playing. + SFXStatusPlaying, + + /// Sound has been stopped. + SFXStatusStopped, + + /// Sound is paused. + SFXStatusPaused, + + /// Sound stream is starved and playback blocked. + SFXStatusBlocked, + + /// Temporary state while transitioning to another state. This is used when multiple + /// threads concurrently maintain a status and need to perform a sequence of actions before + /// being able to fully go from a previous to a new current state. In this case, the + /// transition state marks the status as being under update on another thread. + /// + /// @note Not all places that use SFXStatus actually use this state. + SFXStatusTransition, +}; + +/// Animatable channels in the SFX system. +enum SFXChannel +{ + SFXChannelVolume, + SFXChannelPitch, + SFXChannelPriority, + SFXChannelPositionX, + SFXChannelPositionY, + SFXChannelPositionZ, + SFXChannelRotationX, + SFXChannelRotationY, + SFXChannelRotationZ, + SFXChannelVelocityX, + SFXChannelVelocityY, + SFXChannelVelocityZ, + SFXChannelMinDistance, + SFXChannelMaxDistance, + SFXChannelConeInsideAngle, + SFXChannelConeOutsideAngle, + SFXChannelConeOutsideVolume, + SFXChannelCursor, + SFXChannelStatus, + SFXChannelUser0, + SFXChannelUser1, + SFXChannelUser2, + SFXChannelUser3, + + /// Total number of animatable channels. + SFX_NUM_CHANNELS +}; + +/// Rolloff curve used for distance volume attenuation of 3D sounds. +enum SFXDistanceModel +{ + SFXDistanceModelLinear, ///< Volume decreases linearly from min to max where it reaches zero. + SFXDistanceModelLogarithmic, ///< Volume halves every min distance steps starting from min distance; attenuation stops at max distance. + SFXDistanceModelExponent, /// exponential falloff for distance attenuation. +}; + + +#endif // !_SFXENUMS_H_ diff --git a/Engine/source/sfx/sfxParameter.h b/Engine/source/sfx/sfxParameter.h index 80f311c7c5..1c8cc787b7 100644 --- a/Engine/source/sfx/sfxParameter.h +++ b/Engine/source/sfx/sfxParameter.h @@ -36,6 +36,9 @@ #include "math/mPoint2.h" #endif +#ifndef _SFXAPI_H_ +#include "sfx/sfxApi.h" +#endif /// Enumeration of events triggered by SFXParameters. enum SFXParameterEvent diff --git a/Engine/source/sfx/sfxProvider.cpp b/Engine/source/sfx/sfxProvider.cpp index 73de67d445..9a8c2e69fe 100644 --- a/Engine/source/sfx/sfxProvider.cpp +++ b/Engine/source/sfx/sfxProvider.cpp @@ -23,51 +23,6 @@ #include "core/strings/stringFunctions.h" #include "sfx/sfxProvider.h" -SFXProvider* SFXProvider::smProviders = NULL; -Vector SFXProvider::sAllProviders( __FILE__, __LINE__ ); - -SFXProvider* SFXProvider::findProvider( String providerName ) -{ - if( providerName.isEmpty() ) - return NULL; - - SFXProvider* curr = smProviders; - for ( ; curr != NULL; curr = curr->mNextProvider ) - { - if( curr->getName().equal( providerName, String::NoCase ) ) - return curr; - } - - return NULL; -} - -void SFXProvider::regProvider( SFXProvider* provider ) -{ - AssertFatal( provider, "Got null provider!" ); - AssertFatal( findProvider( provider->getName() ) == NULL, "Can't register provider twice!" ); - AssertFatal( provider->mNextProvider == NULL, "Can't register provider twice!" ); - - SFXProvider* oldHead = smProviders; - smProviders = provider; - provider->mNextProvider = oldHead; -} - -SFXProvider::SFXProvider( const String& name ) - : mNextProvider( NULL ), - mName( name ) -{ - VECTOR_SET_ASSOCIATION( mDeviceInfo ); - - sAllProviders.push_back( this ); -} - -void SFXProvider::initializeAllProviders() -{ - - for (U32 i = 0; i < sAllProviders.size(); i++) - sAllProviders[i]->init(); - -} SFXProvider::~SFXProvider() { @@ -75,21 +30,3 @@ SFXProvider::~SFXProvider() for ( ; iter != mDeviceInfo.end(); iter++ ) delete *iter; } - -SFXDeviceInfo* SFXProvider::_findDeviceInfo( const String& deviceName ) -{ - SFXDeviceInfoVector::iterator iter = mDeviceInfo.begin(); - for ( ; iter != mDeviceInfo.end(); iter++ ) - { - if( deviceName.equal( ( *iter )->name, String::NoCase ) ) - return *iter; - } - - // If not found and deviceName is empty, - // return first (default) device. - - if( deviceName.isEmpty() && mDeviceInfo.size() > 0 ) - return mDeviceInfo[ 0 ]; - - return NULL; -} diff --git a/Engine/source/sfx/sfxProvider.h b/Engine/source/sfx/sfxProvider.h index 34cbc832c5..765adb4467 100644 --- a/Engine/source/sfx/sfxProvider.h +++ b/Engine/source/sfx/sfxProvider.h @@ -27,6 +27,9 @@ #include "core/util/tVector.h" #endif +#ifndef _SFXENUMS_H_ +#include "sfx/sfxEnums.h" +#endif class SFXDevice; @@ -34,54 +37,22 @@ class SFXDevice; struct SFXDeviceInfo { - String driver; - String internalName; String name; bool hasHardware = false; - S32 maxBuffers =0; - - virtual ~SFXDeviceInfo() {} + S32 maxSources = 0; + U32 deviceIdx = 0; + SFXDeviceType type; }; typedef Vector SFXDeviceInfoVector; -class SFXProvider +struct SFXProvider { - friend class SFXSystem; - - private: - - /// The head of the linked list of avalible providers. - static SFXProvider* smProviders; - - /// The next provider in the linked list of available providers. - SFXProvider* mNextProvider; - - /// The provider name which is passed by the concrete provider - /// class to the SFXProvider constructor. String mName; - - static Vector sAllProviders; - - protected: - - /// The array of avaIlable devices from this provider. The - /// concrete provider class will fill this on construction. SFXDeviceInfoVector mDeviceInfo; - - /// This registers the provider to the available provider list. It should be called - /// for providers that are properly initialized and available for device enumeration and creation. - /// the add and registration process is 2 steps to avoid issues when TGEA is used as a shared library (specifically on Windows) - static void regProvider( SFXProvider* provider ); - - virtual void init() = 0; - - SFXProvider( const String& name ); - ~SFXProvider(); - - /// Look up the SFXDeviceInfo for the given device in mDeviceInfo. - /// Return default device (first in list) if no other device matches (or null if device list is empty). - SFXDeviceInfo* _findDeviceInfo( const String& deviceName ); + /// The case sensitive name of this provider. + const String& getName() const { return mName; } + SFXProviderType mType; /// This is called from SFXSystem to create a new device. Must be implemented /// by all contrete provider classes. @@ -89,36 +60,14 @@ class SFXProvider /// @param deviceName The case sensitive name of the device or NULL to create the // default device. /// @param useHardware Toggles the use of hardware processing when available. - /// @param maxBuffers The maximum buffers for this device to use or -1 + /// @param maxSources The maximum buffers for this device to use or -1 /// for the device to pick a reasonable default for that device. /// /// @return Returns the created device or NULL for failure. /// - virtual SFXDevice* createDevice( const String& deviceName, bool useHardware, S32 maxBuffers ) = 0; - - public: - - /// Returns a specific provider by searching the provider list - /// for the first provider with the case sensitive name. - static SFXProvider* findProvider( String providerName ); - - /// Returns the first provider in the provider list. Use - /// getNextProvider() to iterate over list. - static SFXProvider* getFirstProvider() { return smProviders; } - - /// Returns the next provider in the provider list or NULL - /// when the end of the list is reached. - SFXProvider* getNextProvider() const { return mNextProvider; } - - /// The case sensitive name of this provider. - const String& getName() const { return mName; } - - /// Returns a read only vector with device information for - /// all creatable devices available from this provider. - const SFXDeviceInfoVector& getDeviceInfo() const { return mDeviceInfo; } - - static void initializeAllProviders(); + virtual SFXDevice* createDevice(const String& deviceName, bool useHardware, S32 maxSources) = 0; + virtual ~SFXProvider(); }; diff --git a/Engine/source/sfx/sfxSystem.cpp b/Engine/source/sfx/sfxSystem.cpp index 0903536cfc..97f2e9d25b 100644 --- a/Engine/source/sfx/sfxSystem.cpp +++ b/Engine/source/sfx/sfxSystem.cpp @@ -69,107 +69,6 @@ SFXSystem* SFXSystem::smSingleton = NULL; /// Default SFXAmbience used to reset the global soundscape. SFXAmbience *sDefaultAmbience; -// Excludes Null and Blocked as these are not passed out to the control layer. -ImplementEnumType( SFXStatus, - "Playback status of sound source.\n" - "@ingroup SFX" ) - { SFXStatusPlaying, "Playing", - "The source is currently playing." }, - { SFXStatusStopped, "Stopped", - "Playback of the source is stopped. When transitioning to Playing state, playback will start at the beginning " - "of the source." }, - { SFXStatusPaused, "Paused", - "Playback of the source is paused. Resuming playback will play from the current playback position." }, -EndImplementEnumType; - -ImplementEnumType( SFXDistanceModel, - "Type of volume distance attenuation curve.\n" - "The distance model determines the falloff curve applied to the volume of 3D sounds over distance.\n\n" - "@ref SFXSource_volume\n\n" - "@ref SFX_3d\n\n" - "@ingroup SFX" ) - { SFXDistanceModelLinear, "Linear", - "Volume attenuates linearly from the references distance onwards to max distance where it reaches zero." }, - { SFXDistanceModelLogarithmic, "Logarithmic", - "Volume attenuates logarithmically starting from the reference distance and halving every reference distance step from there on. " - "Attenuation stops at max distance but volume won't reach zero." }, - { SFXDistanceModelExponent, "Exponential", - "Volume attenuates exponentially starting from the reference distance and attenuating every reference distance step by the rolloff factor. " - "Attenuation stops at max distance but volume won't reach zero." }, -EndImplementEnumType; - -ImplementEnumType( SFXChannel, - "Channels are individual properties of sound sources that may be animated over time.\n\n" - "@see SFXParameter\n\n" - "@ref SFX_interactive\n\n" - "@ingroup SFX" ) - { SFXChannelVolume, "Volume", - "Channel controls volume level of attached sound sources.\n" - "@see SFXDescription::volume" }, - { SFXChannelPitch, "Pitch", - "Channel controls pitch of attached sound sources.\n" - "@see SFXDescription::pitch" }, - { SFXChannelPriority, "Priority", - "Channel controls virtualizaton priority level of attached sound sources.\n" - "@see SFXDescription::priority" }, - { SFXChannelPositionX, "PositionX", - "Channel controls X coordinate of 3D sound position of attached sources." }, - { SFXChannelPositionY, "PositionY", - "Channel controls Y coordinate of 3D sound position of attached sources." }, - { SFXChannelPositionZ, "PositionZ", - "Channel controls Z coordinate of 3D sound position of attached sources." }, - { SFXChannelRotationX, "RotationX", - "Channel controls X rotation (in degrees) of 3D sound orientation of attached sources." }, - { SFXChannelRotationY, "RotationY", - "Channel controls Y rotation (in degrees) of 3D sound orientation of attached sources." }, - { SFXChannelRotationZ, "RotationZ", - "Channel controls Z rotation (in degrees) of 3D sound orientation of attached sources." }, - { SFXChannelVelocityX, "VelocityX", - "Channel controls X coordinate of 3D sound velocity vector of attached sources." }, - { SFXChannelVelocityY, "VelocityY", - "Channel controls Y coordinate of 3D sound velocity vector of attached sources." }, - { SFXChannelVelocityZ, "VelocityZ", - "Channel controls Z coordinate of 3D sound velocity vector of attached sources." }, - { SFXChannelMinDistance, "ReferenceDistance", - "Channel controls reference distance of 3D sound of attached sources.\n" - "@see SFXDescription::referenceDistance" }, - { SFXChannelMaxDistance, "MaxDistance", - "Channel controls max volume attenuation distance of 3D sound of attached sources.\n" - "@see SFXDescription::maxDistance" }, - { SFXChannelConeInsideAngle, "ConeInsideAngle", - "Channel controls angle (in degrees) of 3D sound inner volume cone of attached sources.\n" - "@see SFXDescription::coneInsideAngle" }, - { SFXChannelConeOutsideAngle, "ConeOutsideAngle", - "Channel controls angle (in degrees) of 3D sound outer volume cone of attached sources.\n" - "@see SFXDescription::coneOutsideAngle" }, - { SFXChannelConeOutsideVolume, "ConeOutsideVolume", - "Channel controls volume outside of 3D sound outer cone of attached sources.\n" - "@see SFXDescription::coneOutsideVolume" }, - { SFXChannelCursor, "Cursor", - "Channel controls playback cursor of attached sound sources.\n\n" - "@note Be aware that different types of sound sources interpret play cursor positions differently " - "or do not actually have play cursors (these sources will ignore the channel)." }, - { SFXChannelStatus, "Status", - "Channel controls playback status of attached sound sources.\n\n" - "The channel's value is rounded down to the nearest integer and interpreted in the following way:\n" - "- 1: Play\n" - "- 2: Stop\n" - "- 3: Pause\n\n" }, - { SFXChannelUser0, "User0", - "Channel available for custom use. By default ignored by sources.\n\n" - "@see SFXSource::onParameterValueChange" }, - { SFXChannelUser1, "User1", - "Channel available for custom use. By default ignored by sources.\n\n" - "@see SFXSource::onParameterValueChange" }, - { SFXChannelUser2, "User2", - "Channel available for custom use. By default ignored by sources.\n\n" - "@see SFXSource::onParameterValueChange" }, - { SFXChannelUser3, "User3", - "Channel available for custom use. By default ignored by sources.\n\n" - "@see SFXSource::onParameterValueChange" }, -EndImplementEnumType; - - // Constants. static const U32 sDeviceCapsReverb = SFXDevice::CAPS_Reverb; static const U32 sDeviceCapsVoiceManagement = SFXDevice::CAPS_VoiceManagement; @@ -346,7 +245,7 @@ void SFXSystem::init() { AssertWarn( smSingleton == NULL, "SFX has already been initialized!" ); - SFXProvider::initializeAllProviders(); + //SFXProvider::initializeAllProviders(); // Create the stream thread pool. @@ -399,69 +298,69 @@ void SFXSystem::removePlugin( SFXSystemPlugin* plugin ) //----------------------------------------------------------------------------- -bool SFXSystem::createDevice( const String& providerName, const String& deviceName, bool useHardware, S32 maxBuffers, bool changeDevice ) +bool SFXSystem::createDevice( const String& providerName, const String& deviceName, bool useHardware, S32 maxSources, bool changeDevice ) { // Make sure we don't have a device already. - if( mDevice && !changeDevice ) + //if( mDevice && !changeDevice ) return false; // Lookup the provider. - SFXProvider* provider = SFXProvider::findProvider( providerName ); - if( !provider ) - return false; + //SFXProvider* provider = SFXProvider::findProvider( providerName ); + //if( !provider ) + // return false; - // If we have already created this device and are using it then no need to do anything. - - if( mDevice - && providerName.equal( mDevice->getProvider()->getName(), String::NoCase ) - && deviceName.equal( mDevice->getName(), String::NoCase ) - && useHardware == mDevice->getUseHardware() ) - return true; - - // If we have an existing device remove it. - - if( mDevice ) - deleteDevice(); - - // Create the new device.. - - mDevice = provider->createDevice( deviceName, useHardware, maxBuffers ); - if( !mDevice ) - { - Con::errorf( "SFXSystem::createDevice - failed creating %s device '%s'", providerName.c_str(), deviceName.c_str() ); - return false; - } - - // Print capabilities. + //// If we have already created this device and are using it then no need to do anything. + // + //if( mDevice + // && providerName.equal( mDevice->getProvider()->getName(), String::NoCase ) + // && deviceName.equal( mDevice->getName(), String::NoCase ) + // && useHardware == mDevice->getUseHardware() ) + // return true; - Con::printf( "SFXSystem::createDevice - created %s device '%s'", providerName.c_str(), deviceName.c_str() ); - if( mDevice->getCaps() & SFXDevice::CAPS_Reverb ) - Con::printf( " CAPS_Reverb" ); - if( mDevice->getCaps() & SFXDevice::CAPS_VoiceManagement ) - Con::printf( " CAPS_VoiceManagement" ); - if( mDevice->getCaps() & SFXDevice::CAPS_Occlusion ) - Con::printf( "\tCAPS_Occlusion" ); - if( mDevice->getCaps() & SFXDevice::CAPS_MultiListener ) - Con::printf( "\tCAPS_MultiListener" ); - - // Set defaults. - - mDevice->setNumListeners( getNumListeners() ); - mDevice->setDistanceModel( mDistanceModel ); - mDevice->setDopplerFactor( mDopplerFactor ); - mDevice->setRolloffFactor( mRolloffFactor ); - //OpenAL requires slots for effects, this creates an empty function - //that will run when a sfxdevice is created. - //mDevice->openSlots(); - //mDevice->setReverb( mReverb ); - - // Signal system. + //// If we have an existing device remove it. + // + //if( mDevice ) + // deleteDevice(); - getEventSignal().trigger( SFXSystemEvent_CreateDevice ); - - return true; + //// Create the new device.. + // + //mDevice = provider->createDevice( deviceName, useHardware, maxSources ); + //if( !mDevice ) + //{ + // Con::errorf( "SFXSystem::createDevice - failed creating %s device '%s'", providerName.c_str(), deviceName.c_str() ); + // return false; + //} + // + //// Print capabilities. + + //Con::printf( "SFXSystem::createDevice - created %s device '%s'", providerName.c_str(), deviceName.c_str() ); + //if( mDevice->getCaps() & SFXDevice::CAPS_Reverb ) + // Con::printf( " CAPS_Reverb" ); + //if( mDevice->getCaps() & SFXDevice::CAPS_VoiceManagement ) + // Con::printf( " CAPS_VoiceManagement" ); + //if( mDevice->getCaps() & SFXDevice::CAPS_Occlusion ) + // Con::printf( "\tCAPS_Occlusion" ); + //if( mDevice->getCaps() & SFXDevice::CAPS_MultiListener ) + // Con::printf( "\tCAPS_MultiListener" ); + // + //// Set defaults. + // + //mDevice->setNumListeners( getNumListeners() ); + //mDevice->setDistanceModel( mDistanceModel ); + //mDevice->setDopplerFactor( mDopplerFactor ); + //mDevice->setRolloffFactor( mRolloffFactor ); + ////OpenAL requires slots for effects, this creates an empty function + ////that will run when a sfxdevice is created. + ////mDevice->openSlots(); + ////mDevice->setReverb( mReverb ); + // + //// Signal system. + + //getEventSignal().trigger( SFXSystemEvent_CreateDevice ); + // + //return true; } //----------------------------------------------------------------------------- @@ -1210,65 +1109,65 @@ void SFXSystem::dumpSources( StringBuilder* toString, bool excludeGroups ) //----------------------------------------------------------------------------- -DefineEngineFunction( sfxGetAvailableDevices, const char*, (),, - "Get a list of all available sound devices.\n" - "The return value will be a newline-separated list of entries where each line describes one available sound " - "device. Each such line will have the following format:" - "@verbatim\n" - "provider TAB device TAB hasHardware TAB numMaxBuffers\n" - "@endverbatim\n" - "- provider: The name of the device provider (e.g. \"OpenAL\").\n" - "- device: The name of the device as returned by the device layer.\n" - "- hasHardware: Whether the device supports hardware mixing or not.\n" - "- numMaxBuffers: The maximum number of concurrent voices supported by the device's mixer. If this limit " - "limit is exceeded, i.e. if there are more active sounds playing at any one time, then voice virtualization " - "will start culling voices and put them into virtualized playback mode. Voice virtualization may or may not " - "be provided by the device itself; if not provided by the device, it will be provided by Torque's sound system.\n\n" - "@return A newline-separated list of information about all available sound devices.\n" - "@see sfxCreateDevice\n" - "@see sfxGetDeviceInfo\n\n" - "@see $SFX::DEVICE_INFO_PROVIDER\n\n" - "@see $SFX::DEVICE_INFO_NAME\n\n" - "@see $SFX::DEVICE_INFO_USEHARDWARE\n\n" - "@see $SFX::DEVICE_INFO_MAXBUFFERS\n\n" - "@ref SFX_devices\n" - "@ingroup SFX" ) -{ - const S32 bufferSize = 2048; - char* deviceList = Con::getReturnBuffer( bufferSize ); - S32 len = bufferSize; - char *ptr = deviceList; - *ptr = 0; - - SFXProvider* provider = SFXProvider::getFirstProvider(); - while ( provider ) - { - // List the devices in this provider. - const SFXDeviceInfoVector& deviceInfo = provider->getDeviceInfo(); - for ( S32 d=0; d < deviceInfo.size(); d++ ) - { - const SFXDeviceInfo* info = deviceInfo[d]; - const char *providerName = provider->getName().c_str(); - char *infoName = (char*)info->name.c_str(); - - dSprintf(ptr, len, "%s\t%s\t%s\t%i\n", providerName, infoName, info->hasHardware ? "1" : "0", info->maxBuffers); - - ptr += dStrlen(ptr); - len = bufferSize - (ptr - deviceList); - - if (len <= 0) - return deviceList; - } - - provider = provider->getNextProvider(); - } - - return deviceList; -} +//DefineEngineFunction( sfxGetAvailableDevices, const char*, (),, +// "Get a list of all available sound devices.\n" +// "The return value will be a newline-separated list of entries where each line describes one available sound " +// "device. Each such line will have the following format:" +// "@verbatim\n" +// "provider TAB device TAB hasHardware TAB numMaxBuffers\n" +// "@endverbatim\n" +// "- provider: The name of the device provider (e.g. \"OpenAL\").\n" +// "- device: The name of the device as returned by the device layer.\n" +// "- hasHardware: Whether the device supports hardware mixing or not.\n" +// "- numMaxBuffers: The maximum number of concurrent voices supported by the device's mixer. If this limit " +// "limit is exceeded, i.e. if there are more active sounds playing at any one time, then voice virtualization " +// "will start culling voices and put them into virtualized playback mode. Voice virtualization may or may not " +// "be provided by the device itself; if not provided by the device, it will be provided by Torque's sound system.\n\n" +// "@return A newline-separated list of information about all available sound devices.\n" +// "@see sfxCreateDevice\n" +// "@see sfxGetDeviceInfo\n\n" +// "@see $SFX::DEVICE_INFO_PROVIDER\n\n" +// "@see $SFX::DEVICE_INFO_NAME\n\n" +// "@see $SFX::DEVICE_INFO_USEHARDWARE\n\n" +// "@see $SFX::DEVICE_INFO_MAXBUFFERS\n\n" +// "@ref SFX_devices\n" +// "@ingroup SFX" ) +//{ +// const S32 bufferSize = 2048; +// char* deviceList = Con::getReturnBuffer( bufferSize ); +// S32 len = bufferSize; +// char *ptr = deviceList; +// *ptr = 0; +// +// SFXProvider* provider = SFXProvider::getFirstProvider(); +// while ( provider ) +// { +// // List the devices in this provider. +// const SFXDeviceInfoVector& deviceInfo = provider->getDeviceInfo(); +// for ( S32 d=0; d < deviceInfo.size(); d++ ) +// { +// const SFXDeviceInfo* info = deviceInfo[d]; +// const char *providerName = provider->getName().c_str(); +// char *infoName = (char*)info->name.c_str(); +// +// dSprintf(ptr, len, "%s\t%s\t%s\t%i\n", providerName, infoName, info->hasHardware ? "1" : "0", info->maxSources); +// +// ptr += dStrlen(ptr); +// len = bufferSize - (ptr - deviceList); +// +// if (len <= 0) +// return deviceList; +// } +// +// provider = provider->getNextProvider(); +// } +// +// return deviceList; +//} //----------------------------------------------------------------------------- -DefineEngineFunction( sfxCreateDevice, bool, ( const char* provider, const char* device, bool useHardware, S32 maxBuffers ),, +DefineEngineFunction( sfxCreateDevice, bool, ( const char* provider, const char* device, bool useHardware, S32 maxSources ),, "Try to create a new sound device using the given properties.\n" "If a sound device is currently initialized, it will be uninitialized first. However, be aware that in this case, " "if this function fails, it will not restore the previously active device but rather leave the sound system in an " @@ -1279,7 +1178,7 @@ DefineEngineFunction( sfxCreateDevice, bool, ( const char* provider, const char* "@param provider The name of the device provider as returned by sfxGetAvailableDevices().\n" "@param device The name of the device as returned by sfxGetAvailableDevices().\n" "@param useHardware Whether to enabled hardware mixing on the device or not. Only relevant if supported by the given device.\n" - "@param maxBuffers The maximum number of concurrent voices for this device to use or -1 for the device to pick its own reasonable default." + "@param maxSources The maximum number of concurrent voices for this device to use or -1 for the device to pick its own reasonable default." "@return True if the initialization was successful, false if not.\n" "@note This function must be called before any of the sound playback functions can be used.\n" "@see sfxGetAvailableDevices\n" @@ -1288,7 +1187,7 @@ DefineEngineFunction( sfxCreateDevice, bool, ( const char* provider, const char* "@ref SFX_devices\n" "@ingroup SFX" ) { - return SFX->createDevice( provider, device, useHardware, maxBuffers, true ); + return SFX->createDevice( provider, device, useHardware, maxSources, true ); } //----------------------------------------------------------------------------- diff --git a/Engine/source/sfx/sfxSystem.h b/Engine/source/sfx/sfxSystem.h index 7ac0b6f249..8807f75411 100644 --- a/Engine/source/sfx/sfxSystem.h +++ b/Engine/source/sfx/sfxSystem.h @@ -36,6 +36,10 @@ #include "platform/threads/threadSafeRefCount.h" #endif +#ifndef _SFXAPI_H_ +#include "sfx/sfxApi.h" +#endif // !_SFXAPI_H_ + class SFXTrack; class SFXDevice; @@ -263,14 +267,14 @@ class SFXSystem /// @param providerName The name of the provider. /// @param deviceName The name of the provider device. /// @param useHardware Toggles the use of hardware processing when available. - /// @param maxBuffers The maximum buffers for this device to use or -1 + /// @param maxSources The maximum sources for this device to use or -1 /// for the device to pick its own reasonable default. /// @param changeDevice Allows this to change the current device to a new one /// @return Returns true if the device was created. bool createDevice( const String& providerName, const String& deviceName, bool useHardware, - S32 maxBuffers, + S32 maxSources, bool changeDevice = false); /// Returns the current device information or NULL if no From f3532ff6e0a37363b29019d9513796c67a54d006 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 14 Feb 2025 19:29:42 +0000 Subject: [PATCH 19/19] bkup commit testing must continue before major changes committed --- Engine/source/core/ogg/oggTheoraDecoder.cpp | 4 +- Engine/source/core/stream/tStream.h | 4 +- Engine/source/core/util/timeSource.h | 4 +- Engine/source/gfx/video/theoraTexture.cpp | 2 +- Engine/source/gfx/video/theoraTexture.h | 8 +- Engine/source/gui/theora/guiTheoraCtrl.cpp | 2 +- Engine/source/gui/theora/guiTheoraCtrl.h | 2 +- .../source/platform/async/asyncPacketQueue.h | 2 +- .../source/platform/async/asyncPacketStream.h | 6 +- Engine/source/sfx/media/sfxSndStream.cpp | 8 +- Engine/source/sfx/media/sfxSndStream.h | 4 +- Engine/source/sfx/null/sfxNullDevice.cpp | 6 +- Engine/source/sfx/null/sfxNullDevice.h | 4 +- Engine/source/sfx/null/sfxNullVoice.cpp | 6 +- Engine/source/sfx/null/sfxNullVoice.h | 6 +- Engine/source/sfx/openal/sfxALDevice.cpp | 21 +- Engine/source/sfx/openal/sfxALDevice.h | 27 +- Engine/source/sfx/openal/sfxALProvider.cpp | 69 ++++- Engine/source/sfx/openal/sfxALProvider.h | 30 ++ Engine/source/sfx/sfxApi.h | 4 + Engine/source/sfx/sfxDevice.cpp | 24 +- Engine/source/sfx/sfxDevice.h | 267 +++++++++--------- Engine/source/sfx/sfxInternal.cpp | 2 +- Engine/source/sfx/sfxInternal.h | 8 +- Engine/source/sfx/sfxProvider.h | 59 ++-- Engine/source/sfx/sfxSound.cpp | 34 +-- Engine/source/sfx/sfxSound.h | 4 +- Engine/source/sfx/sfxSource.cpp | 4 +- Engine/source/sfx/sfxSystem.cpp | 20 +- Engine/source/sfx/sfxVoice.cpp | 8 +- Engine/source/sfx/sfxVoice.h | 4 +- .../source/util/interpolatedChangeProperty.h | 4 +- 32 files changed, 368 insertions(+), 289 deletions(-) create mode 100644 Engine/source/sfx/openal/sfxALProvider.h diff --git a/Engine/source/core/ogg/oggTheoraDecoder.cpp b/Engine/source/core/ogg/oggTheoraDecoder.cpp index 7fb89229c5..64c7d89678 100644 --- a/Engine/source/core/ogg/oggTheoraDecoder.cpp +++ b/Engine/source/core/ogg/oggTheoraDecoder.cpp @@ -232,7 +232,7 @@ bool OggTheoraDecoder::_packetin( ogg_packet* packet ) TimeSourceRef timeSource = mTimeSource; if( timeSource ) { - F32 currentTick = F32( timeSource->getPosition() ) / 1000.f; + F32 currentTick = F32( timeSource->getTimeIndex() ) / 1000.f; if( currentTick >= ( mCurrentFrameTime + mFrameDuration ) ) dropThisFrame = true; @@ -691,4 +691,4 @@ void OggTheoraDecoder::_transcode420toRGBA_SSE2( th_ycbcr_buffer ycbcr, U8* buff #endif } -#endif \ No newline at end of file +#endif diff --git a/Engine/source/core/stream/tStream.h b/Engine/source/core/stream/tStream.h index 5286116acf..6ea4177e0f 100644 --- a/Engine/source/core/stream/tStream.h +++ b/Engine/source/core/stream/tStream.h @@ -70,11 +70,11 @@ class IPositionable typedef P PositionType; /// @return the current position. - virtual PositionType getPosition() const = 0; + virtual PositionType getTimeIndex() const = 0; /// Set the current position to be "pos". /// @param pos The new position. - virtual void setPosition( PositionType pos ) = 0; + virtual void setTimeIndex( PositionType pos ) = 0; }; /// Interface for structures that allow their state to be reset. diff --git a/Engine/source/core/util/timeSource.h b/Engine/source/core/util/timeSource.h index 991a6aa50d..182fb9a41a 100644 --- a/Engine/source/core/util/timeSource.h +++ b/Engine/source/core/util/timeSource.h @@ -106,7 +106,7 @@ class GenericTimeSource : public IPositionable< Tick >, /// Return the number of ticks since the time source /// has been started. - TickType getPosition() const override + TickType getTimeIndex() const override { if( !isStarted() ) return TypeTraits< TickType >::ZERO; @@ -117,7 +117,7 @@ class GenericTimeSource : public IPositionable< Tick >, } /// - void setPosition( TickType pos ) override + void setTimeIndex( TickType pos ) override { if( !isStarted() ) mStartTime = pos; diff --git a/Engine/source/gfx/video/theoraTexture.cpp b/Engine/source/gfx/video/theoraTexture.cpp index 83063e3be0..efc26aae86 100644 --- a/Engine/source/gfx/video/theoraTexture.cpp +++ b/Engine/source/gfx/video/theoraTexture.cpp @@ -635,7 +635,7 @@ void TheoraTexture::refresh() // lifetime of our time sources isn't bound to the // threaded state. - mAsyncState->syncTime( _getTimeSource()->getPosition() ); + mAsyncState->syncTime( _getTimeSource()->getTimeIndex() ); // Update the texture, if necessary. diff --git a/Engine/source/gfx/video/theoraTexture.h b/Engine/source/gfx/video/theoraTexture.h index d262dfae74..acd7ebc3f5 100644 --- a/Engine/source/gfx/video/theoraTexture.h +++ b/Engine/source/gfx/video/theoraTexture.h @@ -293,8 +293,8 @@ class TheoraTexture : private IOutputStream< TheoraTextureFrame* >, private: // IPositionable. - U32 getPosition() const override { return mCurrentTime; } - void setPosition( U32 pos ) override {} + U32 getTimeIndex() const override { return mCurrentTime; } + void setTimeIndex( U32 pos ) override {} }; /// The Theora video file. @@ -410,8 +410,8 @@ class TheoraTexture : private IOutputStream< TheoraTextureFrame* >, GFXTexHandle& getTexture() { return mCurrentFrame->mTexture; } // IPositionable. - U32 getPosition() const override { return _getTimeSource()->getPosition(); } - void setPosition( U32 pos ) override {} // Not (yet?) implemented. + U32 getTimeIndex() const override { return _getTimeSource()->getTimeIndex(); } + void setTimeIndex( U32 pos ) override {} // Not (yet?) implemented. }; #endif // TORQUE_OGGTHEORA diff --git a/Engine/source/gui/theora/guiTheoraCtrl.cpp b/Engine/source/gui/theora/guiTheoraCtrl.cpp index cb5722d85e..c6e46a390f 100644 --- a/Engine/source/gui/theora/guiTheoraCtrl.cpp +++ b/Engine/source/gui/theora/guiTheoraCtrl.cpp @@ -217,7 +217,7 @@ void GuiTheoraCtrl::onRender(Point2I offset, const RectI &updateRect) String info = String::ToString( "Frame Number: %i | Frame Time: %.2fs | Playback Time: %.2fs | Dropped: %i", mTheoraTexture.getFrameNumber(), mTheoraTexture.getFrameTime(), - F32( mTheoraTexture.getPosition() ) / 1000.f, + F32( mTheoraTexture.getTimeIndex() ) / 1000.f, mTheoraTexture.getNumDroppedFrames() ); drawUtil->setBitmapModulation( mProfile->mFontColors[ 0 ] ); diff --git a/Engine/source/gui/theora/guiTheoraCtrl.h b/Engine/source/gui/theora/guiTheoraCtrl.h index 8209f3cd9d..33cc0ed2a2 100644 --- a/Engine/source/gui/theora/guiTheoraCtrl.h +++ b/Engine/source/gui/theora/guiTheoraCtrl.h @@ -106,7 +106,7 @@ class GuiTheoraCtrl : public GuiControl /// Return the current playback position. F32 getCurrentTime() { - return F32( mTheoraTexture.getPosition() ) / 1000.f; + return F32( mTheoraTexture.getTimeIndex() ) / 1000.f; } // GuiControl. diff --git a/Engine/source/platform/async/asyncPacketQueue.h b/Engine/source/platform/async/asyncPacketQueue.h index 3bf36e9a51..9ff6fdbb6a 100644 --- a/Engine/source/platform/async/asyncPacketQueue.h +++ b/Engine/source/platform/async/asyncPacketQueue.h @@ -191,7 +191,7 @@ class AsyncPacketQueue TickType packetPos = TypeTraits< TickType >::MAX ); /// Return the current playback position according to the time source. - TickType getCurrentTick() const { return Deref( mTimeSource ).getPosition(); } + TickType getCurrentTick() const { return Deref( mTimeSource ).getTimeIndex(); } /// Return the total number of ticks that have been queued so far. TickType getTotalQueuedTicks() const { return mTotalQueuedTicks; } diff --git a/Engine/source/platform/async/asyncPacketStream.h b/Engine/source/platform/async/asyncPacketStream.h index 374118784b..d41b30648b 100644 --- a/Engine/source/platform/async/asyncPacketStream.h +++ b/Engine/source/platform/async/asyncPacketStream.h @@ -255,7 +255,7 @@ AsyncPacketBufferedInputStream< Stream, Packet >::AsyncPacketBufferedInputStream IPositionable< U32 >* positionable = dynamic_cast< IPositionable< U32 >* >( &Deref( stream ) ); if( positionable ) - mNumTotalSourceElements += positionable->getPosition(); + mNumTotalSourceElements += positionable->getTimeIndex(); else { ISizeable< U32 >* sizeable = dynamic_cast< ISizeable< U32 >* >( &Deref( stream ) ); @@ -284,7 +284,7 @@ void AsyncPacketBufferedInputStream< Stream, Packet >::_requestNext() IPositionable< U32 >* positionable = dynamic_cast< IPositionable< U32 >* >( &Deref( stream ) ); U32 pos = 0; if(positionable) - pos = positionable->getPosition(); + pos = positionable->getTimeIndex(); resettable->reset(); isEOS = false; @@ -292,7 +292,7 @@ void AsyncPacketBufferedInputStream< Stream, Packet >::_requestNext() if( positionable ) { - positionable->setPosition(pos); + positionable->setTimeIndex(pos); U32 dur = stream->getDuration(); if(dur != 0) //avoiding division by zero? not needed, probably this->mNumRemainingSourceElements -= (U32)(mNumTotalSourceElements*(F32)pos/dur); diff --git a/Engine/source/sfx/media/sfxSndStream.cpp b/Engine/source/sfx/media/sfxSndStream.cpp index 96ad07711f..2adfb9e371 100644 --- a/Engine/source/sfx/media/sfxSndStream.cpp +++ b/Engine/source/sfx/media/sfxSndStream.cpp @@ -137,10 +137,10 @@ U32 SFXSndStream::read(U8* buffer, U32 length) } // (convert to frames) - number of frames available < MAX_BUFFER? reset - if (((getPosition() / mFormat.getBytesPerSample()) - sfinfo.frames) < MAX_BUFFER) + if (((getTimeIndex() / mFormat.getBytesPerSample()) - sfinfo.frames) < MAX_BUFFER) { // reset stream - setPosition(0); + setTimeIndex(0); } @@ -152,12 +152,12 @@ bool SFXSndStream::isEOS() const return (Parent::isEOS() || (mStream && vio_data.length == vio_data.offset)); } -U32 SFXSndStream::getPosition() const +U32 SFXSndStream::getTimeIndex() const { return vio_data.offset; } -void SFXSndStream::setPosition(U32 offset) +void SFXSndStream::setTimeIndex(U32 offset) { sf_seek(sndFile, offset / mFormat.getBytesPerSample(), SEEK_SET); } diff --git a/Engine/source/sfx/media/sfxSndStream.h b/Engine/source/sfx/media/sfxSndStream.h index a6bfbd28c7..753dcc2a3d 100644 --- a/Engine/source/sfx/media/sfxSndStream.h +++ b/Engine/source/sfx/media/sfxSndStream.h @@ -85,8 +85,8 @@ class SFXSndStream : public SFXFileStream, } // IPositionable - U32 getPosition() const override; - void setPosition(U32 offset) override; + U32 getTimeIndex() const override; + void setTimeIndex(U32 offset) override; }; #endif diff --git a/Engine/source/sfx/null/sfxNullDevice.cpp b/Engine/source/sfx/null/sfxNullDevice.cpp index 390653a986..b222186fc3 100644 --- a/Engine/source/sfx/null/sfxNullDevice.cpp +++ b/Engine/source/sfx/null/sfxNullDevice.cpp @@ -29,10 +29,8 @@ SFXNullDevice::SFXNullDevice( SFXProvider* provider, String name, bool useHardware, S32 maxSources ) - - : SFXDevice( name, provider, useHardware, maxSources ) { - mMaxBuffers = getMax( maxSources, 8 ); + mMaxSources = getMax( maxSources, 8 ); } SFXNullDevice::~SFXNullDevice() @@ -51,7 +49,7 @@ SFXVoice* SFXNullDevice::createVoice( bool is3D, SFXBuffer *buffer ) { // Don't bother going any further if we've // exceeded the maximum voices. - if ( mVoices.size() >= mMaxBuffers ) + if ( mVoices.size() >= mMaxSources ) return NULL; AssertFatal( buffer, "SFXNullDevice::createVoice() - Got null buffer!" ); diff --git a/Engine/source/sfx/null/sfxNullDevice.h b/Engine/source/sfx/null/sfxNullDevice.h index 39973f9d2c..65e715e542 100644 --- a/Engine/source/sfx/null/sfxNullDevice.h +++ b/Engine/source/sfx/null/sfxNullDevice.h @@ -23,8 +23,6 @@ #ifndef _SFXNULLDEVICE_H_ #define _SFXNULLDEVICE_H_ -class SFXProvider; - #ifndef _SFXDEVICE_H_ #include "sfx/sfxDevice.h" #endif @@ -60,4 +58,4 @@ class SFXNullDevice : public SFXDevice void update() override; }; -#endif // _SFXNULLDEVICE_H_ \ No newline at end of file +#endif // _SFXNULLDEVICE_H_ diff --git a/Engine/source/sfx/null/sfxNullVoice.cpp b/Engine/source/sfx/null/sfxNullVoice.cpp index 8f9e0f2a3f..a34f123454 100644 --- a/Engine/source/sfx/null/sfxNullVoice.cpp +++ b/Engine/source/sfx/null/sfxNullVoice.cpp @@ -40,7 +40,7 @@ SFXStatus SFXNullVoice::_status() const if( !mIsLooping && mPlayTimer.isStarted() && !mPlayTimer.isPaused() - && mPlayTimer.getPosition() >= mBuffer->getDuration() ) + && mPlayTimer.getTimeIndex() >= mBuffer->getDuration() ) mPlayTimer.stop(); if( mPlayTimer.isPaused() ) @@ -69,7 +69,7 @@ void SFXNullVoice::_stop() void SFXNullVoice::_seek( U32 sample ) { const U32 sampleTime = mBuffer->getFormat().getDuration( sample ); - mPlayTimer.setPosition( sampleTime ); + mPlayTimer.setTimeIndex( sampleTime ); } void SFXNullVoice::play( bool looping ) @@ -91,7 +91,7 @@ SFXStatus SFXNullVoice::getStatus() const return _status(); } -void SFXNullVoice::setPosition( U32 sample ) +void SFXNullVoice::setTimeIndex( U32 sample ) { _seek( sample ); } diff --git a/Engine/source/sfx/null/sfxNullVoice.h b/Engine/source/sfx/null/sfxNullVoice.h index b28cb66292..b5ecc4d617 100644 --- a/Engine/source/sfx/null/sfxNullVoice.h +++ b/Engine/source/sfx/null/sfxNullVoice.h @@ -64,7 +64,7 @@ class SFXNullVoice : public SFXVoice /// U32 _getPlayTime() const { - return mPlayTimer.getPosition(); + return mPlayTimer.getTimeIndex(); } public: @@ -73,7 +73,7 @@ class SFXNullVoice : public SFXVoice /// SFXVoice SFXStatus getStatus() const override; - void setPosition( U32 sample ) override; + void setTimeIndex( U32 sample ) override; void play( bool looping ) override; void setMinMaxDistance( F32 min, F32 max ) override; void setVelocity( const VectorF& velocity ) override; @@ -83,4 +83,4 @@ class SFXNullVoice : public SFXVoice void setCone( F32 innerAngle, F32 outerAngle, F32 outerVolume ) override; }; -#endif // _SFXNULLVOICE_H_ \ No newline at end of file +#endif // _SFXNULLVOICE_H_ diff --git a/Engine/source/sfx/openal/sfxALDevice.cpp b/Engine/source/sfx/openal/sfxALDevice.cpp index ba5a57dc03..97af29c0fe 100644 --- a/Engine/source/sfx/openal/sfxALDevice.cpp +++ b/Engine/source/sfx/openal/sfxALDevice.cpp @@ -105,13 +105,8 @@ S32 SFXALDevice::getMaxSourcesOld() //----------------------------------------------------------------------------- -SFXALDevice::SFXALDevice( SFXProvider *provider, - openAlInterface* openal, - String name, - bool useHardware, - S32 maxSources ) - : Parent( name, provider, useHardware, maxSources ), - mOpenAL( openal ), +SFXALDevice::SFXALDevice(SFXALProvider::ALDeviceInfo* deviceInfo) + : mDeviceInfo(deviceInfo), mContext( NULL ), mDevice( NULL ), mDistanceModel(SFXDistanceModelLinear), @@ -119,7 +114,7 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, mRolloffFactor( 1.0f ), mUserRolloffFactor(1.0f) { - mMaxBuffers = getMax( maxSources, 8 ); + mOpenAL = ALDriverList[deviceInfo->driverIdx]; // TODO: The OpenAL device doesn't set the primary buffer // $pref::SFX::frequency or $pref::SFX::bitrate! @@ -133,7 +128,7 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, printALInfo(NULL); - mDevice = mOpenAL->alcOpenDevice( name ); + mDevice = mOpenAL->alcOpenDevice(deviceInfo->name); U32 err = mOpenAL->alcGetError(mDevice); if (err != ALC_NO_ERROR) Con::errorf("SFXALDevice - Device Initialization Error: %s", mOpenAL->alcGetString(mDevice, err)); @@ -177,10 +172,10 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, printALInfo(mDevice); - mMaxBuffers = getMaxSources(); + mMaxSources = getMaxSources(); // this should be max sources. - Con::printf("| Max Sources: %d", mMaxBuffers); + Con::printf("| Max Sources: %d", mMaxSources); } @@ -211,7 +206,7 @@ SFXBuffer* SFXALDevice::createBuffer( const ThreadSafeRef< SFXStream >& stream, SFXALBuffer* buffer = SFXALBuffer::create( mOpenAL, stream, description, - mUseHardware ); + true ); if ( !buffer ) return NULL; @@ -225,7 +220,7 @@ SFXVoice* SFXALDevice::createVoice( bool is3D, SFXBuffer *buffer ) { // Don't bother going any further if we've // exceeded the maximum voices. - if ( mVoices.size() >= mMaxBuffers ) + if ( mVoices.size() >= mMaxSources ) return NULL; AssertFatal( buffer, "SFXALDevice::createVoice() - Got null buffer!" ); diff --git a/Engine/source/sfx/openal/sfxALDevice.h b/Engine/source/sfx/openal/sfxALDevice.h index c489f9e83a..17ec6c037b 100644 --- a/Engine/source/sfx/openal/sfxALDevice.h +++ b/Engine/source/sfx/openal/sfxALDevice.h @@ -27,8 +27,8 @@ # include "sfx/sfxDevice.h" #endif -#ifndef _SFXPROVIDER_H_ -# include "sfx/sfxProvider.h" +#ifndef _SFXALPROVIDER_H_ +#include "sfx/openal/sfxALProvider.h" #endif #ifndef _SFXALBUFFER_H_ @@ -43,12 +43,14 @@ # include "sfx/openal/LoadOAL.h" #endif +#define SFXAL static_cast(SFXNEW) +#define SFXALDEVICE SFXAL->getALDevice() +#define SFXALCONTEXT SFXAL->getALDeviceContext() +#define SFXALINTERFACE SFXAL->getALDriverIntrface() class SFXALDevice : public SFXDevice { public: - - typedef SFXDevice Parent; friend class SFXALVoice; // mDistanceFactor, mRolloffFactor void printALInfo(ALCdevice* device); @@ -59,22 +61,16 @@ class SFXALDevice : public SFXDevice // Compatibility with pre openal 1.2 S32 getMaxSourcesOld(); - SFXALDevice( SFXProvider *provider, - openAlInterface* openal, - String name, - bool useHardware, - S32 maxSources ); + SFXALDevice(SFXALProvider::ALDeviceInfo* deviceInfo); virtual ~SFXALDevice(); protected: - + // OpenAL objects. openAlInterface* mOpenAL; - ALCcontext *mContext; - ALCdevice *mDevice; - + SFXALProvider::ALDeviceInfo* mDeviceInfo; SFXDistanceModel mDistanceModel; F32 mDistanceFactor; F32 mRolloffFactor; @@ -83,6 +79,10 @@ class SFXALDevice : public SFXDevice void _setRolloffFactor( F32 factor ); public: + // Accessors for the rest of the openal layer. + ALCdevice* getALDevice() { return mDevice; } + ALCcontext* getALDeviceContext() { return mContext; } + openAlInterface* getALDriverIntrface() { return mOpenAL; } // SFXDevice. SFXBuffer* createBuffer( const ThreadSafeRef< SFXStream >& stream, SFXDescription* description ) override; @@ -91,6 +91,7 @@ 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(); diff --git a/Engine/source/sfx/openal/sfxALProvider.cpp b/Engine/source/sfx/openal/sfxALProvider.cpp index 4777002513..c779aa9f81 100644 --- a/Engine/source/sfx/openal/sfxALProvider.cpp +++ b/Engine/source/sfx/openal/sfxALProvider.cpp @@ -24,6 +24,7 @@ #include "sfx/sfxProvider.h" #include "sfx/openal/sfxALDevice.h" +#include "sfx/openal/sfxALProvider.h" #include "sfx/openal/LoadOAL.h" #include "core/strings/stringFunctions.h" @@ -31,20 +32,6 @@ #include "core/module.h" #include "sfx/SFXInit.h" -struct SFXALProvider : public SFXProvider -{ - typedef Delegate CreateALDevice; - static void enumerateDriversAndDevices(Vector& providerList); - - struct ALDeviceInfo : SFXDeviceInfo - { - U32 driverIdx = 0; - }; - - SFXDevice *createDevice( const String& deviceName, bool useHardware, S32 maxSources ) override; - - virtual ~SFXALProvider(); -}; class SFXALRegisterProvider { @@ -106,6 +93,8 @@ void SFXALProvider::enumerateDriversAndDevices(Vector &providerLis devInfo->deviceIdx = deviceIdx; devInfo->name = String(defaultDeviceName); devInfo->type = SFXDeviceType::Output; + // only true for default driver + devInfo->defaultDevice = driverIdx == 0 ? true : false; alProvider->mDeviceInfo.push_back(devInfo); deviceIdx++; @@ -120,15 +109,20 @@ void SFXALProvider::enumerateDriversAndDevices(Vector &providerLis const char* ptr = devices; while (*ptr != 0) { + bool found = false; for (SFXDeviceInfo* dev : alProvider->mDeviceInfo) { if (String::compare(dev->name.c_str(), ptr) == 0) { ptr += dev->name.length() + 1; - continue; + found = true; + break; } } + if (found) + continue; + ALCdevice* device = alDriver->alcOpenDevice(ptr); if (device) { @@ -154,11 +148,56 @@ void SFXALProvider::enumerateDriversAndDevices(Vector &providerLis alDriver->alcCloseDevice(device); } } + + if (alDriver->alcIsExtensionPresent(NULL, "ALC_EXT_CAPTURE") == AL_FALSE) + continue; + + devices = (char*)alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER); + ptr = devices; + while (*ptr != 0) + { + bool found = false; + for (SFXDeviceInfo* dev : alProvider->mDeviceInfo) + { + if (String::compare(dev->name.c_str(), ptr) == 0) + { + ptr += dev->name.length() + 1; + found = true; + break; + } + } + + if (found) + continue; + + ALCdevice* device = alDriver->alcCaptureOpenDevice(ptr, 22040, AL_FORMAT_MONO8, 22040 * 2); + if (device) + { + ALDeviceInfo* devInfo = new ALDeviceInfo; + devInfo->driverIdx = driverIdx; + devInfo->deviceIdx = deviceIdx; + devInfo->name = String(ptr); + devInfo->type = SFXDeviceType::Input; + + alProvider->mDeviceInfo.push_back(devInfo); + deviceIdx++; + ptr += devInfo->name.length() + 1; + + alDriver->alcCaptureCloseDevice(device); + } + } } driverIdx++; } + Con::printf("Devices Found for %s:", alProvider->mName.c_str()); + for (SFXDeviceInfo* info : alProvider->mDeviceInfo) + { + Con::printf("[%s] %s %s", info->type == SFXDeviceType::Output ? "Output Device" : "Input Device", + info->name.c_str(), + info->defaultDevice ? "(Default Device)" : ""); + } providerList.push_back(alProvider); } diff --git a/Engine/source/sfx/openal/sfxALProvider.h b/Engine/source/sfx/openal/sfxALProvider.h new file mode 100644 index 0000000000..2a763c5782 --- /dev/null +++ b/Engine/source/sfx/openal/sfxALProvider.h @@ -0,0 +1,30 @@ +#pragma once +#ifndef _SFXALPROVIDER_H_ +#define _SFXALPROVIDER_H_ + + +#ifndef _SFXDEVICE_H_ +# include "sfx/sfxDevice.h" +#endif + +#ifndef _SFXPROVIDER_H_ +# include "sfx/sfxProvider.h" +#endif + +struct SFXALProvider : public SFXProvider +{ + typedef Delegate CreateALDevice; + static void enumerateDriversAndDevices(Vector& providerList); + + struct ALDeviceInfo : SFXDeviceInfo + { + U32 driverIdx = 0; + }; + + SFXDevice* createDevice(const String& deviceName, bool useHardware, S32 maxSources) override; + + virtual ~SFXALProvider(); +}; + + +#endif // !_SFXALPROVIDER_H_ diff --git a/Engine/source/sfx/sfxApi.h b/Engine/source/sfx/sfxApi.h index 02340fe2a6..6f3b8315f7 100644 --- a/Engine/source/sfx/sfxApi.h +++ b/Engine/source/sfx/sfxApi.h @@ -17,5 +17,9 @@ DefineEnumType(SFXDistanceModel); DefineEnumType(SFXStatus); DefineEnumType(SFXProviderType); +DefineConsoleType(TypeSFXChannel, SFXChannel) +DefineConsoleType(TypeSFXProviderType, SFXProviderType) +DefineConsoleType(TypeSFXStatus, SFXStatus) +DefineConsoleType(TypeSFXDistanceModel, SFXDistanceModel) #endif // !_SFXAPI_H_ diff --git a/Engine/source/sfx/sfxDevice.cpp b/Engine/source/sfx/sfxDevice.cpp index 7e31e66b65..dad353d51d 100644 --- a/Engine/source/sfx/sfxDevice.cpp +++ b/Engine/source/sfx/sfxDevice.cpp @@ -32,6 +32,7 @@ SFXDevice* SFXDevice::smSFXDevice = NULL; //----------------------------------------------------------------------------- + void SFXDevice::initConsole() { } @@ -41,18 +42,19 @@ bool SFXDevice::destroy() return false; } -SFXDevice::SFXDevice( const String& name, SFXProvider* provider, bool useHardware, S32 maxSources ) - : mName( name ), - mProvider( provider ), - mUseHardware( useHardware ), - mMaxBuffers( maxSources ), - mCaps( 0 ), +SFXDevice::DeviceEventSignal& SFXDevice::getDeviceEventSignal() +{ + static DeviceEventSignal theSignal; + return theSignal; +} + +SFXDevice::SFXDevice() + : mCaps( 0 ), mStatNumBuffers( 0 ), mStatNumVoices( 0 ), - mStatNumBufferBytes( 0 ) + mStatNumBufferBytes( 0 ), + mMaxSources( 16 ) { - AssertFatal( provider, "We must have a provider pointer on device creation!" ); - VECTOR_SET_ASSOCIATION( mBuffers ); VECTOR_SET_ASSOCIATION( mVoices ); @@ -141,10 +143,12 @@ void SFXDevice::update() if( !SFXInternal::UPDATE_THREAD() ) SFXInternal::UPDATE_LIST().process(SFXInternal::MAIN_THREAD_PROCESS_TIMEOUT ); + + // Here we want to loop through our list of active voices, sort them, and cull whatever + // is not playing. This list will be sorted based on priority. // Clean out buffers that have surfaced on the dead // buffer list. - SFXInternal::PurgeDeadBuffers(); } diff --git a/Engine/source/sfx/sfxDevice.h b/Engine/source/sfx/sfxDevice.h index b91fc83524..c849eb487d 100644 --- a/Engine/source/sfx/sfxDevice.h +++ b/Engine/source/sfx/sfxDevice.h @@ -63,171 +63,176 @@ class SFXDescription; /// Abstract base class for back-end sound API implementations. class SFXDevice { - public: - - typedef void Parent; - - /// Device capability flags. - enum ECaps - { - CAPS_Reverb = BIT( 0 ), ///< Device supports reverb environments. - CAPS_VoiceManagement = BIT( 1 ), ///< Device manages voices on its own; deactivates virtualization code in SFX system. - CAPS_Occlusion = BIT( 2 ), ///< Device has its own sound occlusion handling (SFXOcclusionManager). - CAPS_DSPEffects = BIT( 3 ), ///< Device implements DSP effects (SFXDSPManager). - CAPS_MultiListener = BIT( 4 ), ///< Device supports multiple listeners. - }; - - static SFXDevice* get() { return smSFXDevice; } - static void initConsole(); - static bool destroy(); +private: + friend class SFXListener; + friend class SFXBuffer; + friend class SFXVoice; + friend class SFXProfile; + friend class SFXStream; + friend class SFXDescription; + +public: + /// Device capability flags. + enum ECaps + { + CAPS_Reverb = BIT( 0 ), ///< Device supports reverb environments. + CAPS_VoiceManagement = BIT( 1 ), ///< Device manages voices on its own; deactivates virtualization code in SFX system. + CAPS_Occlusion = BIT( 2 ), ///< Device has its own sound occlusion handling (SFXOcclusionManager). + CAPS_DSPEffects = BIT( 3 ), ///< Device implements DSP effects (SFXDSPManager). + CAPS_MultiListener = BIT( 4 ), ///< Device supports multiple listeners. + }; + + enum SFXDeviceEventType + { + /// The device has been created, but not initialized + deCreate, + + /// The device has been initialized + deInit, + + /// The device has kicked off an update + deStartUpdate, + + /// The device is finished updating + deEndUpdate + }; + + typedef Signal DeviceEventSignal; + static DeviceEventSignal& getDeviceEventSignal(); + + static SFXDevice* get() { return smSFXDevice; } + static void initConsole(); + static bool destroy(); private: /// @name Device management variables /// @{ static SFXDevice* smSFXDevice; ///< Global SFXDevice /// @} - protected: +protected: - typedef Vector< SFXBuffer* > BufferVector; - typedef Vector< SFXVoice* > VoiceVector; + typedef Vector< SFXBuffer* > BufferVector; + typedef Vector< SFXVoice* > VoiceVector; - typedef BufferVector::iterator BufferIterator; - typedef VoiceVector::iterator VoiceIterator; - - SFXDevice( const String& name, SFXProvider* provider, bool useHardware, S32 maxSources ); - - /// The name of this device. - String mName; - - /// The provider which created this device. - SFXProvider* mProvider; + typedef BufferVector::iterator BufferIterator; + typedef VoiceVector::iterator VoiceIterator; - /// Should the device try to use hardware processing. - bool mUseHardware; + SFXDevice(); - /// The maximum playback buffers this device will use. - S32 mMaxBuffers; + /// The maximum playback buffers this device will use. + S32 mMaxSources; - /// Current set of sound buffers. - BufferVector mBuffers; + /// Current set of sound buffers. + BufferVector mBuffers; - /// Current set of voices. - VoiceVector mVoices; + /// Current set of voices. + VoiceVector mVoices; - /// Device capabilities. - U32 mCaps; + /// Device capabilities. + U32 mCaps; - /// Current number of buffers. Reflected in $SFX::Device::numBuffers. - U32 mStatNumBuffers; + /// Current number of buffers. Reflected in $SFX::Device::numBuffers. + U32 mStatNumBuffers; - /// Current number of voices. Reflected in $SFX::Device::numVoices. - U32 mStatNumVoices; + /// Current number of voices. Reflected in $SFX::Device::numVoices. + U32 mStatNumVoices; - /// Current total memory size of sound buffers. Reflected in $SFX::Device::numBufferBytes. - U32 mStatNumBufferBytes; + /// Current total memory size of sound buffers. Reflected in $SFX::Device::numBufferBytes. + U32 mStatNumBufferBytes; - /// Register a buffer with the device. - /// This also triggers the buffer's stream packet request chain. - void _addBuffer( SFXBuffer* buffer ); + /// Register a buffer with the device. + /// This also triggers the buffer's stream packet request chain. + void _addBuffer( SFXBuffer* buffer ); - /// Unregister the given buffer. - void _removeBuffer( SFXBuffer* buffer ); + /// Unregister the given buffer. + void _removeBuffer( SFXBuffer* buffer ); - /// Register a voice with the device. - void _addVoice( SFXVoice* voice ); + /// Register a voice with the device. + void _addVoice( SFXVoice* voice ); - /// Unregister the given voice. - virtual void _removeVoice( SFXVoice* buffer ); + /// Unregister the given voice. + virtual void _removeVoice( SFXVoice* buffer ); - /// Release all resources tied to the device. Can be called repeatedly - /// without harm. It is meant for device destructors that will severe - /// the connection to the sound API and thus need all resources freed - /// before the base destructor is called. - void _releaseAllResources(); + /// Release all resources tied to the device. Can be called repeatedly + /// without harm. It is meant for device destructors that will severe + /// the connection to the sound API and thus need all resources freed + /// before the base destructor is called. + void _releaseAllResources(); public: - virtual ~SFXDevice(); - - /// Returns the provider which created this device. - SFXProvider* getProvider() const { return mProvider; } - - /// Is the device set to use hardware processing. - bool getUseHardware() const { return mUseHardware; } - - /// The maximum number of playback buffers this device will use. - S32 getMaxBuffers() const { return mMaxBuffers; } - - /// Returns the name of this device. - const String& getName() const { return mName; } - - /// Return the device capability flags. - U32 getCaps() const { return mCaps; } - - /// Tries to create a new sound buffer. If creation fails - /// freeing another buffer will usually allow a new one to - /// be created. - /// - /// @param stream The sound data stream. - /// @param description The playback configuration. - /// - /// @return Returns a new buffer or NULL if one cannot be created. - /// - virtual SFXBuffer* createBuffer( const ThreadSafeRef< SFXStream >& stream, SFXDescription* description ) = 0; - - /// Create a sound buffer directly for a file. This is for - /// devices that implemented their own custom file loading. - /// - /// @note Only implemented on specific SFXDevices. - /// @return Return a new buffer or NULL. - virtual SFXBuffer* createBuffer( const String& fileName, SFXDescription* description ) { return NULL; } - - /// Tries to create a new voice. - /// - /// @param is3d True if the voice should have 3D sound enabled. - /// @param buffer The sound data to play by the voice. - /// - /// @return Returns a new voice or NULL if one cannot be created. - virtual SFXVoice* createVoice( bool is3D, SFXBuffer* buffer ) = 0; + virtual ~SFXDevice(); + + /// The maximum number of playback buffers this device will use. + S32 getMaxSources() const { return mMaxSources; } + + /// Return the device capability flags. + U32 getCaps() const { return mCaps; } + + /// Tries to create a new sound buffer. If creation fails + /// freeing another buffer will usually allow a new one to + /// be created. + /// + /// @param stream The sound data stream. + /// @param description The playback configuration. + /// + /// @return Returns a new buffer or NULL if one cannot be created. + /// + virtual SFXBuffer* createBuffer( const ThreadSafeRef< SFXStream >& stream, SFXDescription* description ) = 0; + + /// Create a sound buffer directly for a file. This is for + /// devices that implemented their own custom file loading. + /// + /// @note Only implemented on specific SFXDevices. + /// @return Return a new buffer or NULL. + virtual SFXBuffer* createBuffer( const String& fileName, SFXDescription* description ) { return NULL; } + + /// Tries to create a new voice. + /// + /// @param is3d True if the voice should have 3D sound enabled. + /// @param buffer The sound data to play by the voice. + /// + /// @return Returns a new voice or NULL if one cannot be created. + virtual SFXVoice* createVoice( bool is3D, SFXBuffer* buffer ) = 0; - /// Set the rolloff curve to be used by distance attenuation of 3D sounds. - virtual void setDistanceModel( SFXDistanceModel model ) {} + /// Set the rolloff curve to be used by distance attenuation of 3D sounds. + virtual void setDistanceModel( SFXDistanceModel model ) {} - /// Set the scale factor to use for doppler effects on 3D sounds. - virtual void setDopplerFactor( F32 factor ) {} + /// Set the scale factor to use for doppler effects on 3D sounds. + virtual void setDopplerFactor( F32 factor ) {} - /// Set the rolloff scale factor for distance attenuation of 3D sounds. - virtual void setRolloffFactor( F32 factor ) {} + /// Set the rolloff scale factor for distance attenuation of 3D sounds. + virtual void setRolloffFactor( F32 factor ) {} - /// send empty function to all sfxdevices - virtual void openSlots() {} + /// send empty function to all sfxdevices + virtual void openSlots() {} - /// Set the global reverb environment. - virtual void setReverb( const SFXReverbProperties& reverb ) {} + /// Set the global reverb environment. + virtual void setReverb( const SFXReverbProperties& reverb ) {} - /// Reset the global reverb environment to its default. - virtual void resetReverb() {} - - /// Set the number of concurrent listeners on the device. - /// - /// @note On devices that do not support multiple listeners, any value - /// other than 1 will be ignored. - virtual void setNumListeners( U32 num ) {} + /// Reset the global reverb environment to its default. + virtual void resetReverb() {} + + /// Set the number of concurrent listeners on the device. + /// + /// @note On devices that do not support multiple listeners, any value + /// other than 1 will be ignored. + virtual void setNumListeners( U32 num ) {} - /// Set the properties of the given listener. - /// - /// @note On devices that do not support multiple listeners, only setting - /// the properties on index=0 will have a effect. - virtual void setListener( U32 index, const SFXListenerProperties& listener ) {} + /// Set the properties of the given listener. + /// + /// @note On devices that do not support multiple listeners, only setting + /// the properties on index=0 will have a effect. + virtual void setListener( U32 index, const SFXListenerProperties& listener ) {} - /// Return the current total number of sound buffers. - U32 getBufferCount() const { return mBuffers.size(); } + /// Return the current total number of sound buffers. + U32 getBufferCount() const { return mBuffers.size(); } - /// Return the current total number of voices. - U32 getVoiceCount() const { return mVoices.size(); } + /// Return the current total number of voices. + U32 getVoiceCount() const { return mVoices.size(); } - /// Called from SFXSystem to do any updates the device may need to make. - virtual void update(); + /// Called from SFXSystem to do any updates the device may need to make. + virtual void update(); }; diff --git a/Engine/source/sfx/sfxInternal.cpp b/Engine/source/sfx/sfxInternal.cpp index 37aea5d268..abd6c118d6 100644 --- a/Engine/source/sfx/sfxInternal.cpp +++ b/Engine/source/sfx/sfxInternal.cpp @@ -60,7 +60,7 @@ SFXAsyncStream::SFXAsyncStream( const SFXStreamRef& stream, : stream->getDataLength(), // Non-streamed buffer; read entire stream in one packet. stream->getDataLength() // Read all remaining data in stream. - ( dynamic_cast< IPositionable< U32 >* >( stream.ptr() ) - ? dynamic_cast< IPositionable< U32 >* >( stream.ptr() )->getPosition() + ? dynamic_cast< IPositionable< U32 >* >( stream.ptr() )->getTimeIndex() : 0 ), numReadAhead, isLooping, diff --git a/Engine/source/sfx/sfxInternal.h b/Engine/source/sfx/sfxInternal.h index 7d2c49df2b..74b18e5bd7 100644 --- a/Engine/source/sfx/sfxInternal.h +++ b/Engine/source/sfx/sfxInternal.h @@ -195,7 +195,7 @@ class SFXVoiceTimeSource SFXVoiceTimeSource( SFXVoice* voice ) : mVoice( voice ), mLastPos( 0 ) {} - U32 getPosition() const + U32 getTimeIndex() const { U32 samplePos = mVoice->_tell(); @@ -451,6 +451,12 @@ inline bool isSFXThread() return ThreadManager::compare( ThreadManager::getCurrentThreadId(), threadId ); } +class SFXManager { +private: + ThreadSafeDeque mPacketQueue; + +}; + } // namespace SFXInternal #endif // !_SFXINTERNAL_H_ diff --git a/Engine/source/sfx/sfxProvider.h b/Engine/source/sfx/sfxProvider.h index 765adb4467..ee40d5f290 100644 --- a/Engine/source/sfx/sfxProvider.h +++ b/Engine/source/sfx/sfxProvider.h @@ -33,41 +33,40 @@ class SFXDevice; - - -struct SFXDeviceInfo +struct SFXProvider { - String name; - bool hasHardware = false; - S32 maxSources = 0; - U32 deviceIdx = 0; - SFXDeviceType type; -}; + struct SFXDeviceInfo + { + String name; + bool hasHardware = false; + bool defaultDevice = false; + S32 maxSources = 0; + U32 deviceIdx = 0; + SFXDeviceType type; + }; -typedef Vector SFXDeviceInfoVector; + typedef Vector SFXDeviceInfoVector; -struct SFXProvider -{ - String mName; - SFXDeviceInfoVector mDeviceInfo; - /// The case sensitive name of this provider. - const String& getName() const { return mName; } - SFXProviderType mType; + String mName; + SFXDeviceInfoVector mDeviceInfo; + /// The case sensitive name of this provider. + const String& getName() const { return mName; } + SFXProviderType mType; - /// This is called from SFXSystem to create a new device. Must be implemented - /// by all contrete provider classes. - /// - /// @param deviceName The case sensitive name of the device or NULL to create the - // default device. - /// @param useHardware Toggles the use of hardware processing when available. - /// @param maxSources The maximum buffers for this device to use or -1 - /// for the device to pick a reasonable default for that device. - /// - /// @return Returns the created device or NULL for failure. - /// - virtual SFXDevice* createDevice(const String& deviceName, bool useHardware, S32 maxSources) = 0; + /// This is called from SFXSystem to create a new device. Must be implemented + /// by all contrete provider classes. + /// + /// @param deviceName The case sensitive name of the device or NULL to create the + // default device. + /// @param useHardware Toggles the use of hardware processing when available. + /// @param maxSources The maximum buffers for this device to use or -1 + /// for the device to pick a reasonable default for that device. + /// + /// @return Returns the created device or NULL for failure. + /// + virtual SFXDevice* createDevice(const String& deviceName, bool useHardware, S32 maxSources) = 0; - virtual ~SFXProvider(); + virtual ~SFXProvider(); }; diff --git a/Engine/source/sfx/sfxSound.cpp b/Engine/source/sfx/sfxSound.cpp index 447eb993bd..98456ed73d 100644 --- a/Engine/source/sfx/sfxSound.cpp +++ b/Engine/source/sfx/sfxSound.cpp @@ -273,12 +273,12 @@ bool SFXSound::_allocVoice( SFXDevice* device ) // If virtualized playback has been started, we transfer its position to the // voice and stop virtualization. - const U32 playTime = mPlayTimer.getPosition(); + const U32 playTime = mPlayTimer.getTimeIndex(); if( playTime > 0 ) { const U32 pos = mBuffer->getFormat().getSampleCount( playTime ); - mVoice->setPosition( pos); + mVoice->setTimeIndex( pos); } mVoice->play( isLooping() ); @@ -303,7 +303,7 @@ void SFXSound::_onParameterEvent( SFXParameter* parameter, SFXParameterEvent eve switch( parameter->getChannel() ) { case SFXChannelCursor: - setPosition( parameter->getValue() * 1000.f ); + setTimeIndex( parameter->getValue() * 1000.f ); break; default: @@ -365,7 +365,7 @@ bool SFXSound::_releaseVoice() // Sync up the play timer with the voice's current position to make // sure we handle any lag that's cropped up. - mPlayTimer.setPosition( mVoice->getPosition() ); + mPlayTimer.setTimeIndex( mVoice->getTimeIndex() ); if( status == SFXStatusBlocked ) status = SFXStatusPlaying; @@ -412,8 +412,8 @@ void SFXSound::_play() Platform::outputDebugString( "[SFXSound] virtualizing playback of source '%i'", getId() ); #endif } - if(getPosition() != mSetPositionValue) - setPosition(mSetPositionValue); + if(getTimeIndex() != mSetPositionValue) + setTimeIndex(mSetPositionValue); mSetPositionValue = 0; //Non looping sounds need this to reset. } @@ -436,7 +436,7 @@ void SFXSound::_pause() if( mVoice ) mVoice->pause(); - mSetPositionValue = getPosition(); + mSetPositionValue = getTimeIndex(); } //----------------------------------------------------------------------------- @@ -469,7 +469,7 @@ void SFXSound::_updateStatus() // need to decide if the sound is done playing // to ensure proper virtualization of the sound. - if( mPlayTimer.getPosition() > mDuration ) + if( mPlayTimer.getTimeIndex() > mDuration ) { _stop(); _setStatus( SFXStatusStopped ); @@ -515,27 +515,27 @@ void SFXSound::_updatePriority() //----------------------------------------------------------------------------- -U32 SFXSound::getPosition() const +U32 SFXSound::getTimeIndex() const { if( getLastStatus() == SFXStatusStopped) return mSetPositionValue; if( mVoice ) - return mVoice->getFormat().getDuration( mVoice->getPosition() ); + return mVoice->getFormat().getDuration( mVoice->getTimeIndex() ); else - return ( mPlayTimer.getPosition() % mDuration ); // Clamp for looped sounds. + return ( mPlayTimer.getTimeIndex() % mDuration ); // Clamp for looped sounds. } //----------------------------------------------------------------------------- -void SFXSound::setPosition( U32 ms ) +void SFXSound::setTimeIndex( U32 ms ) { AssertFatal( ms < getDuration(), "SFXSound::setPosition() - position out of range" ); mSetPositionValue = ms; if( mVoice ) - mVoice->setPosition( mVoice->getFormat().getSampleCount( ms ) ); + mVoice->setTimeIndex( mVoice->getFormat().getSampleCount( ms ) ); else - mPlayTimer.setPosition( ms ); + mPlayTimer.setTimeIndex( ms ); } //----------------------------------------------------------------------------- @@ -608,7 +608,7 @@ SFXProfile* SFXSound::getProfile() const F32 SFXSound::getElapsedPlayTimeCurrentCycle() const { - return F32( getPosition() ) / 1000.f; + return F32(getTimeIndex() ) / 1000.f; } //----------------------------------------------------------------------------- @@ -692,7 +692,7 @@ DefineEngineMethod( SFXSound, getPosition, F32, (),, "Get the current playback position in seconds.\n" "@return The current play cursor offset." ) { - return F32( object->getPosition() ) * 0.001f; + return F32( object->getTimeIndex() ) * 0.001f; } //----------------------------------------------------------------------------- @@ -705,7 +705,7 @@ DefineEngineMethod( SFXSound, setPosition, void, ( F32 position ),, { position *= 1000.0f; if( position >= 0 && position < object->getDuration() ) - object->setPosition( position ); + object->setTimeIndex( position ); } //----------------------------------------------------------------------------- diff --git a/Engine/source/sfx/sfxSound.h b/Engine/source/sfx/sfxSound.h index c3c5dd8c59..07040f08e5 100644 --- a/Engine/source/sfx/sfxSound.h +++ b/Engine/source/sfx/sfxSound.h @@ -131,10 +131,10 @@ class SFXSound : public SFXSource, /// Return the current playback position in milliseconds. /// @note For looping sources, this returns the position in the current cycle. - U32 getPosition() const override; + U32 getTimeIndex() const override; /// Set the current playback position in milliseconds. - void setPosition( U32 ms ) override; + void setTimeIndex( U32 ms ) override; /// Returns the source's total playback time in milliseconds. U32 getDuration() const { return mDuration; } diff --git a/Engine/source/sfx/sfxSource.cpp b/Engine/source/sfx/sfxSource.cpp index 5d782dee5b..0caafea01d 100644 --- a/Engine/source/sfx/sfxSource.cpp +++ b/Engine/source/sfx/sfxSource.cpp @@ -460,7 +460,7 @@ SFXSource* SFXSource::getSourceGroup() const F32 SFXSource::getElapsedPlayTime() const { - return F32( mPlayTimer.getPosition() ) / 1000.f; + return F32( mPlayTimer.getTimeIndex() ) / 1000.f; } //----------------------------------------------------------------------------- @@ -471,7 +471,7 @@ F32 SFXSource::getElapsedPlayTimeCurrentCycle() const // and thus cannot clamp the playtimer into range for the current cycle. // This needs to be done by subclasses. - return F32( mPlayTimer.getPosition() ) / 1000.f; + return F32( mPlayTimer.getTimeIndex() ) / 1000.f; } //----------------------------------------------------------------------------- diff --git a/Engine/source/sfx/sfxSystem.cpp b/Engine/source/sfx/sfxSystem.cpp index 97f2e9d25b..e58049b2b8 100644 --- a/Engine/source/sfx/sfxSystem.cpp +++ b/Engine/source/sfx/sfxSystem.cpp @@ -367,16 +367,16 @@ bool SFXSystem::createDevice( const String& providerName, const String& deviceNa String SFXSystem::getDeviceInfoString() { - // Make sure we have a valid device. - if( !mDevice ) +// // Make sure we have a valid device. +// if( !mDevice ) return String(); - - return String::ToString( "%s\t%s\t%s\t%d\t%d", - mDevice->getProvider()->getName().c_str(), - mDevice->getName().c_str(), - mDevice->getUseHardware() ? "1" : "0", - mDevice->getMaxBuffers(), - mDevice->getCaps() ); +// +// return String::ToString( "%s\t%s\t%s\t%d\t%d", +// mDevice->getProvider()->getName().c_str(), +// mDevice->getName().c_str(), +// mDevice->getUseHardware() ? "1" : "0", +// mDevice->getMaxBuffers(), +// mDevice->getCaps() ); } //----------------------------------------------------------------------------- @@ -849,7 +849,7 @@ void SFXSystem::_assignVoices() if( ( other->getAttenuatedVolume() < 0.1 // Very quiet or maybe not even audible. || !other->isPlaying() // Not playing so not audible anyways. - || other->getPosition() == 0 ) // Not yet started playing. + || other->getTimeIndex() == 0 ) // Not yet started playing. && other->_releaseVoice() ) break; } diff --git a/Engine/source/sfx/sfxVoice.cpp b/Engine/source/sfx/sfxVoice.cpp index b12cfcbcb4..456ffa2bc7 100644 --- a/Engine/source/sfx/sfxVoice.cpp +++ b/Engine/source/sfx/sfxVoice.cpp @@ -260,7 +260,7 @@ void SFXVoice::stop() //----------------------------------------------------------------------------- -U32 SFXVoice::getPosition() const +U32 SFXVoice::getTimeIndex() const { // When stopped, always return 0. @@ -290,7 +290,7 @@ U32 SFXVoice::getPosition() const //----------------------------------------------------------------------------- -void SFXVoice::setPosition( U32 inSample ) +void SFXVoice::setTimeIndex( U32 inSample ) { // Clamp to sample range. const U32 sample = inSample % ( mBuffer->getFormat().getSampleCount( mBuffer->getDuration() ) - 1 ); @@ -299,7 +299,7 @@ void SFXVoice::setPosition( U32 inSample ) // given position. Especially avoids a costly stream // clone when seeking on a streamed voice. - if( getPosition() == sample ) + if(getTimeIndex() == sample ) return; if( !mBuffer->isStreaming() ) @@ -386,7 +386,7 @@ void SFXVoice::_resetStream( U32 sampleStartPos, bool triggerUpdate ) return; } - sfxPositionable->setPosition( sampleStartPos * sfxStream->getFormat().getBytesPerSample() ); + sfxPositionable->setTimeIndex( sampleStartPos * sfxStream->getFormat().getBytesPerSample() ); ThreadSafeRef< SFXInternal::SFXAsyncStream > newStream = new SFXInternal::SFXAsyncStream diff --git a/Engine/source/sfx/sfxVoice.h b/Engine/source/sfx/sfxVoice.h index 74e40293e8..5751d0bd4b 100644 --- a/Engine/source/sfx/sfxVoice.h +++ b/Engine/source/sfx/sfxVoice.h @@ -156,14 +156,14 @@ class SFXVoice : public StrongRefBase, /// /// @note For looping sounds, this will return the position in the /// current cycle and not the total number of samples played so far. - U32 getPosition() const override; + U32 getTimeIndex() const override; /// Sets the playback position to the given sample count. /// /// @param sample Offset in number of samples. This is allowed to use an offset /// accumulated from multiple cycles. Each cycle will wrap around back to the /// beginning of the buffer. - void setPosition( U32 sample ) override; + void setTimeIndex( U32 sample ) override; /// @return the current playback status. /// @note For streaming voices, the reaction to for the voice to update its status diff --git a/Engine/source/util/interpolatedChangeProperty.h b/Engine/source/util/interpolatedChangeProperty.h index 120563c9e5..a09fdb3201 100644 --- a/Engine/source/util/interpolatedChangeProperty.h +++ b/Engine/source/util/interpolatedChangeProperty.h @@ -154,7 +154,7 @@ void InterpolatedChangeProperty< T, TimeSource >::setTargetValue( const T& value mSourceValue = getCurrentValue(); mTargetValue = value; - mTransitionStartTime = mTimeSource.getPosition(); + mTransitionStartTime = mTimeSource.getTimeIndex(); } } @@ -170,7 +170,7 @@ void InterpolatedChangeProperty< T, TimeSource >::_update() const // See if we have finished the transition. - TimeType deltaTime = mTimeSource.getPosition() - mTransitionStartTime; + TimeType deltaTime = mTimeSource.getTimeIndex() - mTransitionStartTime; if( deltaTime >= mBlendPhaseTime ) { // We're done.