aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
Diffstat (limited to 'alc')
-rw-r--r--alc/alc.cpp6
-rw-r--r--alc/alu.h4
-rw-r--r--alc/effectslot.cpp7
-rw-r--r--alc/effectslot.h6
-rw-r--r--alc/panning.cpp11
5 files changed, 23 insertions, 11 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 224ebce1..b98cc520 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2113,7 +2113,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
if(ALeffectslot *slot{context->mDefaultSlot.get()})
{
- aluInitEffectPanning(slot, context);
+ aluInitEffectPanning(&slot->mSlot, context);
EffectState *state{slot->Effect.State.get()};
state->mOutTarget = device->Dry.Buffer;
@@ -2132,7 +2132,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
ALeffectslot *slot{sublist.EffectSlots + idx};
usemask &= ~(1_u64 << idx);
- aluInitEffectPanning(slot, context);
+ aluInitEffectPanning(&slot->mSlot, context);
EffectState *state{slot->Effect.State.get()};
state->mOutTarget = device->Dry.Buffer;
@@ -2441,7 +2441,7 @@ void ALCcontext::init()
{
mDefaultSlot = std::unique_ptr<ALeffectslot>{new ALeffectslot{}};
if(mDefaultSlot->init() == AL_NO_ERROR)
- aluInitEffectPanning(mDefaultSlot.get(), this);
+ aluInitEffectPanning(&mDefaultSlot->mSlot, this);
else
{
mDefaultSlot = nullptr;
diff --git a/alc/alu.h b/alc/alu.h
index b1f48045..2aa1a652 100644
--- a/alc/alu.h
+++ b/alc/alu.h
@@ -13,7 +13,7 @@
struct ALCcontext;
struct ALCdevice;
-struct ALeffectslot;
+struct EffectSlot;
struct MixParams;
@@ -54,7 +54,7 @@ void aluInitMixer(void);
void aluInitRenderer(ALCdevice *device, int hrtf_id, HrtfRequestMode hrtf_appreq,
HrtfRequestMode hrtf_userreq);
-void aluInitEffectPanning(ALeffectslot *slot, ALCcontext *context);
+void aluInitEffectPanning(EffectSlot *slot, ALCcontext *context);
/**
* Calculates ambisonic encoder coefficients using the X, Y, and Z direction
diff --git a/alc/effectslot.cpp b/alc/effectslot.cpp
index f3324858..8abac248 100644
--- a/alc/effectslot.cpp
+++ b/alc/effectslot.cpp
@@ -5,6 +5,7 @@
#include <stddef.h>
+#include "alcontext.h"
#include "almalloc.h"
@@ -16,3 +17,9 @@ EffectSlotArray *EffectSlot::CreatePtrArray(size_t count) noexcept
void *ptr{al_calloc(alignof(EffectSlotArray), EffectSlotArray::Sizeof(count*2))};
return new(ptr) EffectSlotArray{count};
}
+
+EffectSlot::~EffectSlot()
+{
+ if(mWetBuffer)
+ mWetBuffer->mInUse = false;
+}
diff --git a/alc/effectslot.h b/alc/effectslot.h
index be84fcab..c1eb1cc3 100644
--- a/alc/effectslot.h
+++ b/alc/effectslot.h
@@ -10,6 +10,7 @@
struct EffectSlot;
+struct WetBuffer;
using EffectSlotArray = al::FlexArray<EffectSlot*>;
@@ -75,6 +76,11 @@ struct EffectSlot {
bool DecayHFLimit{false};
float AirAbsorptionGainHF{1.0f};
+ /* Mixing buffer used by the Wet mix. */
+ WetBuffer *mWetBuffer{nullptr};
+
+ ~EffectSlot();
+
static EffectSlotArray *CreatePtrArray(size_t count) noexcept;
DISABLE_ALLOC()
diff --git a/alc/panning.cpp b/alc/panning.cpp
index 0dc77621..37f016fa 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -1042,7 +1042,7 @@ no_hrtf:
}
-void aluInitEffectPanning(ALeffectslot *slot, ALCcontext *context)
+void aluInitEffectPanning(EffectSlot *slot, ALCcontext *context)
{
ALCdevice *device{context->mDevice.get()};
const size_t count{AmbiChannelsFromOrder(device->mAmbiOrder)};
@@ -1059,7 +1059,7 @@ void aluInitEffectPanning(ALeffectslot *slot, ALCcontext *context)
if(wetbuffer_iter->get() == slot->mWetBuffer)
{
slot->mWetBuffer = nullptr;
- slot->mSlot.Wet.Buffer = {};
+ slot->Wet.Buffer = {};
*wetbuffer_iter = WetBufferPtr{new(FamCount(count)) WetBuffer{count}};
@@ -1087,12 +1087,11 @@ void aluInitEffectPanning(ALeffectslot *slot, ALCcontext *context)
wetbuffer->mInUse = true;
auto acnmap_end = AmbiIndex::FromACN.begin() + count;
- auto iter = std::transform(AmbiIndex::FromACN.begin(), acnmap_end,
- slot->mSlot.Wet.AmbiMap.begin(),
+ auto iter = std::transform(AmbiIndex::FromACN.begin(), acnmap_end, slot->Wet.AmbiMap.begin(),
[](const uint8_t &acn) noexcept -> BFChannelConfig
{ return BFChannelConfig{1.0f, acn}; });
- std::fill(iter, slot->mSlot.Wet.AmbiMap.end(), BFChannelConfig{});
- slot->mSlot.Wet.Buffer = wetbuffer->mBuffer;
+ std::fill(iter, slot->Wet.AmbiMap.end(), BFChannelConfig{});
+ slot->Wet.Buffer = wetbuffer->mBuffer;
}