From 5b1e20f28c72b82074a9461d03d38e45d2f08d7d Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Mon, 29 Aug 2022 18:04:55 +0100 Subject: [PATCH] OpenAL Mac Cleanup print functions cos mac hates them. All these functions did was print what was capable on openal anyway end user doesn't really get any benefit from this. Will save these for the refactor. --- Engine/source/sfx/openal/LoadOAL.h | 5 +- Engine/source/sfx/openal/aldlist.cpp | 14 +- Engine/source/sfx/openal/sfxALDevice.cpp | 155 +---------------------- 3 files changed, 15 insertions(+), 159 deletions(-) diff --git a/Engine/source/sfx/openal/LoadOAL.h b/Engine/source/sfx/openal/LoadOAL.h index 01455797a..85493c082 100644 --- a/Engine/source/sfx/openal/LoadOAL.h +++ b/Engine/source/sfx/openal/LoadOAL.h @@ -28,7 +28,7 @@ #endif #if defined(TORQUE_OS_MAC) -//#define AL_ALEXT_PROTOTYPES true +#undef AL_ALEXT_PROTOTYPES # include # include #elif defined(TORQUE_OS_LINUX) @@ -267,12 +267,11 @@ typedef struct LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv; LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf; LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv; -#endif LPALGENFILTERS alGenFilters; LPALDELETEFILTERS alDeleteFilters; LPALFILTERI alFilteri; - LPALCGETSTRINGISOFT alcGetStringiSOFT; +#endif } OPENALFNTABLE, *LPOPENALFNTABLE; #endif diff --git a/Engine/source/sfx/openal/aldlist.cpp b/Engine/source/sfx/openal/aldlist.cpp index c9a422050..b80efd21f 100644 --- a/Engine/source/sfx/openal/aldlist.cpp +++ b/Engine/source/sfx/openal/aldlist.cpp @@ -83,17 +83,23 @@ ALDeviceList::ALDeviceList( const OPENALFNTABLE &oalft ) dMemset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO)); ALDeviceInfo.bSelected = true; dStrncpy(ALDeviceInfo.strInternalDeviceName, devices, sizeof(ALDeviceInfo.strInternalDeviceName)); - char* openFind = dStrchr(devices, '('); + char deviceExternal[256]; + dStrcpy(deviceExternal, devices, 256); + char* openFind = dStrchr(deviceExternal, '('); if (openFind) { - devices = openFind + 1; - char* closeFind = dStrchr(devices, ')'); + char* deviceName = openFind + 1; + char* closeFind = dStrchr(deviceName, ')'); if (closeFind) (*closeFind) = '\0'; - dStrncpy(ALDeviceInfo.strDeviceName, devices, sizeof(ALDeviceInfo.strDeviceName)); + dStrncpy(ALDeviceInfo.strDeviceName, deviceName, sizeof(ALDeviceInfo.strDeviceName)); } + else + { + dStrncpy(ALDeviceInfo.strDeviceName, devices, sizeof(ALDeviceInfo.strDeviceName)); + } vDeviceInfo.push_back(ALDeviceInfo); } diff --git a/Engine/source/sfx/openal/sfxALDevice.cpp b/Engine/source/sfx/openal/sfxALDevice.cpp index cab3ea99f..bd5b6f3d6 100644 --- a/Engine/source/sfx/openal/sfxALDevice.cpp +++ b/Engine/source/sfx/openal/sfxALDevice.cpp @@ -62,161 +62,13 @@ void SFXALDevice::printALInfo(ALCdevice* device) } -void SFXALDevice::printHRTFInfo(ALCdevice* device) -{ - if (mOpenAL.alcIsExtensionPresent(device, "ALC_SOFT_HRTF") == AL_FALSE) - { - Con::printf("HRTF Extensions not compatible"); - return; - } - - ALCint numHrtfs; - - mOpenAL.alcGetIntegerv(device, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &numHrtfs); - if (!numHrtfs) - Con::printf("No HRTFs Found"); - else - { - Con::printf("Available HRTFs"); - for (U32 i = 0; i < numHrtfs; ++i) - { - const ALCchar* name = mOpenAL.alcGetStringiSOFT(device, ALC_HRTF_SPECIFIER_SOFT, i); - printf(" %s", name); - } - } - - U32 err = mOpenAL.alcGetError(device); - if (err != ALC_NO_ERROR) - Con::errorf("SFXALDevice - Error Retrieving HRTF info: %s", mOpenAL.alcGetString(device, err)); - -} - -void SFXALDevice::getEFXInfo(ALCdevice *device) -{ - static const ALint filters[] = { - AL_FILTER_LOWPASS, AL_FILTER_HIGHPASS, AL_FILTER_BANDPASS, - AL_FILTER_NULL - }; - - char filterNames[] = "Low-pass,High-pass,Band-pass,"; - static const ALint effects[] = { - AL_EFFECT_EAXREVERB, AL_EFFECT_REVERB, AL_EFFECT_CHORUS, - AL_EFFECT_DISTORTION, AL_EFFECT_ECHO, AL_EFFECT_FLANGER, - AL_EFFECT_FREQUENCY_SHIFTER, AL_EFFECT_VOCAL_MORPHER, - AL_EFFECT_PITCH_SHIFTER, AL_EFFECT_RING_MODULATOR, - AL_EFFECT_AUTOWAH, AL_EFFECT_COMPRESSOR, AL_EFFECT_EQUALIZER, - AL_EFFECT_NULL - }; - static const ALint dedeffects[] = { - AL_EFFECT_DEDICATED_DIALOGUE, AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT, - AL_EFFECT_NULL - }; - char effectNames[] = "EAX Reverb,Reverb,Chorus,Distortion,Echo,Flanger," - "Frequency Shifter,Vocal Morpher,Pitch Shifter,Ring Modulator,Autowah," - "Compressor,Equalizer,Dedicated Dialog,Dedicated LFE,"; - - ALCint major, minor, sends; - ALuint obj; - - char* current; - U32 i; - - if (mOpenAL.alcIsExtensionPresent(device, "ALC_EXT_EFX") == AL_FALSE) - { - Con::printf("SFXALDevice - EFX Not available."); - return; - } - - mOpenAL.alcGetIntegerv(device, ALC_EFX_MAJOR_VERSION, 1, &major); - mOpenAL.alcGetIntegerv(device, ALC_EFX_MINOR_VERSION, 1, &minor); - U32 err = mOpenAL.alcGetError(device); - if (err != ALC_NO_ERROR) - Con::errorf("SFXALDevice - Error Retrieving EFX Version: %s", mOpenAL.alcGetString(device, err)); - else - { - Con::printf("| EFX Version: %d.%d", major, minor); - } - - mOpenAL.alcGetIntegerv(device, ALC_MAX_AUXILIARY_SENDS, 1, &sends); - err = mOpenAL.alcGetError(device); - if (err != ALC_NO_ERROR) - Con::errorf("SFXALDevice - Error Retrieving Auxiliary Sends: %s", mOpenAL.alcGetString(device, err)); - else - { - Con::printf("| Max Aux Sends: %d", sends); - } - - mOpenAL.alGenFilters(1, &obj); - err = mOpenAL.alcGetError(device); - if (err != ALC_NO_ERROR) - Con::errorf("SFXALDevice - Error Generating filter: %s", mOpenAL.alcGetString(device, err)); - - current = filterNames; - for (i = 0; filters[i] != AL_FILTER_NULL; i++) - { - char* next = dStrchr(current, ','); - - mOpenAL.alFilteri(obj, AL_FILTER_TYPE, filters[i]); - if (mOpenAL.alGetError() != AL_NO_ERROR) - dMemmove(current, next + 1, strlen(next)); - else - current = next + 1; - } - - Con::printf("| Supported Filters: %s", filterNames); - - mOpenAL.alDeleteFilters(1, &obj); - - mOpenAL.alGenEffects(1, &obj); - err = mOpenAL.alcGetError(device); - if (err != ALC_NO_ERROR) - Con::errorf("SFXALDevice - Error Generating effects: %s", mOpenAL.alcGetString(device, err)); - - current = effectNames; - for (i = 0; effects[i] != AL_EFFECT_NULL; i++) - { - char* next = dStrchr(current, ','); - mOpenAL.alEffecti(obj, AL_FILTER_TYPE, effects[i]); - if (mOpenAL.alGetError() != AL_NO_ERROR) - dMemmove(current, next + 1, strlen(next)); - else - current = next + 1; - } - - if (mOpenAL.alcIsExtensionPresent(device, "ALC_EXT_DEDICATED")) - { - for (i = 0; dedeffects[i] != AL_EFFECT_NULL; i++) - { - char* next = dStrchr(current, ','); - mOpenAL.alEffecti(obj, AL_FILTER_TYPE, dedeffects[i]); - if (mOpenAL.alGetError() != AL_NO_ERROR) - dMemmove(current, next + 1, strlen(next)); - else - current = next + 1; - } - } - else - { - for (i = 0; dedeffects[i] != AL_EFFECT_NULL; i++) - { - char* next = dStrchr(current, ','); - dMemmove(current, next + 1, strlen(next)); - } - } - - Con::printf("| Supported Effects: %s", effectNames); - - mOpenAL.alDeleteEffects(1, &obj); -} - S32 SFXALDevice::getMaxSources() { - // Clear AL Error Code mOpenAL.alGetError(); - + ALCint nummono; mOpenAL.alcGetIntegerv(mDevice, ALC_MONO_SOURCES, 1, &nummono); - + return nummono; } @@ -292,8 +144,7 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, #endif printALInfo(mDevice); - printHRTFInfo(mDevice); - getEFXInfo(mDevice); + mMaxBuffers = getMaxSources();