Don't pass an ALeffect to ALeffectslot::initEffect
This commit is contained in:
parent
4f7799f1ae
commit
b09aab8426
@ -582,9 +582,14 @@ START_API_FUNC
|
|||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> ___{device->EffectLock};
|
std::lock_guard<std::mutex> ___{device->EffectLock};
|
||||||
ALeffect *effect{value ? LookupEffect(device, static_cast<ALuint>(value)) : nullptr};
|
ALeffect *effect{value ? LookupEffect(device, static_cast<ALuint>(value)) : nullptr};
|
||||||
if(!(value == 0 || effect != nullptr))
|
if(effect)
|
||||||
SETERR_RETURN(context, AL_INVALID_VALUE,, "Invalid effect ID %u", value);
|
err = slot->initEffect(effect->type, effect->Props, context.get());
|
||||||
err = slot->initEffect(effect, 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)
|
if UNLIKELY(err != AL_NO_ERROR)
|
||||||
{
|
{
|
||||||
@ -939,9 +944,10 @@ ALeffectslot::~ALeffectslot()
|
|||||||
mSlot.mEffectState->release();
|
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)
|
if(newtype != Effect.Type)
|
||||||
{
|
{
|
||||||
EffectStateFactory *factory{getFactoryByType(newtype)};
|
EffectStateFactory *factory{getFactoryByType(newtype)};
|
||||||
@ -961,12 +967,12 @@ ALenum ALeffectslot::initEffect(ALeffect *effect, ALCcontext *context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Effect.Type = newtype;
|
Effect.Type = newtype;
|
||||||
Effect.Props = effect ? effect->Props : EffectProps{};
|
Effect.Props = effectProps;
|
||||||
|
|
||||||
Effect.State = std::move(state);
|
Effect.State = std::move(state);
|
||||||
}
|
}
|
||||||
else if(effect)
|
else if(newtype != EffectSlotType::None)
|
||||||
Effect.Props = effect->Props;
|
Effect.Props = effectProps;
|
||||||
|
|
||||||
/* Remove state references from old effect slot property updates. */
|
/* Remove state references from old effect slot property updates. */
|
||||||
EffectSlotProps *props{context->mFreeEffectslotProps.load()};
|
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_slot_lock{eax_al_context_->mEffectSlotLock};
|
||||||
std::lock_guard<std::mutex> effect_lock{device.EffectLock};
|
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)
|
if (error != AL_NO_ERROR)
|
||||||
{
|
{
|
||||||
ERR(EAX_PREFIX "%s\n", "Failed to initialize an effect.");
|
ERR(EAX_PREFIX "%s\n", "Failed to initialize an effect.");
|
||||||
|
@ -65,7 +65,7 @@ struct ALeffectslot {
|
|||||||
ALeffectslot& operator=(const ALeffectslot&) = delete;
|
ALeffectslot& operator=(const ALeffectslot&) = delete;
|
||||||
~ALeffectslot();
|
~ALeffectslot();
|
||||||
|
|
||||||
ALenum initEffect(ALeffect *effect, ALCcontext *context);
|
ALenum initEffect(ALenum effectType, const EffectProps &effectProps, ALCcontext *context);
|
||||||
void updateProps(ALCcontext *context);
|
void updateProps(ALCcontext *context);
|
||||||
|
|
||||||
/* This can be new'd for the context's default effect slot. */
|
/* This can be new'd for the context's default effect slot. */
|
||||||
|
@ -3052,7 +3052,9 @@ START_API_FUNC
|
|||||||
|
|
||||||
if(ALeffectslot *slot{context->mDefaultSlot.get()})
|
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());
|
slot->updateProps(context.get());
|
||||||
else
|
else
|
||||||
ERR("Failed to initialize the default effect\n");
|
ERR("Failed to initialize the default effect\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user