diff options
Diffstat (limited to 'al')
-rw-r--r-- | al/auxeffectslot.cpp | 24 | ||||
-rw-r--r-- | al/auxeffectslot.h | 3 | ||||
-rw-r--r-- | al/event.cpp | 5 | ||||
-rw-r--r-- | al/event.h | 3 |
4 files changed, 9 insertions, 26 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index d9f459ba..a4e945b4 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -484,7 +484,6 @@ START_API_FUNC SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); ALeffectslot *target{}; - ALbuffer *buffer{}; ALCdevice *device{}; ALenum err{}; switch(param) @@ -552,8 +551,13 @@ START_API_FUNC case AL_BUFFER: device = context->mDevice.get(); + if(slot->mState == SlotState::Playing) + SETERR_RETURN(context, AL_INVALID_OPERATION,, + "Setting buffer on playing effect slot %u", slot->id); + { std::lock_guard<std::mutex> ___{device->BufferLock}; + ALbuffer *buffer{}; if(value) { buffer = LookupBuffer(device, static_cast<ALuint>(value)); @@ -569,13 +573,9 @@ START_API_FUNC DecrementRef(oldbuffer->ref); slot->Buffer = buffer; - slot->Effect.Buffer = nullptr; - if(buffer) - { - FPUCtl mixer_mode{}; - auto *state = slot->Effect.State.get(); - slot->Effect.Buffer.reset(state->createBuffer(device, buffer->mBuffer)); - } + FPUCtl mixer_mode{}; + auto *state = slot->Effect.State.get(); + state->setBuffer(device, buffer ? &buffer->mBuffer : nullptr); } break; @@ -819,8 +819,6 @@ ALeffectslot::~ALeffectslot() if(Params.mEffectState) Params.mEffectState->release(); - if(Params.mEffectBuffer) - Params.mEffectBuffer->release(); } ALenum ALeffectslot::init() @@ -856,9 +854,8 @@ ALenum ALeffectslot::initEffect(ALeffect *effect, ALCcontext *context) { FPUCtl mixer_mode{}; State->deviceUpdate(Device); - Effect.Buffer = nullptr; if(Buffer) - Effect.Buffer.reset(State->createBuffer(Device, Buffer->mBuffer)); + State->setBuffer(Device, &Buffer->mBuffer); } if(!effect) @@ -882,7 +879,6 @@ ALenum ALeffectslot::initEffect(ALeffect *effect, ALCcontext *context) while(props) { props->State = nullptr; - props->Buffer = nullptr; props = props->next.load(std::memory_order_relaxed); } @@ -912,7 +908,6 @@ void ALeffectslot::updateProps(ALCcontext *context) props->Type = Effect.Type; props->Props = Effect.Props; props->State = Effect.State; - props->Buffer = Effect.Buffer; /* Set the new container for updating internal parameters. */ props = Params.Update.exchange(props, std::memory_order_acq_rel); @@ -922,7 +917,6 @@ void ALeffectslot::updateProps(ALCcontext *context) * freelist. */ props->State = nullptr; - props->Buffer = nullptr; AtomicReplaceHead(context->mFreeEffectslotProps, props); } } diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h index 3977b650..fdab99ef 100644 --- a/al/auxeffectslot.h +++ b/al/auxeffectslot.h @@ -32,7 +32,6 @@ struct ALeffectslotProps { EffectProps Props; al::intrusive_ptr<EffectState> State; - al::intrusive_ptr<EffectBufferBase> Buffer; std::atomic<ALeffectslotProps*> next; @@ -57,7 +56,6 @@ struct ALeffectslot { EffectProps Props{}; al::intrusive_ptr<EffectState> State; - al::intrusive_ptr<EffectBufferBase> Buffer; } Effect; std::atomic_flag PropsClean; @@ -76,7 +74,6 @@ struct ALeffectslot { ALenum EffectType{AL_EFFECT_NULL}; EffectProps mEffectProps{}; EffectState *mEffectState{nullptr}; - EffectBufferBase *mEffectBuffer{nullptr}; float RoomRolloff{0.0f}; /* Added to the source's room rolloff, not multiplied. */ float DecayTime{0.0f}; diff --git a/al/event.cpp b/al/event.cpp index 6c004ef3..cd8ea7c2 100644 --- a/al/event.cpp +++ b/al/event.cpp @@ -60,11 +60,6 @@ static int EventThread(ALCcontext *context) evt.u.mEffectState->release(); continue; } - if(evt.EnumType == EventType_ReleaseEffectBuffer) - { - evt.u.mEffectBuffer->release(); - continue; - } ALbitfieldSOFT enabledevts{context->mEnabledEvts.load(std::memory_order_acquire)}; if(!context->mEventCb) continue; @@ -6,7 +6,6 @@ #include "almalloc.h" -struct EffectBufferBase; struct EffectState; @@ -24,7 +23,6 @@ enum { /* Internal events. */ EventType_ReleaseEffectState = 65536, - EventType_ReleaseEffectBuffer, }; struct AsyncEvent { @@ -46,7 +44,6 @@ struct AsyncEvent { ALchar msg[232]; } user; EffectState *mEffectState; - EffectBufferBase *mEffectBuffer; } u{}; AsyncEvent() noexcept = default; |