aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alAuxEffectSlot.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-24 15:52:37 -0800
committerChris Robinson <[email protected]>2018-12-24 15:52:37 -0800
commit194e7ff815d744830c8aaedfb0d32ed3c3d01645 (patch)
tree525e8a90f7f0a1c9266b1a87fec0c04a74d61889 /OpenAL32/alAuxEffectSlot.cpp
parentbbf9e6931cf607da49bb5a541e86f9760ea68047 (diff)
Add an in-progress extension to set the effect slot target
Diffstat (limited to 'OpenAL32/alAuxEffectSlot.cpp')
-rw-r--r--OpenAL32/alAuxEffectSlot.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/OpenAL32/alAuxEffectSlot.cpp b/OpenAL32/alAuxEffectSlot.cpp
index 4add1668..b91774dc 100644
--- a/OpenAL32/alAuxEffectSlot.cpp
+++ b/OpenAL32/alAuxEffectSlot.cpp
@@ -295,6 +295,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param
if(UNLIKELY(!slot))
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
+ ALeffectslot *target{};
ALCdevice *device{};
ALenum err{};
switch(param)
@@ -322,6 +323,37 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param
slot->AuxSendAuto = value;
break;
+ case AL_EFFECTSLOT_TARGET_SOFT:
+ target = (value ? LookupEffectSlot(context.get(), value) : nullptr);
+ if(value && !target)
+ SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "Invalid effect slot target ID");
+ if(target)
+ {
+ ALeffectslot *checker{target};
+ while(checker && checker != slot)
+ checker = checker->Target;
+ if(checker)
+ SETERR_RETURN(context.get(), AL_INVALID_OPERATION,,
+ "Setting target of effect slot ID %u to %u creates circular chain", slot->id,
+ target->id);
+ }
+
+ if(ALeffectslot *oldtarget{slot->Target})
+ {
+ /* We must force an update if there was an existing effect slot
+ * target, in case it's about to be deleted.
+ */
+ if(target) IncrementRef(&target->ref);
+ DecrementRef(&oldtarget->ref);
+ slot->Target = target;
+ UpdateEffectSlotProps(slot, context.get());
+ return;
+ }
+
+ if(target) IncrementRef(&target->ref);
+ slot->Target = target;
+ break;
+
default:
SETERR_RETURN(context.get(), AL_INVALID_ENUM,,
"Invalid effect slot integer property 0x%04x", param);
@@ -335,6 +367,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum para
{
case AL_EFFECTSLOT_EFFECT:
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
+ case AL_EFFECTSLOT_TARGET_SOFT:
alAuxiliaryEffectSloti(effectslot, param, values[0]);
return;
}
@@ -422,6 +455,10 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum pa
*value = slot->AuxSendAuto;
break;
+ case AL_EFFECTSLOT_TARGET_SOFT:
+ *value = slot->Target ? slot->Target->id : 0;
+ break;
+
default:
SETERR_RETURN(context.get(), AL_INVALID_ENUM,,
"Invalid effect slot integer property 0x%04x", param);
@@ -434,6 +471,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum p
{
case AL_EFFECTSLOT_EFFECT:
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
+ case AL_EFFECTSLOT_TARGET_SOFT:
alGetAuxiliaryEffectSloti(effectslot, param, values);
return;
}