diff options
author | Chris Robinson <[email protected]> | 2022-02-07 08:47:55 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-02-07 08:47:55 -0800 |
commit | b09aab8426b0feb74cacb8704b4953b3b56a8c30 (patch) | |
tree | 3ebbf942a85bacd4ac6e1f2314774ccf448c4b9b | |
parent | 4f7799f1aecc3eadaaea8e770797124f85aac5e4 (diff) |
Don't pass an ALeffect to ALeffectslot::initEffect
-rw-r--r-- | al/auxeffectslot.cpp | 25 | ||||
-rw-r--r-- | al/auxeffectslot.h | 2 | ||||
-rw-r--r-- | alc/alc.cpp | 4 |
3 files changed, 19 insertions, 12 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."); diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h index 12213df6..2c462cd0 100644 --- a/al/auxeffectslot.h +++ b/al/auxeffectslot.h @@ -65,7 +65,7 @@ struct ALeffectslot { ALeffectslot& operator=(const ALeffectslot&) = delete; ~ALeffectslot(); - ALenum initEffect(ALeffect *effect, ALCcontext *context); + ALenum initEffect(ALenum effectType, const EffectProps &effectProps, ALCcontext *context); void updateProps(ALCcontext *context); /* This can be new'd for the context's default effect slot. */ diff --git a/alc/alc.cpp b/alc/alc.cpp index 4effcc67..3af6f8ec 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -3052,7 +3052,9 @@ START_API_FUNC if(ALeffectslot *slot{context->mDefaultSlot.get()}) { - if(slot->initEffect(&ALCcontext::sDefaultEffect, context.get()) == AL_NO_ERROR) + ALenum sloterr{slot->initEffect(ALCcontext::sDefaultEffect.type, + ALCcontext::sDefaultEffect.Props, context.get())}; + if(sloterr == AL_NO_ERROR) slot->updateProps(context.get()); else ERR("Failed to initialize the default effect\n"); |