aboutsummaryrefslogtreecommitdiffstats
path: root/alc/alu.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-08-24 20:34:50 -0700
committerChris Robinson <[email protected]>2020-08-24 20:40:24 -0700
commita6bd53c4e1de084d93541f23d391154d7949b678 (patch)
treef33a98b0e978eaf14191806271fb883f95783a69 /alc/alu.cpp
parent1a9fbc1b2f7456f14e9cb74d95f4696cbe5c5af3 (diff)
Store a reference to the effect buffer as an active property
Diffstat (limited to 'alc/alu.cpp')
-rw-r--r--alc/alu.cpp18
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;