aboutsummaryrefslogtreecommitdiffstats
path: root/al/auxeffectslot.cpp
diff options
context:
space:
mode:
authorBoris I. Bendovsky <[email protected]>2022-02-08 18:20:46 +0200
committerGitHub <[email protected]>2022-02-08 08:20:46 -0800
commitd42077680890fee9e8f150e99bc259435bbe5d44 (patch)
tree0606b99eba2a09c18a8b82a2b5aafe11557eba91 /al/auxeffectslot.cpp
parentf23c7fe8ba77d4d406d37c60501f961313db7d1a (diff)
EAX various fixes (#657)
* [EAX] Fix effect GUID validation Only NULL and REVERB was valid. * [EAX] Fix default FX slot flags EAX4 and EAX5 both sets to ENVIRONMENT. * [EAX] Set default values for legacy FX slots in the initialization * [EAX] Fix FX slot locking policy Fail on attempt to load an effect or change a lock for EAX4 "set" call. Unlock legacy FX slots on any EAX5 call. * [EAX] Allow DEFER flag for "get" calls. * [EAX] Make speaker configuration read-only * [EAX] Initialize speaker configuration * [EAX] Commit EAX source on a 3D source parameter call Reference: EAX 4.0 Programmer's Guide * [EAX] Commit EAX source on a 3D listener parameter call Reference: EAX 4.0 Programmer's Guide * [EAX] Commit source when it begins to play Reference: EAX 4.0 Programmer's Guide
Diffstat (limited to 'al/auxeffectslot.cpp')
-rw-r--r--al/auxeffectslot.cpp99
1 files changed, 52 insertions, 47 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index 5ddd2a28..d0487925 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -1087,8 +1087,8 @@ void ALeffectslot::eax_initialize(
eax_fx_slot_index_ = index;
eax_initialize_eax();
+ eax_initialize_lock();
eax_initialize_effects();
- eax_set_default_slots_defaults();
}
const EAX50FXSLOTPROPERTIES& ALeffectslot::eax_get_eax_fx_slot() const noexcept
@@ -1096,11 +1096,30 @@ const EAX50FXSLOTPROPERTIES& ALeffectslot::eax_get_eax_fx_slot() const noexcept
return eax_eax_fx_slot_;
}
+void ALeffectslot::eax_ensure_is_unlocked() const
+{
+ if (eax_is_locked_)
+ eax_fail("Locked.");
+}
+
void ALeffectslot::eax_validate_fx_slot_effect(
const GUID& eax_effect_id)
{
+ eax_ensure_is_unlocked();
+
if (eax_effect_id != EAX_NULL_GUID &&
- eax_effect_id != EAX_REVERB_EFFECT)
+ eax_effect_id != EAX_REVERB_EFFECT &&
+ eax_effect_id != EAX_AGCCOMPRESSOR_EFFECT &&
+ eax_effect_id != EAX_AUTOWAH_EFFECT &&
+ eax_effect_id != EAX_CHORUS_EFFECT &&
+ eax_effect_id != EAX_DISTORTION_EFFECT &&
+ eax_effect_id != EAX_ECHO_EFFECT &&
+ eax_effect_id != EAX_EQUALIZER_EFFECT &&
+ eax_effect_id != EAX_FLANGER_EFFECT &&
+ eax_effect_id != EAX_FREQUENCYSHIFTER_EFFECT &&
+ eax_effect_id != EAX_VOCALMORPHER_EFFECT &&
+ eax_effect_id != EAX_PITCHSHIFTER_EFFECT &&
+ eax_effect_id != EAX_RINGMODULATOR_EFFECT)
{
eax_fail("Unsupported EAX effect GUID.");
}
@@ -1119,6 +1138,8 @@ void ALeffectslot::eax_validate_fx_slot_volume(
void ALeffectslot::eax_validate_fx_slot_lock(
long eax_lock)
{
+ eax_ensure_is_unlocked();
+
eax_validate_range<EaxFxSlotException>(
"Lock",
eax_lock,
@@ -1126,16 +1147,6 @@ void ALeffectslot::eax_validate_fx_slot_lock(
EAXFXSLOT_MAXLOCK);
}
-void ALeffectslot::eax_validate_fx_slot_lock_state(
- long eax_lock,
- const GUID& eax_effect_id)
-{
- if (eax_lock == EAXFXSLOT_LOCKED && eax_effect_id != eax_eax_fx_slot_.guidLoadEffect)
- {
- eax_fail("Loading an effect in a locked slot.");
- }
-}
-
void ALeffectslot::eax_validate_fx_slot_flags(
unsigned long eax_flags,
int eax_version)
@@ -1293,6 +1304,13 @@ bool ALeffectslot::eax_dispatch(
return eax_call.is_get() ? eax_get(eax_call) : eax_set(eax_call);
}
+void ALeffectslot::eax_unlock_legacy() noexcept
+{
+ assert(eax_fx_slot_index_ < 2);
+ eax_is_locked_ = false;
+ eax_eax_fx_slot_.lLock = EAXFXSLOT_UNLOCKED;
+}
+
[[noreturn]]
void ALeffectslot::eax_fail(
const char* message)
@@ -1300,55 +1318,44 @@ void ALeffectslot::eax_fail(
throw EaxFxSlotException{message};
}
-void ALeffectslot::eax_set_eax_fx_slot_defaults()
+GUID ALeffectslot::eax_get_eax_default_effect_guid() const noexcept
{
- eax_eax_fx_slot_.guidLoadEffect = EAX_NULL_GUID;
- eax_eax_fx_slot_.lVolume = EAXFXSLOT_DEFAULTVOLUME;
- eax_eax_fx_slot_.lLock = EAXFXSLOT_UNLOCKED;
- eax_eax_fx_slot_.ulFlags = EAX50FXSLOT_DEFAULTFLAGS;
- eax_eax_fx_slot_.lOcclusion = EAXFXSLOT_DEFAULTOCCLUSION;
- eax_eax_fx_slot_.flOcclusionLFRatio = EAXFXSLOT_DEFAULTOCCLUSIONLFRATIO;
+ switch (eax_fx_slot_index_)
+ {
+ case 0: return EAX_REVERB_EFFECT;
+ case 1: return EAX_CHORUS_EFFECT;
+ default: return EAX_NULL_GUID;
+ }
}
-void ALeffectslot::eax_initialize_eax()
+unsigned long ALeffectslot::eax_get_eax_default_lock() const noexcept
{
- eax_set_eax_fx_slot_defaults();
+ return eax_fx_slot_index_ < 2 ? EAXFXSLOT_LOCKED : EAXFXSLOT_UNLOCKED;
}
-void ALeffectslot::eax_initialize_effects()
+void ALeffectslot::eax_set_eax_fx_slot_defaults()
{
- eax_set_fx_slot_effect();
+ eax_eax_fx_slot_.guidLoadEffect = eax_get_eax_default_effect_guid();
+ eax_eax_fx_slot_.lVolume = EAXFXSLOT_DEFAULTVOLUME;
+ eax_eax_fx_slot_.lLock = eax_get_eax_default_lock();
+ eax_eax_fx_slot_.ulFlags = EAX40FXSLOT_DEFAULTFLAGS;
+ eax_eax_fx_slot_.lOcclusion = EAXFXSLOT_DEFAULTOCCLUSION;
+ eax_eax_fx_slot_.flOcclusionLFRatio = EAXFXSLOT_DEFAULTOCCLUSIONLFRATIO;
}
-void ALeffectslot::eax_set_default_slot_0_defaults()
+void ALeffectslot::eax_initialize_eax()
{
- eax_set_fx_slot_effect(EAX_REVERB_EFFECT);
+ eax_set_eax_fx_slot_defaults();
}
-void ALeffectslot::eax_set_default_slot_1_defaults()
+void ALeffectslot::eax_initialize_lock()
{
- eax_set_fx_slot_effect(EAX_CHORUS_EFFECT);
+ eax_is_locked_ = (eax_fx_slot_index_ < 2);
}
-void ALeffectslot::eax_set_default_slots_defaults()
+void ALeffectslot::eax_initialize_effects()
{
- switch (eax_fx_slot_index_)
- {
- case 0:
- eax_set_default_slot_0_defaults();
- break;
-
- case 1:
- eax_set_default_slot_1_defaults();
- break;
-
- case 2:
- case 3:
- break;
-
- default:
- eax_fail("FX slot index out of range.");
- }
+ eax_set_fx_slot_effect();
}
void ALeffectslot::eax_get_fx_slot_all(
@@ -1540,8 +1547,6 @@ void ALeffectslot::eax_set_fx_slot_effect(
eax_call.get_value<EaxFxSlotException, const decltype(EAX40FXSLOTPROPERTIES::guidLoadEffect)>();
eax_validate_fx_slot_effect(eax_effect_id);
- eax_validate_fx_slot_lock_state(eax_eax_fx_slot_.lLock, eax_effect_id);
-
eax_set_fx_slot_effect(eax_effect_id);
}