diff options
author | Chris Robinson <[email protected]> | 2020-11-02 04:24:36 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-11-02 04:24:36 -0800 |
commit | 52d58a40234b8829801f0a587375eca91694c30f (patch) | |
tree | caa8d283de74feeb4f23eab39ea57b3835c3bffc /alc/panning.cpp | |
parent | 6e05adf955bdd81c82a1feabb25f6f27d7bc56e0 (diff) |
Store the wet buffers in the context
This is rather ugly, but we need the wet buffers to remain allocated after its
effect slot is deleted, because a voice can still use it for its final fade-out
mix.
Diffstat (limited to 'alc/panning.cpp')
-rw-r--r-- | alc/panning.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/alc/panning.cpp b/alc/panning.cpp index 15a05136..ee7f39eb 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -40,6 +40,7 @@ #include "al/auxeffectslot.h" #include "alcmain.h" #include "alconfig.h" +#include "alcontext.h" #include "almalloc.h" #include "alnumeric.h" #include "aloptional.h" @@ -1034,19 +1035,33 @@ no_hrtf: } -void aluInitEffectPanning(ALeffectslot *slot, ALCdevice *device) +void aluInitEffectPanning(ALeffectslot *slot, ALCcontext *context) { + ALCdevice *device{context->mDevice.get()}; const size_t count{AmbiChannelsFromOrder(device->mAmbiOrder)}; - slot->MixBuffer.resize(count); - slot->MixBuffer.shrink_to_fit(); + + ALuint idx{0}; + for(auto &wetbuffer : context->mWetBuffers) + { + if(!wetbuffer->mInUse) + break; + ++idx; + } + if(idx == context->mWetBuffers.size()) + { + auto newbuffer = WetBufferPtr{new(FamCount(count)) WetBuffer{count}}; + context->mWetBuffers.emplace_back(std::move(newbuffer)); + } + auto *wetbuffer = context->mWetBuffers[idx].get(); + slot->mWetBuffer = wetbuffer; + wetbuffer->mInUse = true; auto acnmap_end = AmbiIndex::FromACN.begin() + count; auto iter = std::transform(AmbiIndex::FromACN.begin(), acnmap_end, slot->Wet.AmbiMap.begin(), [](const uint8_t &acn) noexcept -> BFChannelConfig - { return BFChannelConfig{1.0f, acn}; } - ); + { return BFChannelConfig{1.0f, acn}; }); std::fill(iter, slot->Wet.AmbiMap.end(), BFChannelConfig{}); - slot->Wet.Buffer = {slot->MixBuffer.data(), slot->MixBuffer.size()}; + slot->Wet.Buffer = {wetbuffer->mBuffer.data(), count}; } |