diff options
author | Chris Robinson <[email protected]> | 2020-09-05 20:48:56 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-09-05 20:48:56 -0700 |
commit | c52bf8c401aaf78bbcfa99b33fdaf4838999d547 (patch) | |
tree | 453bccbc16da43e7ec5403b57feab52e82e12faa /alc/effects/convolution.cpp | |
parent | 9975aeb37f0bcb9a35b1cba7a755abc4774883d0 (diff) |
Rework effect slot buffer setting
Rather than creating an effect-specific buffer that gets passed along as a
property, the buffer is set the effect state when the effect state is created,
the device is updated, or the buffer is changed. The buffer can only be set
while the effect slot isn't playing, so it won't be changed or updated while
the mixer is processing the effect state.
Diffstat (limited to 'alc/effects/convolution.cpp')
-rw-r--r-- | alc/effects/convolution.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index 1ce3bae2..2ba0bde8 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -97,7 +97,7 @@ using complex_d = std::complex<double>; constexpr size_t ConvolveUpdateSize{1024}; constexpr size_t ConvolveUpdateSamples{ConvolveUpdateSize / 2}; -struct ConvolutionFilter final : public EffectBufferBase { +struct ConvolutionFilter { FmtChannels mChannels{}; AmbiLayout mAmbiLayout{}; AmbiScaling mAmbiScaling{}; @@ -385,13 +385,13 @@ void ConvolutionFilter::process(const size_t samplesToDo, struct ConvolutionState final : public EffectState { - ConvolutionFilter *mFilter{}; + std::unique_ptr<ConvolutionFilter> mFilter; ConvolutionState() = default; ~ConvolutionState() override = default; void deviceUpdate(const ALCdevice *device) override; - EffectBufferBase *createBuffer(const ALCdevice *device, const BufferStorage &buffer) override; + void setBuffer(const ALCdevice *device, const BufferStorage *buffer) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; @@ -402,29 +402,26 @@ void ConvolutionState::deviceUpdate(const ALCdevice* /*device*/) { } -EffectBufferBase *ConvolutionState::createBuffer(const ALCdevice *device, - const BufferStorage &buffer) +void ConvolutionState::setBuffer(const ALCdevice *device, const BufferStorage *buffer) { + mFilter = nullptr; /* An empty buffer doesn't need a convolution filter. */ - if(buffer.mSampleLen < 1) return nullptr; + if(!buffer || buffer->mSampleLen < 1) return; - auto numChannels = ChannelsFromFmt(buffer.mChannels, - minu(buffer.mAmbiOrder, device->mAmbiOrder)); + auto numChannels = ChannelsFromFmt(buffer->mChannels, + minu(buffer->mAmbiOrder, device->mAmbiOrder)); - al::intrusive_ptr<ConvolutionFilter> filter{new ConvolutionFilter{numChannels}}; - if LIKELY(filter->init(device, buffer)) - return filter.release(); - return nullptr; + mFilter.reset(new ConvolutionFilter{numChannels}); + if(!mFilter->init(device, *buffer)) + mFilter = nullptr; } void ConvolutionState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) { - mFilter = static_cast<ConvolutionFilter*>(slot->Params.mEffectBuffer); - if(!mFilter) return; - - mFilter->update(mOutTarget, context, slot, props, target); + if(mFilter) + mFilter->update(mOutTarget, context, slot, props, target); } void ConvolutionState::process(const size_t samplesToDo, |