aboutsummaryrefslogtreecommitdiffstats
path: root/al
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 /al
parent1a9fbc1b2f7456f14e9cb74d95f4696cbe5c5af3 (diff)
Store a reference to the effect buffer as an active property
Diffstat (limited to 'al')
-rw-r--r--al/auxeffectslot.cpp8
-rw-r--r--al/auxeffectslot.h2
-rw-r--r--al/event.cpp5
-rw-r--r--al/event.h3
4 files changed, 15 insertions, 3 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index 88512bef..790db24f 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -702,6 +702,8 @@ ALeffectslot::~ALeffectslot()
if(Params.mEffectState)
Params.mEffectState->release();
+ if(Params.mEffectBuffer)
+ Params.mEffectBuffer->release();
}
ALenum ALeffectslot::init()
@@ -764,6 +766,7 @@ ALenum ALeffectslot::initEffect(ALeffect *effect, ALCcontext *context)
while(props)
{
props->State = nullptr;
+ props->Buffer = nullptr;
props = props->next.load(std::memory_order_relaxed);
}
@@ -792,10 +795,8 @@ void ALeffectslot::updateProps(ALCcontext *context)
props->Type = Effect.Type;
props->Props = Effect.Props;
- /* Swap out any stale effect state object there may be in the container, to
- * delete it.
- */
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);
@@ -805,6 +806,7 @@ 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 de640b58..79373f45 100644
--- a/al/auxeffectslot.h
+++ b/al/auxeffectslot.h
@@ -32,6 +32,7 @@ struct ALeffectslotProps {
EffectProps Props;
al::intrusive_ptr<EffectState> State;
+ al::intrusive_ptr<EffectBufferBase> Buffer;
std::atomic<ALeffectslotProps*> next;
@@ -67,6 +68,7 @@ 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 cd8ea7c2..6c004ef3 100644
--- a/al/event.cpp
+++ b/al/event.cpp
@@ -60,6 +60,11 @@ 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;
diff --git a/al/event.h b/al/event.h
index 44d9306f..4717865b 100644
--- a/al/event.h
+++ b/al/event.h
@@ -6,6 +6,7 @@
#include "almalloc.h"
+struct EffectBufferBase;
struct EffectState;
@@ -23,6 +24,7 @@ enum {
/* Internal events. */
EventType_ReleaseEffectState = 65536,
+ EventType_ReleaseEffectBuffer,
};
struct AsyncEvent {
@@ -44,6 +46,7 @@ struct AsyncEvent {
ALchar msg[232];
} user;
EffectState *mEffectState;
+ EffectBufferBase *mEffectBuffer;
} u{};
AsyncEvent() noexcept = default;