aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include/alAuxEffectSlot.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-05-12 18:26:33 -0700
committerChris Robinson <[email protected]>2016-05-12 18:41:33 -0700
commitef0d4f8210fe6aa65b9df96f3b64bf6f355e845a (patch)
tree401b74c7c7291229397883c73d4ad2c382275b7e /OpenAL32/Include/alAuxEffectSlot.h
parent186b54aa3d5f1398a384fa318aa000210d82437e (diff)
Provide (mostly) lockless updates for effect slots
Similar to the listener, separate containers are provided atomically for the mixer thread to apply updates without needing to block, and a free-list is used to reuse container objects. A couple things to note. First, the lock is still used when the effect state's deviceUpdate method is called to prevent asynchronous calls to reset the device from interfering. This can be fixed by using the list lock in ALc.c instead. Secondly, old effect states aren't immediately deleted when the effect type changes (the actual type, not just its properties). This is because the mixer thread is intended to be real-time safe, and so can't be freeing anything. They are cleared away when updates reuse the container they were kept in, and they don't incur any extra processing cost, but there may be cases where the memory is kept around until the effect slot is deleted.
Diffstat (limited to 'OpenAL32/Include/alAuxEffectSlot.h')
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h44
1 files changed, 39 insertions, 5 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index e521ff82..7f670a95 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -20,6 +20,8 @@ typedef struct ALeffectState {
ALuint OutChannels;
} ALeffectState;
+void ALeffectState_Destruct(ALeffectState *state);
+
struct ALeffectStateVtable {
void (*const Destruct)(ALeffectState *state);
@@ -70,18 +72,48 @@ static const struct ALeffectStateFactoryVtable T##_ALeffectStateFactory_vtable =
#define MAX_EFFECT_CHANNELS (4)
-typedef struct ALeffectslot {
- ALenum EffectType;
- ALeffectProps EffectProps;
+struct ALeffectslotProps {
+ ATOMIC(ALfloat) Gain;
+ ATOMIC(ALboolean) AuxSendAuto;
+
+ ATOMIC(ALenum) Type;
+ ALeffectProps Props;
+
+ ATOMIC(ALeffectState*) State;
+
+ ATOMIC(struct ALeffectslotProps*) next;
+};
+
+typedef struct ALeffectslot {
volatile ALfloat Gain;
volatile ALboolean AuxSendAuto;
- ATOMIC(ALenum) NeedsUpdate;
- ALeffectState *EffectState;
+ struct {
+ ALenum Type;
+ ALeffectProps Props;
+
+ ALeffectState *State;
+ } Effect;
RefCount ref;
+ ATOMIC(struct ALeffectslotProps*) Update;
+ ATOMIC(struct ALeffectslotProps*) FreeList;
+
+ struct {
+ ALfloat Gain;
+ ALboolean AuxSendAuto;
+
+ ALenum EffectType;
+ ALeffectProps EffectProps;
+ ALeffectState *EffectState;
+
+ ALfloat RoomRolloff; /* Added to the source's room rolloff, not multiplied. */
+ ALfloat DecayTime;
+ ALfloat AirAbsorptionGainHF;
+ } Params;
+
/* Self ID */
ALuint id;
@@ -106,6 +138,8 @@ inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id)
{ return (struct ALeffectslot*)RemoveUIntMapKey(&context->EffectSlotMap, id); }
ALenum InitEffectSlot(ALeffectslot *slot);
+void DeinitEffectSlot(ALeffectslot *slot);
+void UpdateEffectSlotProps(ALeffectslot *slot);
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);