forked from Mirrors/openclonk
MSVC/Apple CMake: Search for alext.h separately and make OpenAL extensions optional if only al.h is found.
parent
6ad8471101
commit
bc2259d197
|
@ -14,6 +14,7 @@
|
||||||
# This module chooses an audio provider for use in OpenClonk.
|
# This module chooses an audio provider for use in OpenClonk.
|
||||||
|
|
||||||
macro(__FINDAUDIO_FINDOPENAL)
|
macro(__FINDAUDIO_FINDOPENAL)
|
||||||
|
set(HAVE_ALEXT FALSE)
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
if(PKG_CONFIG_FOUND AND NOT(APPLE))
|
if(PKG_CONFIG_FOUND AND NOT(APPLE))
|
||||||
pkg_check_modules(OpenAL "openal>=1.13")
|
pkg_check_modules(OpenAL "openal>=1.13")
|
||||||
|
@ -23,6 +24,8 @@ macro(__FINDAUDIO_FINDOPENAL)
|
||||||
# of directories that pkg_check_modules returned, and if not, add it to
|
# of directories that pkg_check_modules returned, and if not, add it to
|
||||||
# the include path.
|
# the include path.
|
||||||
if (OpenAL_FOUND)
|
if (OpenAL_FOUND)
|
||||||
|
# OpenAL pkg-config data always includes alext.h
|
||||||
|
set(HAVE_ALEXT TRUE)
|
||||||
find_path(__findaudio_al_h NAMES al.h PATHS ${OpenAL_INCLUDE_DIRS})
|
find_path(__findaudio_al_h NAMES al.h PATHS ${OpenAL_INCLUDE_DIRS})
|
||||||
if (NOT __findaudio_al_h)
|
if (NOT __findaudio_al_h)
|
||||||
find_path(__findaudio_al_h NAMES al.h PATHS ${OpenAL_INCLUDE_DIRS} PATH_SUFFIXES OpenAL AL)
|
find_path(__findaudio_al_h NAMES al.h PATHS ${OpenAL_INCLUDE_DIRS} PATH_SUFFIXES OpenAL AL)
|
||||||
|
@ -37,7 +40,16 @@ macro(__FINDAUDIO_FINDOPENAL)
|
||||||
pkg_check_modules(OggVorbis "vorbisfile>=1.3.2" "vorbis>=1.3.2" "ogg>=1.2.2")
|
pkg_check_modules(OggVorbis "vorbisfile>=1.3.2" "vorbis>=1.3.2" "ogg>=1.2.2")
|
||||||
else()
|
else()
|
||||||
if(MSVC OR APPLE)
|
if(MSVC OR APPLE)
|
||||||
find_path(OpenAL_INCLUDE_DIRS al.h PATH_SUFFIXES include/AL include/OpenAL include OpenAL)
|
# We need OpenAL preferrably with alext.h.
|
||||||
|
find_path(OpenALExt_INCLUDE_DIRS alext.h PATH_SUFFIXES include/AL include/OpenAL include OpenAL)
|
||||||
|
if(OpenALExt_INCLUDE_DIRS)
|
||||||
|
set(HAVE_ALEXT TRUE)
|
||||||
|
set(OpenAL_INCLUDE_DIRS ${OpenALExt_INCLUDE_DIRS})
|
||||||
|
else()
|
||||||
|
set(HAVE_ALEXT FALSE)
|
||||||
|
# Maybe only al.h can be found without alext.h?
|
||||||
|
find_path(OpenAL_INCLUDE_DIRS al.h PATH_SUFFIXES include/AL include/OpenAL include OpenAL)
|
||||||
|
endif()
|
||||||
find_path(Vorbis_INCLUDE_DIRS vorbis/codec.h vorbis/vorbisfile.h PATH_SUFFIXES include)
|
find_path(Vorbis_INCLUDE_DIRS vorbis/codec.h vorbis/vorbisfile.h PATH_SUFFIXES include)
|
||||||
find_library(Ogg_LIBRARY NAMES libogg_static libogg ogg)
|
find_library(Ogg_LIBRARY NAMES libogg_static libogg ogg)
|
||||||
find_library(Vorbis_LIBRARY NAMES libvorbis_static libvorbis vorbis)
|
find_library(Vorbis_LIBRARY NAMES libvorbis_static libvorbis vorbis)
|
||||||
|
@ -92,6 +104,9 @@ else()
|
||||||
if(OpenAL_FOUND AND Alut_FOUND AND OggVorbis_FOUND)
|
if(OpenAL_FOUND AND Alut_FOUND AND OggVorbis_FOUND)
|
||||||
# Prefer OpenAL
|
# Prefer OpenAL
|
||||||
set(Audio_TK "OpenAL")
|
set(Audio_TK "OpenAL")
|
||||||
|
if (NOT HAVE_ALEXT)
|
||||||
|
message(STATUS "Warning: Found OpenAL but no extensions (alext.h). Sound modifiers will be disabled.")
|
||||||
|
endif()
|
||||||
elseif(SDLMixer_FOUND)
|
elseif(SDLMixer_FOUND)
|
||||||
set(Audio_TK "SDL_Mixer")
|
set(Audio_TK "SDL_Mixer")
|
||||||
elseif(FMOD_FOUND)
|
elseif(FMOD_FOUND)
|
||||||
|
|
|
@ -194,3 +194,6 @@
|
||||||
#define AUDIO_TK_FMOD 2
|
#define AUDIO_TK_FMOD 2
|
||||||
#define AUDIO_TK_SDL_MIXER 3
|
#define AUDIO_TK_SDL_MIXER 3
|
||||||
#define AUDIO_TK AUDIO_TK_${Audio_TK_UPPER}
|
#define AUDIO_TK AUDIO_TK_${Audio_TK_UPPER}
|
||||||
|
|
||||||
|
/* Include OpenAL extensions (alext.h) for sound modifiers */
|
||||||
|
#cmakedefine HAVE_ALEXT 1
|
||||||
|
|
|
@ -29,16 +29,11 @@
|
||||||
typedef struct Mix_Chunk* C4SoundHandle;
|
typedef struct Mix_Chunk* C4SoundHandle;
|
||||||
# include <SDL.h>
|
# include <SDL.h>
|
||||||
#elif AUDIO_TK == AUDIO_TK_OPENAL
|
#elif AUDIO_TK == AUDIO_TK_OPENAL
|
||||||
# ifdef __APPLE__
|
# include <al.h>
|
||||||
# include <OpenAL/al.h>
|
# include <alc.h>
|
||||||
# include <OpenAL/alc.h>
|
# ifdef HAVE_ALEXT
|
||||||
# include <OpenAL/alext.h>
|
# include <alext.h>
|
||||||
# include <OpenAL/efx-presets.h>
|
# endif
|
||||||
# else
|
|
||||||
# include <al.h>
|
|
||||||
# include <alc.h>
|
|
||||||
# include <alext.h>
|
|
||||||
# endif
|
|
||||||
typedef ALuint C4SoundHandle;
|
typedef ALuint C4SoundHandle;
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
// This is an ugly hack to make FreeALUT not dllimport everything.
|
// This is an ugly hack to make FreeALUT not dllimport everything.
|
||||||
|
|
|
@ -471,7 +471,7 @@ void C4SoundInstance::SetModifier(C4SoundModifier *new_modifier, bool is_global)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
alSource3i(iChannel, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL);
|
alSource3i(iChannel, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <C4Application.h>
|
#include <C4Application.h>
|
||||||
#include <C4Value.h>
|
#include <C4Value.h>
|
||||||
|
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
static LPALGENEFFECTS alGenEffects;
|
static LPALGENEFFECTS alGenEffects;
|
||||||
static LPALDELETEEFFECTS alDeleteEffects;
|
static LPALDELETEEFFECTS alDeleteEffects;
|
||||||
static LPALISEFFECT alIsEffect;
|
static LPALISEFFECT alIsEffect;
|
||||||
|
@ -51,13 +51,13 @@ static LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
C4SoundModifier::C4SoundModifier(C4PropList *in_props) : instance_count(0)
|
C4SoundModifier::C4SoundModifier(C4PropList *in_props) : instance_count(0)
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
, effect(0u), slot(0u)
|
, effect(0u), slot(0u)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
props.SetPropList(in_props);
|
props.SetPropList(in_props);
|
||||||
Application.SoundSystem.Modifiers.Add(this);
|
Application.SoundSystem.Modifiers.Add(this);
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
Application.MusicSystem.SelectContext();
|
Application.MusicSystem.SelectContext();
|
||||||
alGenEffects(1, &effect);
|
alGenEffects(1, &effect);
|
||||||
alGenAuxiliaryEffectSlots(1, &slot);
|
alGenAuxiliaryEffectSlots(1, &slot);
|
||||||
|
@ -66,7 +66,7 @@ C4SoundModifier::C4SoundModifier(C4PropList *in_props) : instance_count(0)
|
||||||
|
|
||||||
C4SoundModifier::~C4SoundModifier()
|
C4SoundModifier::~C4SoundModifier()
|
||||||
{
|
{
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
// failsafe effect removal
|
// failsafe effect removal
|
||||||
if (alIsEffect(effect))
|
if (alIsEffect(effect))
|
||||||
alDeleteEffects(1, &effect);
|
alDeleteEffects(1, &effect);
|
||||||
|
@ -78,7 +78,7 @@ C4SoundModifier::~C4SoundModifier()
|
||||||
|
|
||||||
void C4SoundModifier::Update()
|
void C4SoundModifier::Update()
|
||||||
{
|
{
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
// update AL effect slot
|
// update AL effect slot
|
||||||
if (slot)
|
if (slot)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +92,9 @@ void C4SoundModifier::Update()
|
||||||
void C4SoundModifier::ApplyTo(ALuint source)
|
void C4SoundModifier::ApplyTo(ALuint source)
|
||||||
{
|
{
|
||||||
// apply slot to source if valid
|
// apply slot to source if valid
|
||||||
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
if (slot) alSource3i(source, AL_AUXILIARY_SEND_FILTER, slot, 0, AL_FILTER_NULL);
|
if (slot) alSource3i(source, AL_AUXILIARY_SEND_FILTER, slot, 0, AL_FILTER_NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
float C4SoundModifier::GetFloatProp(C4PropertyName key, float ratio, float default_value)
|
float C4SoundModifier::GetFloatProp(C4PropertyName key, float ratio, float default_value)
|
||||||
|
@ -112,14 +114,14 @@ bool C4SoundModifier::GetBoolProp(C4PropertyName key, bool default_value)
|
||||||
C4SoundModifierReverb::C4SoundModifierReverb(C4PropList *in_props)
|
C4SoundModifierReverb::C4SoundModifierReverb(C4PropList *in_props)
|
||||||
: C4SoundModifier(in_props)
|
: C4SoundModifier(in_props)
|
||||||
{
|
{
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB);
|
alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4SoundModifierReverb::Update()
|
void C4SoundModifierReverb::Update()
|
||||||
{
|
{
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
// use the cave preset as default for the reverb modifier
|
// use the cave preset as default for the reverb modifier
|
||||||
Application.MusicSystem.SelectContext();
|
Application.MusicSystem.SelectContext();
|
||||||
alEffectf(effect, AL_REVERB_DENSITY, GetFloatProp(P_Reverb_Density, 1000, 1.0f));
|
alEffectf(effect, AL_REVERB_DENSITY, GetFloatProp(P_Reverb_Density, 1000, 1.0f));
|
||||||
|
@ -142,14 +144,14 @@ void C4SoundModifierReverb::Update()
|
||||||
C4SoundModifierEcho::C4SoundModifierEcho(C4PropList *in_props)
|
C4SoundModifierEcho::C4SoundModifierEcho(C4PropList *in_props)
|
||||||
: C4SoundModifier(in_props)
|
: C4SoundModifier(in_props)
|
||||||
{
|
{
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_ECHO);
|
alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_ECHO);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4SoundModifierEcho::Update()
|
void C4SoundModifierEcho::Update()
|
||||||
{
|
{
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
// use default OpenAL echo preset
|
// use default OpenAL echo preset
|
||||||
Application.MusicSystem.SelectContext();
|
Application.MusicSystem.SelectContext();
|
||||||
alEffectf(effect, AL_ECHO_DELAY, GetFloatProp(P_Echo_Delay, 1000, 0.1f));
|
alEffectf(effect, AL_ECHO_DELAY, GetFloatProp(P_Echo_Delay, 1000, 0.1f));
|
||||||
|
@ -164,14 +166,14 @@ void C4SoundModifierEcho::Update()
|
||||||
C4SoundModifierEqualizer::C4SoundModifierEqualizer(C4PropList *in_props)
|
C4SoundModifierEqualizer::C4SoundModifierEqualizer(C4PropList *in_props)
|
||||||
: C4SoundModifier(in_props)
|
: C4SoundModifier(in_props)
|
||||||
{
|
{
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_EQUALIZER);
|
alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_EQUALIZER);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4SoundModifierEqualizer::Update()
|
void C4SoundModifierEqualizer::Update()
|
||||||
{
|
{
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
// use default OpenAL equalizer preset
|
// use default OpenAL equalizer preset
|
||||||
Application.MusicSystem.SelectContext();
|
Application.MusicSystem.SelectContext();
|
||||||
alEffectf(effect, AL_EQUALIZER_LOW_GAIN, GetFloatProp(P_Equalizer_Low_Gain, 1000, 1.0f));
|
alEffectf(effect, AL_EQUALIZER_LOW_GAIN, GetFloatProp(P_Equalizer_Low_Gain, 1000, 1.0f));
|
||||||
|
@ -197,7 +199,7 @@ C4SoundModifierList::C4SoundModifierList()
|
||||||
void C4SoundModifierList::Init()
|
void C4SoundModifierList::Init()
|
||||||
{
|
{
|
||||||
is_initialized = false;
|
is_initialized = false;
|
||||||
#if AUDIO_TK == AUDIO_TK_OPENAL
|
#if (AUDIO_TK == AUDIO_TK_OPENAL) && defined(HAVE_ALEXT)
|
||||||
#define LOAD_ALPROC(x) ((void *&)(x) = alGetProcAddress(#x))
|
#define LOAD_ALPROC(x) ((void *&)(x) = alGetProcAddress(#x))
|
||||||
Application.MusicSystem.SelectContext();
|
Application.MusicSystem.SelectContext();
|
||||||
if (!alcIsExtensionPresent(Application.MusicSystem.GetDevice(), "ALC_EXT_EFX"))
|
if (!alcIsExtensionPresent(Application.MusicSystem.GetDevice(), "ALC_EXT_EFX"))
|
||||||
|
|
Loading…
Reference in New Issue