Move the WetBuffer reference to EffectSlot
This commit is contained in:
@@ -277,7 +277,7 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context)
|
||||
context->setError(err, "Effect slot object initialization failed");
|
||||
return nullptr;
|
||||
}
|
||||
aluInitEffectPanning(slot, context);
|
||||
aluInitEffectPanning(&slot->mSlot, context);
|
||||
|
||||
/* Add 1 to avoid source ID 0. */
|
||||
slot->id = ((lidx<<6) | slidx) + 1;
|
||||
@@ -897,8 +897,6 @@ ALeffectslot::~ALeffectslot()
|
||||
delete props;
|
||||
}
|
||||
|
||||
if(mWetBuffer)
|
||||
mWetBuffer->mInUse = false;
|
||||
if(mSlot.mEffectState)
|
||||
mSlot.mEffectState->release();
|
||||
}
|
||||
|
||||
@@ -51,9 +51,6 @@ struct ALeffectslot {
|
||||
/* Self ID */
|
||||
ALuint id{};
|
||||
|
||||
/* Mixing buffer used by the Wet mix. */
|
||||
WetBuffer *mWetBuffer{nullptr};
|
||||
|
||||
ALeffectslot() { PropsClean.test_and_set(std::memory_order_relaxed); }
|
||||
ALeffectslot(const ALeffectslot&) = delete;
|
||||
ALeffectslot& operator=(const ALeffectslot&) = delete;
|
||||
|
||||
+3
-3
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
+5
-6
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user