aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-01-24 02:07:39 -0800
committerChris Robinson <[email protected]>2021-01-24 02:07:39 -0800
commit13c1d7efb7141aee93d32a60c0e609e61a64f550 (patch)
treec788c53507811f8adb8a33ee668c014f66d9b8fa
parent3142fb30eaa451c955a1607b8cffe2069cbd15b2 (diff)
Store buffer info in the queue entry
-rw-r--r--al/auxeffectslot.cpp11
-rw-r--r--al/buffer.h5
-rw-r--r--al/source.cpp11
-rw-r--r--alc/alc.cpp9
-rw-r--r--alc/buffer_storage.h11
-rw-r--r--alc/effects/autowah.cpp4
-rw-r--r--alc/effects/base.h8
-rw-r--r--alc/effects/chorus.cpp4
-rw-r--r--alc/effects/compressor.cpp4
-rw-r--r--alc/effects/convolution.cpp40
-rw-r--r--alc/effects/dedicated.cpp4
-rw-r--r--alc/effects/distortion.cpp4
-rw-r--r--alc/effects/echo.cpp4
-rw-r--r--alc/effects/equalizer.cpp4
-rw-r--r--alc/effects/fshifter.cpp4
-rw-r--r--alc/effects/modulator.cpp4
-rw-r--r--alc/effects/null.cpp4
-rw-r--r--alc/effects/pshifter.cpp4
-rw-r--r--alc/effects/reverb.cpp4
-rw-r--r--alc/effects/vmorpher.cpp4
-rw-r--r--alc/voice.cpp34
21 files changed, 103 insertions, 78 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index 8b31ab80..10f13be7 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -126,6 +126,13 @@ inline ALbuffer *LookupBuffer(ALCdevice *device, ALuint id) noexcept
}
+inline auto GetEffectBuffer(ALbuffer *buffer) noexcept -> EffectState::Buffer
+{
+ if(!buffer) return EffectState::Buffer{};
+ return EffectState::Buffer{buffer, buffer->mData};
+}
+
+
void AddActiveEffectSlots(const al::span<ALeffectslot*> auxslots, ALCcontext *context)
{
if(auxslots.empty()) return;
@@ -650,7 +657,7 @@ START_API_FUNC
FPUCtl mixer_mode{};
auto *state = slot->Effect.State.get();
- state->deviceUpdate(device, buffer);
+ state->deviceUpdate(device, GetEffectBuffer(buffer));
}
break;
@@ -926,7 +933,7 @@ ALenum ALeffectslot::initEffect(ALeffect *effect, ALCcontext *context)
state->mOutTarget = device->Dry.Buffer;
{
FPUCtl mixer_mode{};
- state->deviceUpdate(device, Buffer);
+ state->deviceUpdate(device, GetEffectBuffer(Buffer));
}
Effect.Type = newtype;
diff --git a/al/buffer.h b/al/buffer.h
index 2b3cd517..9f72fb1b 100644
--- a/al/buffer.h
+++ b/al/buffer.h
@@ -41,6 +41,8 @@ enum UserFmtChannels : unsigned char {
struct ALbuffer : public BufferStorage {
ALbitfieldSOFT Access{0u};
+ al::vector<al::byte,16> mData;
+
UserFmtType OriginalType{UserFmtShort};
ALuint OriginalSize{0};
ALuint OriginalAlign{0};
@@ -53,6 +55,9 @@ struct ALbuffer : public BufferStorage {
ALsizei MappedOffset{0};
ALsizei MappedSize{0};
+ ALuint mLoopStart{0u};
+ ALuint mLoopEnd{0u};
+
/* Number of times buffer was attached to a source (deletion can only occur when 0) */
RefCount ref{0u};
diff --git a/al/source.cpp b/al/source.cpp
index a4e59e59..ecaf4069 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -1398,6 +1398,9 @@ bool SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
/* Add the selected buffer to a one-item queue */
auto newlist = new BufferlistItem{};
newlist->mSampleLen = buffer->mSampleLen;
+ newlist->mLoopStart = buffer->mLoopStart;
+ newlist->mLoopEnd = buffer->mLoopEnd;
+ newlist->mSamples = buffer->mData;
newlist->mBuffer = buffer;
IncrementRef(buffer->ref);
@@ -3297,10 +3300,12 @@ START_API_FUNC
BufferList->mNext.store(item, std::memory_order_relaxed);
BufferList = item;
}
- BufferList->mNext.store(nullptr, std::memory_order_relaxed);
- BufferList->mSampleLen = buffer ? buffer->mSampleLen : 0;
- BufferList->mBuffer = buffer;
if(!buffer) continue;
+ BufferList->mSampleLen = buffer->mSampleLen;
+ BufferList->mLoopStart = 0;
+ BufferList->mLoopEnd = buffer->mSampleLen;
+ BufferList->mSamples = buffer->mData;
+ BufferList->mBuffer = buffer;
IncrementRef(buffer->ref);
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 02aaaa18..cc2a9536 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2102,6 +2102,11 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
FPUCtl mixer_mode{};
for(ALCcontext *context : *device->mContexts.load())
{
+ auto GetEffectBuffer = [](ALbuffer *buffer) noexcept -> EffectState::Buffer
+ {
+ if(!buffer) return EffectState::Buffer{};
+ return EffectState::Buffer{buffer, buffer->mData};
+ };
std::unique_lock<std::mutex> proplock{context->mPropLock};
std::unique_lock<std::mutex> slotlock{context->mEffectSlotLock};
@@ -2118,7 +2123,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
EffectState *state{slot->Effect.State.get()};
state->mOutTarget = device->Dry.Buffer;
- state->deviceUpdate(device, slot->Buffer);
+ state->deviceUpdate(device, GetEffectBuffer(slot->Buffer));
slot->updateProps(context);
}
@@ -2137,7 +2142,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
EffectState *state{slot->Effect.State.get()};
state->mOutTarget = device->Dry.Buffer;
- state->deviceUpdate(device, slot->Buffer);
+ state->deviceUpdate(device, GetEffectBuffer(slot->Buffer));
slot->updateProps(context);
}
}
diff --git a/alc/buffer_storage.h b/alc/buffer_storage.h
index 80ccbc7b..d6518bc0 100644
--- a/alc/buffer_storage.h
+++ b/alc/buffer_storage.h
@@ -5,7 +5,7 @@
#include "albyte.h"
#include "almalloc.h"
-#include "vector.h"
+#include "alspan.h"
using uint = unsigned int;
@@ -50,8 +50,6 @@ inline uint FrameSizeFromFmt(FmtChannels chans, FmtType type, uint ambiorder) no
using CallbackType = int(*)(void*, void*, int);
struct BufferStorage {
- al::vector<al::byte,16> mData;
-
CallbackType mCallback{nullptr};
void *mUserData{nullptr};
@@ -64,9 +62,6 @@ struct BufferStorage {
AmbiScaling mAmbiScaling{AmbiScaling::FuMa};
uint mAmbiOrder{0u};
- uint mLoopStart{0u};
- uint mLoopEnd{0u};
-
inline uint bytesFromFmt() const noexcept { return BytesFromFmt(mType); }
inline uint channelsFromFmt() const noexcept
{ return ChannelsFromFmt(mChannels, mAmbiOrder); }
@@ -80,6 +75,10 @@ struct BufferStorage {
struct BufferlistItem {
std::atomic<BufferlistItem*> mNext{nullptr};
uint mSampleLen{0u};
+ uint mLoopStart{0u};
+ uint mLoopEnd{0u};
+ al::span<al::byte> mSamples;
+
BufferStorage *mBuffer{nullptr};
DEF_NEWDEL(BufferlistItem)
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<const FloatBufferLine> 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 <cstddef>
+#include "albyte.h"
#include "alcmain.h"
#include "almalloc.h"
#include "alspan.h"
@@ -164,12 +165,17 @@ struct EffectTarget {
};
struct EffectState : public al::intrusive_ref<EffectState> {
+ struct Buffer {
+ const BufferStorage *storage;
+ al::span<const al::byte> samples;
+ };
+
al::span<FloatBufferLine> 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<const FloatBufferLine> 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<const FloatBufferLine> 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<const FloatBufferLine> 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<FloatBufferLine>,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<const FloatBufferLine> samplesIn,
@@ -219,7 +219,7 @@ void ConvolutionState::UpsampleMix(const al::span<FloatBufferLine> 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<uint>(
- (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<float>(device->Frequency)};
for(auto &e : *mChans)
@@ -277,20 +277,20 @@ void ConvolutionState::deviceUpdate(const ALCdevice *device, const BufferStorage
mComplexData = std::make_unique<complex_d[]>(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<double[]>(maxz(buffer->mSampleLen, resampledCount));
+ auto srcsamples = std::make_unique<double[]>(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<const FloatBufferLine> 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<const FloatBufferLine> 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<const FloatBufferLine> 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<float>(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<const FloatBufferLine> 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<const FloatBufferLine> 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<const FloatBufferLine> 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<const FloatBufferLine> 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<const FloatBufferLine> 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<const FloatBufferLine> 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<float>(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<const FloatBufferLine> samplesIn,
@@ -202,7 +202,7 @@ std::array<FormantFilter,4> VmorpherState::getFiltersByPhoneme(VMorpherPhenome p
}
-void VmorpherState::deviceUpdate(const ALCdevice* /*device*/, const BufferStorage* /*buffer*/)
+void VmorpherState::deviceUpdate(const ALCdevice*, const Buffer&)
{
for(auto &e : mChans)
{
diff --git a/alc/voice.cpp b/alc/voice.cpp
index 47484452..397f1ed9 100644
--- a/alc/voice.cpp
+++ b/alc/voice.cpp
@@ -239,8 +239,8 @@ float *LoadBufferStatic(BufferlistItem *BufferListItem, BufferlistItem *&BufferL
al::span<float> SrcBuffer)
{
const BufferStorage &Buffer = *BufferListItem->mBuffer;
- const uint LoopStart{Buffer.mLoopStart};
- const uint LoopEnd{Buffer.mLoopEnd};
+ const uint LoopStart{BufferListItem->mLoopStart};
+ const uint LoopEnd{BufferListItem->mLoopEnd};
ASSUME(LoopEnd > LoopStart);
/* If current pos is beyond the loop range, do not loop */
@@ -249,9 +249,9 @@ float *LoadBufferStatic(BufferlistItem *BufferListItem, BufferlistItem *&BufferL
BufferLoopItem = nullptr;
/* Load what's left to play from the buffer */
- const size_t DataRem{minz(SrcBuffer.size(), Buffer.mSampleLen-DataPosInt)};
+ const size_t DataRem{minz(SrcBuffer.size(), BufferListItem->mSampleLen-DataPosInt)};
- const al::byte *Data{Buffer.mData.data()};
+ const al::byte *Data{BufferListItem->mSamples.data()};
Data += (DataPosInt*NumChannels + chan)*SampleSize;
LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer.mType, DataRem);
@@ -262,7 +262,7 @@ float *LoadBufferStatic(BufferlistItem *BufferListItem, BufferlistItem *&BufferL
/* Load what's left of this loop iteration */
const size_t DataRem{minz(SrcBuffer.size(), LoopEnd-DataPosInt)};
- const al::byte *Data{Buffer.mData.data()};
+ const al::byte *Data{BufferListItem->mSamples.data()};
Data += (DataPosInt*NumChannels + chan)*SampleSize;
LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer.mType, DataRem);
@@ -274,7 +274,7 @@ float *LoadBufferStatic(BufferlistItem *BufferListItem, BufferlistItem *&BufferL
{
const size_t DataSize{minz(SrcBuffer.size(), LoopSize)};
- Data = Buffer.mData.data() + (LoopStart*NumChannels + chan)*SampleSize;
+ Data = BufferListItem->mSamples.data() + (LoopStart*NumChannels + chan)*SampleSize;
LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer.mType, DataSize);
SrcBuffer = SrcBuffer.subspan(DataSize);
@@ -292,7 +292,7 @@ float *LoadBufferCallback(BufferlistItem *BufferListItem, const size_t NumChanne
/* Load what's left to play from the buffer */
const size_t DataRem{minz(SrcBuffer.size(), NumCallbackSamples)};
- const al::byte *Data{Buffer.mData.data() + chan*SampleSize};
+ const al::byte *Data{BufferListItem->mSamples.data() + chan*SampleSize};
LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer.mType, DataRem);
SrcBuffer = SrcBuffer.subspan(DataRem);
@@ -307,18 +307,18 @@ float *LoadBufferQueue(BufferlistItem *BufferListItem, BufferlistItem *BufferLoo
/* Crawl the buffer queue to fill in the temp buffer */
while(BufferListItem && !SrcBuffer.empty())
{
- BufferStorage *Buffer{BufferListItem->mBuffer};
- if(!(Buffer && DataPosInt < Buffer->mSampleLen))
+ if(DataPosInt >= BufferListItem->mSampleLen)
{
- if(Buffer) DataPosInt -= Buffer->mSampleLen;
+ DataPosInt -= BufferListItem->mSampleLen;
BufferListItem = BufferListItem->mNext.load(std::memory_order_acquire);
if(!BufferListItem) BufferListItem = BufferLoopItem;
continue;
}
- const size_t DataSize{minz(SrcBuffer.size(), Buffer->mSampleLen-DataPosInt)};
+ BufferStorage *Buffer{BufferListItem->mBuffer};
+ const size_t DataSize{minz(SrcBuffer.size(), BufferListItem->mSampleLen-DataPosInt)};
- const al::byte *Data{Buffer->mData.data()};
+ const al::byte *Data{BufferListItem->mSamples.data()};
Data += (DataPosInt*NumChannels + chan)*SampleSize;
LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer->mType, DataSize);
@@ -567,7 +567,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const uint SamplesToDo)
const size_t needBytes{toLoad*FrameSize - byteOffset};
const int gotBytes{buffer->mCallback(buffer->mUserData,
- &buffer->mData[byteOffset], static_cast<int>(needBytes))};
+ &BufferListItem->mSamples[byteOffset], static_cast<int>(needBytes))};
if(gotBytes < 1)
mFlags |= VoiceCallbackStopped;
else if(static_cast<uint>(gotBytes) < needBytes)
@@ -705,9 +705,8 @@ void Voice::mix(const State vstate, ALCcontext *Context, const uint SamplesToDo)
if(BufferLoopItem)
{
/* Handle looping static source */
- const BufferStorage &Buffer = *BufferListItem->mBuffer;
- const uint LoopStart{Buffer.mLoopStart};
- const uint LoopEnd{Buffer.mLoopEnd};
+ const uint LoopStart{BufferListItem->mLoopStart};
+ const uint LoopEnd{BufferListItem->mLoopEnd};
if(DataPosInt >= LoopEnd)
{
assert(LoopEnd > LoopStart);
@@ -726,12 +725,11 @@ void Voice::mix(const State vstate, ALCcontext *Context, const uint SamplesToDo)
}
else if((mFlags&VoiceIsCallback))
{
- BufferStorage &buffer = *BufferListItem->mBuffer;
if(SrcSamplesDone < mNumCallbackSamples)
{
const size_t byteOffset{SrcSamplesDone*FrameSize};
const size_t byteEnd{mNumCallbackSamples*FrameSize};
- al::byte *data{buffer.mData.data()};
+ al::byte *data{BufferListItem->mSamples.data()};
std::copy(data+byteOffset, data+byteEnd, data);
mNumCallbackSamples -= SrcSamplesDone;
}