aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/alc.cpp41
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h52
-rw-r--r--OpenAL32/alAuxEffectSlot.cpp43
3 files changed, 39 insertions, 97 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index 2ab2df8e..8cc8fb2d 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -2584,31 +2584,8 @@ static ALvoid InitContext(ALCcontext *Context)
ALlistener &listener = Context->Listener;
struct ALeffectslotArray *auxslots;
- //Initialise listener
- listener.Gain = 1.0f;
- listener.Position[0] = 0.0f;
- listener.Position[1] = 0.0f;
- listener.Position[2] = 0.0f;
- listener.Velocity[0] = 0.0f;
- listener.Velocity[1] = 0.0f;
- listener.Velocity[2] = 0.0f;
- listener.Forward[0] = 0.0f;
- listener.Forward[1] = 0.0f;
- listener.Forward[2] = -1.0f;
- listener.Up[0] = 0.0f;
- listener.Up[1] = 1.0f;
- listener.Up[2] = 0.0f;
- ATOMIC_INIT(&listener.PropsClean, AL_TRUE);
-
- ATOMIC_INIT(&listener.Update, static_cast<ALlistenerProps*>(nullptr));
-
//Validate Context
- InitRef(&Context->UpdateCount, 0);
- ATOMIC_INIT(&Context->HoldUpdates, AL_FALSE);
- Context->GainBoost = 1.0f;
almtx_init(&Context->PropLock, almtx_plain);
- ATOMIC_INIT(&Context->LastError, AL_NO_ERROR);
- Context->NumSources = 0;
almtx_init(&Context->SourceLock, almtx_plain);
almtx_init(&Context->EffectSlotLock, almtx_plain);
@@ -2637,17 +2614,7 @@ static ALvoid InitContext(ALCcontext *Context)
ATOMIC_INIT(&Context->PropsClean, AL_TRUE);
ATOMIC_INIT(&Context->DeferUpdates, AL_FALSE);
alsem_init(&Context->EventSem, 0);
- Context->AsyncEvents = nullptr;
- ATOMIC_INIT(&Context->EnabledEvts, 0u);
almtx_init(&Context->EventCbLock, almtx_plain);
- Context->EventCb = nullptr;
- Context->EventParam = nullptr;
-
- ATOMIC_INIT(&Context->Update, static_cast<ALcontextProps*>(nullptr));
- ATOMIC_INIT(&Context->FreeContextProps, static_cast<ALcontextProps*>(nullptr));
- ATOMIC_INIT(&Context->FreeListenerProps, static_cast<ALlistenerProps*>(nullptr));
- ATOMIC_INIT(&Context->FreeVoiceProps, static_cast<ALvoiceProps*>(nullptr));
- ATOMIC_INIT(&Context->FreeEffectslotProps, static_cast<ALeffectslotProps*>(nullptr));
Context->ExtensionList = alExtList;
@@ -2696,12 +2663,8 @@ ALCcontext_struct::~ALCcontext_struct()
}
TRACE("Freed " SZFMT " context property object%s\n", count, (count==1)?"":"s");
- if(DefaultSlot)
- {
- DeinitEffectSlot(DefaultSlot);
- delete DefaultSlot;
- DefaultSlot = nullptr;
- }
+ delete DefaultSlot;
+ DefaultSlot = nullptr;
al_free(ActiveAuxSlots.exchange(nullptr, std::memory_order_relaxed));
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index 38900695..815ae77e 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -101,42 +101,42 @@ struct ALeffectslotProps {
struct ALeffectslot {
- ALfloat Gain;
- ALboolean AuxSendAuto;
+ ALfloat Gain{1.0f};
+ ALboolean AuxSendAuto{AL_TRUE};
struct {
- ALenum Type;
- ALeffectProps Props;
+ ALenum Type{AL_EFFECT_NULL};
+ ALeffectProps Props{};
- ALeffectState *State;
+ ALeffectState *State{nullptr};
} Effect;
- ATOMIC(ALenum) PropsClean;
+ ATOMIC(ALenum) PropsClean{AL_TRUE};
- RefCount ref;
+ RefCount ref{0u};
- ATOMIC(struct ALeffectslotProps*) Update;
+ ATOMIC(struct ALeffectslotProps*) Update{nullptr};
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 DecayLFRatio;
- ALfloat DecayHFRatio;
- ALboolean DecayHFLimit;
- ALfloat AirAbsorptionGainHF;
+ ALfloat Gain{1.0f};
+ ALboolean AuxSendAuto{AL_TRUE};
+
+ ALenum EffectType{AL_EFFECT_NULL};
+ ALeffectProps EffectProps{};
+ ALeffectState *EffectState{nullptr};
+
+ ALfloat RoomRolloff{0.0f}; /* Added to the source's room rolloff, not multiplied. */
+ ALfloat DecayTime{0.0f};
+ ALfloat DecayLFRatio{0.0f};
+ ALfloat DecayHFRatio{0.0f};
+ ALboolean DecayHFLimit{AL_FALSE};
+ ALfloat AirAbsorptionGainHF{1.0f};
} Params;
/* Self ID */
- ALuint id;
+ ALuint id{};
- ALsizei NumChannels;
+ ALsizei NumChannels{};
BFChannelConfig ChanMap[MAX_EFFECT_CHANNELS];
/* Wet buffer configuration is ACN channel order with N3D scaling:
* * Channel 0 is the unattenuated mono signal.
@@ -150,11 +150,15 @@ struct ALeffectslot {
*/
alignas(16) ALfloat WetBuffer[MAX_EFFECT_CHANNELS][BUFFERSIZE];
+ ALeffectslot() = default;
+ ALeffectslot(const ALeffectslot&) = delete;
+ ALeffectslot& operator=(const ALeffectslot&) = delete;
+ ~ALeffectslot();
+
DEF_NEWDEL(ALeffectslot)
};
ALenum InitEffectSlot(ALeffectslot *slot);
-void DeinitEffectSlot(ALeffectslot *slot);
void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context);
void UpdateAllEffectSlotProps(ALCcontext *context);
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
diff --git a/OpenAL32/alAuxEffectSlot.cpp b/OpenAL32/alAuxEffectSlot.cpp
index ceb5cf39..6a0cc34c 100644
--- a/OpenAL32/alAuxEffectSlot.cpp
+++ b/OpenAL32/alAuxEffectSlot.cpp
@@ -198,7 +198,6 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *
continue;
context->EffectSlotList[effectslots[i]-1] = nullptr;
- DeinitEffectSlot(slot);
delete slot;
}
@@ -666,40 +665,18 @@ static void RemoveActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcon
ALenum InitEffectSlot(ALeffectslot *slot)
{
- EffectStateFactory *factory;
-
- slot->Effect.Type = AL_EFFECT_NULL;
-
- factory = getFactoryByType(AL_EFFECT_NULL);
+ EffectStateFactory *factory{getFactoryByType(slot->Effect.Type)};
slot->Effect.State = EffectStateFactory_create(factory);
if(!slot->Effect.State) return AL_OUT_OF_MEMORY;
- slot->Gain = 1.0;
- slot->AuxSendAuto = AL_TRUE;
- ATOMIC_INIT(&slot->PropsClean, AL_TRUE);
- InitRef(&slot->ref, 0);
-
- ATOMIC_INIT(&slot->Update, static_cast<ALeffectslotProps*>(nullptr));
-
- slot->Params.Gain = 1.0f;
- slot->Params.AuxSendAuto = AL_TRUE;
ALeffectState_IncRef(slot->Effect.State);
slot->Params.EffectState = slot->Effect.State;
- slot->Params.RoomRolloff = 0.0f;
- slot->Params.DecayTime = 0.0f;
- slot->Params.DecayLFRatio = 0.0f;
- slot->Params.DecayHFRatio = 0.0f;
- slot->Params.DecayHFLimit = AL_FALSE;
- slot->Params.AirAbsorptionGainHF = 1.0f;
-
return AL_NO_ERROR;
}
-void DeinitEffectSlot(ALeffectslot *slot)
+ALeffectslot::~ALeffectslot()
{
- struct ALeffectslotProps *props;
-
- props = ATOMIC_LOAD_SEQ(&slot->Update);
+ struct ALeffectslotProps *props{Update.load()};
if(props)
{
if(props->State) ALeffectState_DecRef(props->State);
@@ -707,9 +684,10 @@ void DeinitEffectSlot(ALeffectslot *slot)
al_free(props);
}
- ALeffectState_DecRef(slot->Effect.State);
- if(slot->Params.EffectState)
- ALeffectState_DecRef(slot->Params.EffectState);
+ if(Effect.State)
+ ALeffectState_DecRef(Effect.State);
+ if(Params.EffectState)
+ ALeffectState_DecRef(Params.EffectState);
}
void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context)
@@ -781,13 +759,10 @@ ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *context)
size_t leftover = 0;
for(auto &entry : context->EffectSlotList)
{
- ALeffectslot *slot = entry;
- if(!slot) continue;
+ if(!entry) continue;
+ delete entry;
entry = nullptr;
- DeinitEffectSlot(slot);
- delete slot;
-
++leftover;
}
if(leftover > 0)