revert to using the stock mac framework, and encapsulate nonstandard openal extensions usage under a set of #if defined(AL_ALEXT_PROTOTYPES) blocks

This commit is contained in:
Brian Roberts 2019-05-24 11:11:09 -05:00
parent c0c8ecf521
commit 518cd593b2
6 changed files with 33 additions and 17 deletions

View file

@ -28,11 +28,9 @@
#endif
#if defined(TORQUE_OS_MAC)
# include <AL/al.h>
# include <AL/alc.h>
# include <AL/alext.h>
# include <AL/efx.h>
# include <AL/efx-presets.h>
//#define AL_ALEXT_PROTOTYPES true
# include <OpenAL/al.h>
# include <OpenAL/alc.h>
#elif defined(TORQUE_OS_LINUX)
# include <AL/al.h>
# include <AL/alc.h>
@ -237,6 +235,8 @@ typedef struct
LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
LPALCGETPROCADDRESS alcGetProcAddress;
LPALCGETENUMVALUE alcGetEnumValue;
#if defined(AL_ALEXT_PROTOTYPES)
LPALGENEFFECTS alGenEffects;
LPALDELETEEFFECTS alDeleteEffects;
LPALISEFFECT alIsEffect;
@ -260,6 +260,7 @@ typedef struct
LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv;
LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf;
LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv;
#endif
} OPENALFNTABLE, *LPOPENALFNTABLE;
#endif

View file

@ -434,7 +434,7 @@ ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable
warn("Failed to retrieve 'alcGetEnumValue' function address\n");
return AL_FALSE;
}
#if defined(AL_ALEXT_PROTOTYPES)
//efx
lpOALFnTable->alGenEffects = (LPALGENEFFECTS)alGenEffects;
if (lpOALFnTable->alGenEffects == NULL)
@ -574,7 +574,7 @@ ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable
warn("Failed to retrieve 'alSource3i' function address\n");
return AL_FALSE;
}
#endif
return AL_TRUE;
}

View file

@ -44,8 +44,10 @@ SFXALDevice::SFXALDevice( SFXProvider *provider,
// $pref::SFX::frequency or $pref::SFX::bitrate!
//check auxiliary device sends 4 and add them to the device
ALint attribs[4] = { 0 };
#if defined(AL_ALEXT_PROTOTYPES)
ALCint iSends = 0;
attribs[0] = ALC_MAX_AUXILIARY_SENDS;
#endif
attribs[1] = 4;
mDevice = mOpenAL.alcOpenDevice( name );
@ -56,8 +58,10 @@ SFXALDevice::SFXALDevice( SFXProvider *provider,
if( mContext )
mOpenAL.alcMakeContextCurrent( mContext );
mOpenAL.alcGetIntegerv(mDevice, ALC_MAX_AUXILIARY_SENDS, 1, &iSends);
U32 err = mOpenAL.alcGetError( mDevice );
#if defined(AL_ALEXT_PROTOTYPES)
mOpenAL.alcGetIntegerv(mDevice, ALC_MAX_AUXILIARY_SENDS, 1, &iSends);
#endif
U32 err = mOpenAL.alcGetError( mDevice );
if( err != ALC_NO_ERROR )
Con::errorf( "SFXALDevice - Initialization Error: %s", mOpenAL.alcGetString( mDevice, err ) );
@ -84,8 +88,10 @@ SFXALDevice::~SFXALDevice()
{
_releaseAllResources();
///cleanup our effects
#if defined(AL_ALEXT_PROTOTYPES)
mOpenAL.alDeleteAuxiliaryEffectSlots(4, effectSlot);
mOpenAL.alDeleteEffects(2, effect);
#endif
///cleanup of effects ends
mOpenAL.alcMakeContextCurrent( NULL );
mOpenAL.alcDestroyContext( mContext );
@ -155,7 +161,9 @@ void SFXALDevice::setListener( U32 index, const SFXListenerProperties& listener
mOpenAL.alListenerfv( AL_ORIENTATION, (const F32 *)&tupple[0] );
///Pass a unit size to openal, 1.0 assumes 1 meter to 1 game unit.
///Crucial for air absorbtion calculations.
#if defined(AL_ALEXT_PROTOTYPES)
mOpenAL.alListenerf(AL_METERS_PER_UNIT, 1.0f);
#endif
}
//-----------------------------------------------------------------------------
@ -218,6 +226,7 @@ void SFXALDevice::setRolloffFactor( F32 factor )
mUserRolloffFactor = factor;
}
#if defined(AL_ALEXT_PROTOTYPES)
void SFXALDevice::openSlots()
{
for (uLoop = 0; uLoop < 4; uLoop++)
@ -322,4 +331,5 @@ void SFXALDevice::setReverb(const SFXReverbProperties& reverb)
}
}
}
#endif

View file

@ -85,6 +85,7 @@ class SFXALDevice : public SFXDevice
virtual void setDistanceModel( SFXDistanceModel model );
virtual void setDopplerFactor( F32 factor );
virtual void setRolloffFactor( F32 factor );
#if defined(AL_ALEXT_PROTOTYPES)
//function for openAL to open slots
virtual void openSlots();
//slots
@ -93,7 +94,8 @@ class SFXALDevice : public SFXDevice
ALuint uLoop;
//get values from sfxreverbproperties and pass it to openal device
virtual void setReverb(const SFXReverbProperties& reverb);
#endif
virtual void resetReverb() {}
};
#endif // _SFXALDEVICE_H_
#endif // _SFXALDEVICE_H_

View file

@ -118,8 +118,10 @@ void SFXALVoice::_play()
#ifdef DEBUG_SPEW
Platform::outputDebugString( "[SFXALVoice] Starting playback" );
#endif
#if defined(AL_ALEXT_PROTOTYPES)
//send every voice that plays to the alauxiliary slot that has the reverb
mOpenAL.alSource3i(mSourceName, AL_AUXILIARY_SEND_FILTER, 1, 0, AL_FILTER_NULL);
#endif
mOpenAL.alSourcePlay( mSourceName );
//WORKAROUND: Adjust play cursor for buggy OAL when resuming playback. Do this after alSourcePlay

View file

@ -61,9 +61,8 @@ mark_as_advanced(TORQUE_BASIC_LIGHTING)
option(TORQUE_SFX_DirectX "DirectX Sound" OFF)
mark_as_advanced(TORQUE_SFX_DirectX)
option(TORQUE_SFX_OPENAL "OpenAL Sound" ON)
if(TORQUE_SFX_OPENAL)
#windows uses openal-soft
if(WIN32)
#disable a few things that are not required
set(ALSOFT_TESTS OFF CACHE BOOL "Build and install test programs" FORCE)
set(ALSOFT_UTILS OFF CACHE BOOL "Build and install utility programs" FORCE)
@ -73,14 +72,15 @@ if(TORQUE_SFX_OPENAL)
set(ALSOFT_NO_CONFIG_UTIL OFF CACHE BOOL "Disable building the alsoft-config utility" FORCE)
set(ALSOFT_HRTF_DEFS OFF CACHE BOOL "Install HRTF definition files" FORCE)
set(ALSOFT_AMBDEC_PRESETS OFF CACHE BOOL "Install AmbDec presets" FORCE)
add_subdirectory( ${libDir}/openal-soft ${CMAKE_CURRENT_BINARY_DIR}/openal-soft)
endif()
if(TORQUE_SFX_OPENAL)
#Hide some unnecessary fields as advanced
mark_as_advanced(ALSOFT_AMBDEC_PRESETS)
mark_as_advanced(ALSOFT_BACKEND_DSOUND)
mark_as_advanced(ALSOFT_BACKEND_MMDEVAPI)
mark_as_advanced(ALSOFT_BUILD_ROUTER)
mark_as_advanced(ALSOFT_BACKEND_WAVE)
mark_as_advanced(ALSOFT_BACKEND_WINMM)
mark_as_advanced(ALSOFT_CONFIG)
@ -316,6 +316,7 @@ addPath("${srcDir}/scene")
addPath("${srcDir}/scene/culling")
addPath("${srcDir}/scene/zones")
addPath("${srcDir}/scene/mixin")
addPath("${srcDir}/shaderGen")
addPath("${srcDir}/terrain")
addPath("${srcDir}/environment")
addPath("${srcDir}/forest")
@ -401,7 +402,7 @@ if(TORQUE_SFX_OPENAL AND NOT TORQUE_DEDICATED)
endif()
if(APPLE)
addPath("${srcDir}/sfx/openal/mac")
addInclude("${libDir}/openal-soft/include")
addFramework("OpenAL")
endif()
endif()