From 13c1d7efb7141aee93d32a60c0e609e61a64f550 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 24 Jan 2021 02:07:39 -0800 Subject: Store buffer info in the queue entry --- alc/effects/autowah.cpp | 4 ++-- alc/effects/base.h | 8 +++++++- alc/effects/chorus.cpp | 4 ++-- alc/effects/compressor.cpp | 4 ++-- alc/effects/convolution.cpp | 40 ++++++++++++++++++++-------------------- alc/effects/dedicated.cpp | 4 ++-- alc/effects/distortion.cpp | 4 ++-- alc/effects/echo.cpp | 4 ++-- alc/effects/equalizer.cpp | 4 ++-- alc/effects/fshifter.cpp | 4 ++-- alc/effects/modulator.cpp | 4 ++-- alc/effects/null.cpp | 4 ++-- alc/effects/pshifter.cpp | 4 ++-- alc/effects/reverb.cpp | 4 ++-- alc/effects/vmorpher.cpp | 4 ++-- 15 files changed, 53 insertions(+), 47 deletions(-) (limited to 'alc/effects') diff --git a/alc/effects/autowah.cpp b/alc/effects/autowah.cpp index 403a23e3..2577eb30 100644 --- a/alc/effects/autowah.cpp +++ b/alc/effects/autowah.cpp @@ -69,7 +69,7 @@ struct AutowahState final : public EffectState { alignas(16) float mBufferOut[BufferLineSize]; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -78,7 +78,7 @@ struct AutowahState final : public EffectState { DEF_NEWDEL(AutowahState) }; -void AutowahState::deviceUpdate(const ALCdevice*, const BufferStorage* /*buffer*/) +void AutowahState::deviceUpdate(const ALCdevice*, const Buffer&) { /* (Re-)initializing parameters and clear the buffers. */ diff --git a/alc/effects/base.h b/alc/effects/base.h index 32d7fc86..b482bae2 100644 --- a/alc/effects/base.h +++ b/alc/effects/base.h @@ -3,6 +3,7 @@ #include +#include "albyte.h" #include "alcmain.h" #include "almalloc.h" #include "alspan.h" @@ -164,12 +165,17 @@ struct EffectTarget { }; struct EffectState : public al::intrusive_ref { + struct Buffer { + const BufferStorage *storage; + al::span samples; + }; + al::span mOutTarget; virtual ~EffectState() = default; - virtual void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) = 0; + virtual void deviceUpdate(const ALCdevice *device, const Buffer &buffer) = 0; virtual void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) = 0; virtual void process(const size_t samplesToDo, const al::span samplesIn, diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp index 92d57c18..365eaf33 100644 --- a/alc/effects/chorus.cpp +++ b/alc/effects/chorus.cpp @@ -68,7 +68,7 @@ struct ChorusState final : public EffectState { void getTriangleDelays(uint (*delays)[MAX_UPDATE_SAMPLES], const size_t todo); void getSinusoidDelays(uint (*delays)[MAX_UPDATE_SAMPLES], const size_t todo); - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -77,7 +77,7 @@ struct ChorusState final : public EffectState { DEF_NEWDEL(ChorusState) }; -void ChorusState::deviceUpdate(const ALCdevice *Device, const BufferStorage* /*buffer*/) +void ChorusState::deviceUpdate(const ALCdevice *Device, const Buffer&) { constexpr float max_delay{maxf(AL_CHORUS_MAX_DELAY, AL_FLANGER_MAX_DELAY)}; diff --git a/alc/effects/compressor.cpp b/alc/effects/compressor.cpp index 4e2f2098..393bb93f 100644 --- a/alc/effects/compressor.cpp +++ b/alc/effects/compressor.cpp @@ -49,7 +49,7 @@ struct CompressorState final : public EffectState { float mEnvFollower{1.0f}; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -58,7 +58,7 @@ struct CompressorState final : public EffectState { DEF_NEWDEL(CompressorState) }; -void CompressorState::deviceUpdate(const ALCdevice *device, const BufferStorage* /*buffer*/) +void CompressorState::deviceUpdate(const ALCdevice *device, const Buffer&) { /* Number of samples to do a full attack and release (non-integer sample * counts are okay). diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index 2dec0dc6..22311bbb 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -190,7 +190,7 @@ struct ConvolutionState final : public EffectState { void (ConvolutionState::*mMix)(const al::span,const size_t) {&ConvolutionState::NormalMix}; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -219,7 +219,7 @@ void ConvolutionState::UpsampleMix(const al::span samplesOut, } -void ConvolutionState::deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) +void ConvolutionState::deviceUpdate(const ALCdevice *device, const Buffer &buffer) { constexpr uint MaxConvolveAmbiOrder{1u}; @@ -236,13 +236,13 @@ void ConvolutionState::deviceUpdate(const ALCdevice *device, const BufferStorage mComplexData = nullptr; /* An empty buffer doesn't need a convolution filter. */ - if(!buffer || buffer->mSampleLen < 1) return; + if(!buffer.storage || buffer.storage->mSampleLen < 1) return; constexpr size_t m{ConvolveUpdateSize/2 + 1}; - auto bytesPerSample = BytesFromFmt(buffer->mType); - auto realChannels = ChannelsFromFmt(buffer->mChannels, buffer->mAmbiOrder); - auto numChannels = ChannelsFromFmt(buffer->mChannels, - minu(buffer->mAmbiOrder, MaxConvolveAmbiOrder)); + auto bytesPerSample = BytesFromFmt(buffer.storage->mType); + auto realChannels = ChannelsFromFmt(buffer.storage->mChannels, buffer.storage->mAmbiOrder); + auto numChannels = ChannelsFromFmt(buffer.storage->mChannels, + minu(buffer.storage->mAmbiOrder, MaxConvolveAmbiOrder)); mChans = ChannelDataArray::Create(numChannels); @@ -252,11 +252,11 @@ void ConvolutionState::deviceUpdate(const ALCdevice *device, const BufferStorage * called very infrequently, go ahead and use the polyphase resampler. */ PPhaseResampler resampler; - if(device->Frequency != buffer->mSampleRate) - resampler.init(buffer->mSampleRate, device->Frequency); + if(device->Frequency != buffer.storage->mSampleRate) + resampler.init(buffer.storage->mSampleRate, device->Frequency); const auto resampledCount = static_cast( - (uint64_t{buffer->mSampleLen}*device->Frequency + (buffer->mSampleRate-1)) / - buffer->mSampleRate); + (uint64_t{buffer.storage->mSampleLen}*device->Frequency+(buffer.storage->mSampleRate-1)) / + buffer.storage->mSampleRate); const BandSplitter splitter{device->mXOverFreq / static_cast(device->Frequency)}; for(auto &e : *mChans) @@ -277,20 +277,20 @@ void ConvolutionState::deviceUpdate(const ALCdevice *device, const BufferStorage mComplexData = std::make_unique(complex_length); std::fill_n(mComplexData.get(), complex_length, complex_d{}); - mChannels = buffer->mChannels; - mAmbiLayout = buffer->mAmbiLayout; - mAmbiScaling = buffer->mAmbiScaling; - mAmbiOrder = minu(buffer->mAmbiOrder, MaxConvolveAmbiOrder); + mChannels = buffer.storage->mChannels; + mAmbiLayout = buffer.storage->mAmbiLayout; + mAmbiScaling = buffer.storage->mAmbiScaling; + mAmbiOrder = minu(buffer.storage->mAmbiOrder, MaxConvolveAmbiOrder); - auto srcsamples = std::make_unique(maxz(buffer->mSampleLen, resampledCount)); + auto srcsamples = std::make_unique(maxz(buffer.storage->mSampleLen, resampledCount)); complex_d *filteriter = mComplexData.get() + mNumConvolveSegs*m; for(size_t c{0};c < numChannels;++c) { /* Load the samples from the buffer, and resample to match the device. */ - LoadSamples(srcsamples.get(), buffer->mData.data() + bytesPerSample*c, realChannels, - buffer->mType, buffer->mSampleLen); - if(device->Frequency != buffer->mSampleRate) - resampler.process(buffer->mSampleLen, srcsamples.get(), resampledCount, + LoadSamples(srcsamples.get(), buffer.samples.data() + bytesPerSample*c, realChannels, + buffer.storage->mType, buffer.storage->mSampleLen); + if(device->Frequency != buffer.storage->mSampleRate) + resampler.process(buffer.storage->mSampleLen, srcsamples.get(), resampledCount, srcsamples.get()); /* Store the first segment's samples in reverse in the time-domain, to diff --git a/alc/effects/dedicated.cpp b/alc/effects/dedicated.cpp index 876b14ef..9fee7fd7 100644 --- a/alc/effects/dedicated.cpp +++ b/alc/effects/dedicated.cpp @@ -37,7 +37,7 @@ struct DedicatedState final : public EffectState { float mTargetGains[MAX_OUTPUT_CHANNELS]; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -46,7 +46,7 @@ struct DedicatedState final : public EffectState { DEF_NEWDEL(DedicatedState) }; -void DedicatedState::deviceUpdate(const ALCdevice*, const BufferStorage*) +void DedicatedState::deviceUpdate(const ALCdevice*, const Buffer&) { std::fill(std::begin(mCurrentGains), std::end(mCurrentGains), 0.0f); } diff --git a/alc/effects/distortion.cpp b/alc/effects/distortion.cpp index 46ca03d8..09dae4c5 100644 --- a/alc/effects/distortion.cpp +++ b/alc/effects/distortion.cpp @@ -45,7 +45,7 @@ struct DistortionState final : public EffectState { float mBuffer[2][BufferLineSize]{}; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -54,7 +54,7 @@ struct DistortionState final : public EffectState { DEF_NEWDEL(DistortionState) }; -void DistortionState::deviceUpdate(const ALCdevice*, const BufferStorage*) +void DistortionState::deviceUpdate(const ALCdevice*, const Buffer&) { mLowpass.clear(); mBandpass.clear(); diff --git a/alc/effects/echo.cpp b/alc/effects/echo.cpp index b84e501a..f782055f 100644 --- a/alc/effects/echo.cpp +++ b/alc/effects/echo.cpp @@ -57,7 +57,7 @@ struct EchoState final : public EffectState { alignas(16) float mTempBuffer[2][BufferLineSize]; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -66,7 +66,7 @@ struct EchoState final : public EffectState { DEF_NEWDEL(EchoState) }; -void EchoState::deviceUpdate(const ALCdevice *Device, const BufferStorage* /*buffer*/) +void EchoState::deviceUpdate(const ALCdevice *Device, const Buffer&) { const auto frequency = static_cast(Device->Frequency); diff --git a/alc/effects/equalizer.cpp b/alc/effects/equalizer.cpp index 133ab319..bd19c051 100644 --- a/alc/effects/equalizer.cpp +++ b/alc/effects/equalizer.cpp @@ -90,7 +90,7 @@ struct EqualizerState final : public EffectState { FloatBufferLine mSampleBuffer{}; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -99,7 +99,7 @@ struct EqualizerState final : public EffectState { DEF_NEWDEL(EqualizerState) }; -void EqualizerState::deviceUpdate(const ALCdevice*, const BufferStorage*) +void EqualizerState::deviceUpdate(const ALCdevice*, const Buffer&) { for(auto &e : mChans) { diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp index 1f202fc3..1f881f9d 100644 --- a/alc/effects/fshifter.cpp +++ b/alc/effects/fshifter.cpp @@ -83,7 +83,7 @@ struct FshifterState final : public EffectState { } mGains[2]; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -92,7 +92,7 @@ struct FshifterState final : public EffectState { DEF_NEWDEL(FshifterState) }; -void FshifterState::deviceUpdate(const ALCdevice*, const BufferStorage*) +void FshifterState::deviceUpdate(const ALCdevice*, const Buffer&) { /* (Re-)initializing parameters and clear the buffers. */ mCount = FIFO_LATENCY; diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp index eeb41635..267c73e7 100644 --- a/alc/effects/modulator.cpp +++ b/alc/effects/modulator.cpp @@ -81,7 +81,7 @@ struct ModulatorState final : public EffectState { } mChans[MaxAmbiChannels]; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -90,7 +90,7 @@ struct ModulatorState final : public EffectState { DEF_NEWDEL(ModulatorState) }; -void ModulatorState::deviceUpdate(const ALCdevice*, const BufferStorage*) +void ModulatorState::deviceUpdate(const ALCdevice*, const Buffer&) { for(auto &e : mChans) { diff --git a/alc/effects/null.cpp b/alc/effects/null.cpp index 9608f48a..9d589285 100644 --- a/alc/effects/null.cpp +++ b/alc/effects/null.cpp @@ -15,7 +15,7 @@ struct NullState final : public EffectState { NullState(); ~NullState() override; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -39,7 +39,7 @@ NullState::~NullState() = default; * format) have been changed. Will always be followed by a call to the update * method, if successful. */ -void NullState::deviceUpdate(const ALCdevice* /*device*/, const BufferStorage* /*buffer*/) +void NullState::deviceUpdate(const ALCdevice* /*device*/, const Buffer& /*buffer*/) { } diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp index 3a577ce7..257742ed 100644 --- a/alc/effects/pshifter.cpp +++ b/alc/effects/pshifter.cpp @@ -92,7 +92,7 @@ struct PshifterState final : public EffectState { float mTargetGains[MAX_OUTPUT_CHANNELS]; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -101,7 +101,7 @@ struct PshifterState final : public EffectState { DEF_NEWDEL(PshifterState) }; -void PshifterState::deviceUpdate(const ALCdevice* /*device*/, const BufferStorage* /*buffer*/) +void PshifterState::deviceUpdate(const ALCdevice*, const Buffer&) { /* (Re-)initializing parameters and clear the buffers. */ mCount = FIFO_LATENCY; diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index 1aaad4a6..a519fc34 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -527,7 +527,7 @@ struct ReverbState final : public EffectState { void lateFaded(const size_t offset, const size_t todo, const float fade, const float fadeStep); - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -607,7 +607,7 @@ void ReverbState::allocLines(const float frequency) mLate.Delay.realizeLineOffset(mSampleBuffer.data()); } -void ReverbState::deviceUpdate(const ALCdevice *device, const BufferStorage* /*buffer*/) +void ReverbState::deviceUpdate(const ALCdevice *device, const Buffer&) { const auto frequency = static_cast(device->Frequency); diff --git a/alc/effects/vmorpher.cpp b/alc/effects/vmorpher.cpp index f1c46b8c..ab21439c 100644 --- a/alc/effects/vmorpher.cpp +++ b/alc/effects/vmorpher.cpp @@ -138,7 +138,7 @@ struct VmorpherState final : public EffectState { alignas(16) float mSampleBufferB[MAX_UPDATE_SAMPLES]{}; alignas(16) float mLfo[MAX_UPDATE_SAMPLES]{}; - void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override; + void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override; void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span samplesIn, @@ -202,7 +202,7 @@ std::array VmorpherState::getFiltersByPhoneme(VMorpherPhenome p } -void VmorpherState::deviceUpdate(const ALCdevice* /*device*/, const BufferStorage* /*buffer*/) +void VmorpherState::deviceUpdate(const ALCdevice*, const Buffer&) { for(auto &e : mChans) { -- cgit v1.2.3