diff options
Diffstat (limited to 'alc/alu.cpp')
-rw-r--r-- | alc/alu.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp index aed79b14..47b3ad36 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -505,6 +505,24 @@ bool CalcEffectSlotParams(ALeffectslot *slot, ALeffectslot **sorted_slots, ALCco } } + EffectBufferBase *buffer{props->Buffer.release()}; + EffectBufferBase *oldbuffer{slot->Params.mEffectBuffer}; + slot->Params.mEffectBuffer = buffer; + + if(oldbuffer && !oldbuffer->releaseIfNoDelete()) + { + RingBuffer *ring{context->mAsyncEvents.get()}; + auto evt_vec = ring->getWriteVector(); + if LIKELY(evt_vec.first.len > 0) + { + AsyncEvent *evt{::new(evt_vec.first.buf) AsyncEvent{EventType_ReleaseEffectBuffer}}; + evt->u.mEffectBuffer = oldbuffer; + ring->writeAdvance(1); + } + else + props->Buffer.reset(oldbuffer); + } + AtomicReplaceHead(context->mFreeEffectslotProps, props); EffectTarget output; |