aboutsummaryrefslogtreecommitdiffstats
path: root/al/auxeffectslot.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-02-07 08:47:55 -0800
committerChris Robinson <[email protected]>2022-02-07 08:47:55 -0800
commitb09aab8426b0feb74cacb8704b4953b3b56a8c30 (patch)
tree3ebbf942a85bacd4ac6e1f2314774ccf448c4b9b /al/auxeffectslot.cpp
parent4f7799f1aecc3eadaaea8e770797124f85aac5e4 (diff)
Don't pass an ALeffect to ALeffectslot::initEffect
Diffstat (limited to 'al/auxeffectslot.cpp')
-rw-r--r--al/auxeffectslot.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index 06e6b7a3..e0f2be73 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -582,9 +582,14 @@ START_API_FUNC
{
std::lock_guard<std::mutex> ___{device->EffectLock};
ALeffect *effect{value ? LookupEffect(device, static_cast<ALuint>(value)) : nullptr};
- if(!(value == 0 || effect != nullptr))
- SETERR_RETURN(context, AL_INVALID_VALUE,, "Invalid effect ID %u", value);
- err = slot->initEffect(effect, context.get());
+ if(effect)
+ err = slot->initEffect(effect->type, effect->Props, context.get());
+ else
+ {
+ if(value != 0)
+ SETERR_RETURN(context, AL_INVALID_VALUE,, "Invalid effect ID %u", value);
+ err = slot->initEffect(AL_EFFECT_NULL, EffectProps{}, context.get());
+ }
}
if UNLIKELY(err != AL_NO_ERROR)
{
@@ -939,9 +944,10 @@ ALeffectslot::~ALeffectslot()
mSlot.mEffectState->release();
}
-ALenum ALeffectslot::initEffect(ALeffect *effect, ALCcontext *context)
+ALenum ALeffectslot::initEffect(ALenum effectType, const EffectProps &effectProps,
+ ALCcontext *context)
{
- EffectSlotType newtype{EffectSlotTypeFromEnum(effect ? effect->type : AL_EFFECT_NULL)};
+ EffectSlotType newtype{EffectSlotTypeFromEnum(effectType)};
if(newtype != Effect.Type)
{
EffectStateFactory *factory{getFactoryByType(newtype)};
@@ -961,12 +967,12 @@ ALenum ALeffectslot::initEffect(ALeffect *effect, ALCcontext *context)
}
Effect.Type = newtype;
- Effect.Props = effect ? effect->Props : EffectProps{};
+ Effect.Props = effectProps;
Effect.State = std::move(state);
}
- else if(effect)
- Effect.Props = effect->Props;
+ else if(newtype != EffectSlotType::None)
+ Effect.Props = effectProps;
/* Remove state references from old effect slot property updates. */
EffectSlotProps *props{context->mFreeEffectslotProps.load()};
@@ -1726,8 +1732,7 @@ void ALeffectslot::eax_set_effect_slot_effect(
std::lock_guard<std::mutex> effect_slot_lock{eax_al_context_->mEffectSlotLock};
std::lock_guard<std::mutex> effect_lock{device.EffectLock};
- const auto error = initEffect(&effect, eax_al_context_);
-
+ const auto error = initEffect(effect.type, effect.Props, eax_al_context_);
if (error != AL_NO_ERROR)
{
ERR(EAX_PREFIX "%s\n", "Failed to initialize an effect.");