Combine EffectState::deviceUpdate with setBuffer

This commit is contained in:
Chris Robinson 2020-12-26 12:33:00 -08:00
parent 54719de132
commit 507cbfa027
17 changed files with 33 additions and 45 deletions

View File

@ -655,7 +655,7 @@ START_API_FUNC
FPUCtl mixer_mode{}; FPUCtl mixer_mode{};
auto *state = slot->Effect.State.get(); auto *state = slot->Effect.State.get();
state->setBuffer(device, buffer); state->deviceUpdate(device, buffer);
} }
break; break;
@ -935,9 +935,7 @@ ALenum ALeffectslot::initEffect(ALeffect *effect, ALCcontext *context)
State->mOutTarget = Device->Dry.Buffer; State->mOutTarget = Device->Dry.Buffer;
{ {
FPUCtl mixer_mode{}; FPUCtl mixer_mode{};
State->deviceUpdate(Device); State->deviceUpdate(Device, Buffer);
if(Buffer)
State->setBuffer(Device, Buffer);
} }
Effect.Type = newtype; Effect.Type = newtype;

View File

@ -2117,9 +2117,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
EffectState *state{slot->Effect.State.get()}; EffectState *state{slot->Effect.State.get()};
state->mOutTarget = device->Dry.Buffer; state->mOutTarget = device->Dry.Buffer;
state->deviceUpdate(device); state->deviceUpdate(device, slot->Buffer);
if(ALbuffer *buffer{slot->Buffer})
state->setBuffer(device, buffer);
slot->updateProps(context); slot->updateProps(context);
} }
@ -2138,9 +2136,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
EffectState *state{slot->Effect.State.get()}; EffectState *state{slot->Effect.State.get()};
state->mOutTarget = device->Dry.Buffer; state->mOutTarget = device->Dry.Buffer;
state->deviceUpdate(device); state->deviceUpdate(device, slot->Buffer);
if(ALbuffer *buffer{slot->Buffer})
state->setBuffer(device, buffer);
slot->updateProps(context); slot->updateProps(context);
} }
} }

View File

@ -69,7 +69,7 @@ struct AutowahState final : public EffectState {
alignas(16) float mBufferOut[BufferLineSize]; alignas(16) float mBufferOut[BufferLineSize];
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -78,7 +78,7 @@ struct AutowahState final : public EffectState {
DEF_NEWDEL(AutowahState) DEF_NEWDEL(AutowahState)
}; };
void AutowahState::deviceUpdate(const ALCdevice*) void AutowahState::deviceUpdate(const ALCdevice*, const BufferStorage* /*buffer*/)
{ {
/* (Re-)initializing parameters and clear the buffers. */ /* (Re-)initializing parameters and clear the buffers. */

View File

@ -169,8 +169,7 @@ struct EffectState : public al::intrusive_ref<EffectState> {
virtual ~EffectState() = default; virtual ~EffectState() = default;
virtual void deviceUpdate(const ALCdevice *device) = 0; virtual void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) = 0;
virtual void setBuffer(const ALCdevice* /*device*/, const BufferStorage* /*buffer*/) { }
virtual void update(const ALCcontext *context, const EffectSlot *slot, virtual void update(const ALCcontext *context, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target) = 0; const EffectProps *props, const EffectTarget target) = 0;
virtual void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, virtual void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,

View File

@ -68,7 +68,7 @@ struct ChorusState final : public EffectState {
void getTriangleDelays(uint (*delays)[MAX_UPDATE_SAMPLES], const size_t todo); void getTriangleDelays(uint (*delays)[MAX_UPDATE_SAMPLES], const size_t todo);
void getSinusoidDelays(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) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -77,7 +77,7 @@ struct ChorusState final : public EffectState {
DEF_NEWDEL(ChorusState) DEF_NEWDEL(ChorusState)
}; };
void ChorusState::deviceUpdate(const ALCdevice *Device) void ChorusState::deviceUpdate(const ALCdevice *Device, const BufferStorage* /*buffer*/)
{ {
constexpr float max_delay{maxf(AL_CHORUS_MAX_DELAY, AL_FLANGER_MAX_DELAY)}; constexpr float max_delay{maxf(AL_CHORUS_MAX_DELAY, AL_FLANGER_MAX_DELAY)};

View File

@ -49,7 +49,7 @@ struct CompressorState final : public EffectState {
float mEnvFollower{1.0f}; float mEnvFollower{1.0f};
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -58,7 +58,7 @@ struct CompressorState final : public EffectState {
DEF_NEWDEL(CompressorState) DEF_NEWDEL(CompressorState)
}; };
void CompressorState::deviceUpdate(const ALCdevice *device) void CompressorState::deviceUpdate(const ALCdevice *device, const BufferStorage* /*buffer*/)
{ {
/* Number of samples to do a full attack and release (non-integer sample /* Number of samples to do a full attack and release (non-integer sample
* counts are okay). * counts are okay).

View File

@ -174,8 +174,7 @@ struct ConvolutionState final : public EffectState {
void (ConvolutionState::*mMix)(const al::span<FloatBufferLine>,const size_t) void (ConvolutionState::*mMix)(const al::span<FloatBufferLine>,const size_t)
{&ConvolutionState::NormalMix}; {&ConvolutionState::NormalMix};
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void setBuffer(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -204,11 +203,7 @@ void ConvolutionState::UpsampleMix(const al::span<FloatBufferLine> samplesOut,
} }
void ConvolutionState::deviceUpdate(const ALCdevice* /*device*/) void ConvolutionState::deviceUpdate(const ALCdevice *device, const BufferStorage *buffer)
{
}
void ConvolutionState::setBuffer(const ALCdevice *device, const BufferStorage *buffer)
{ {
constexpr uint MaxConvolveAmbiOrder{1u}; constexpr uint MaxConvolveAmbiOrder{1u};

View File

@ -37,7 +37,7 @@ struct DedicatedState final : public EffectState {
float mTargetGains[MAX_OUTPUT_CHANNELS]; float mTargetGains[MAX_OUTPUT_CHANNELS];
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -46,7 +46,7 @@ struct DedicatedState final : public EffectState {
DEF_NEWDEL(DedicatedState) DEF_NEWDEL(DedicatedState)
}; };
void DedicatedState::deviceUpdate(const ALCdevice*) void DedicatedState::deviceUpdate(const ALCdevice*, const BufferStorage*)
{ {
std::fill(std::begin(mCurrentGains), std::end(mCurrentGains), 0.0f); std::fill(std::begin(mCurrentGains), std::end(mCurrentGains), 0.0f);
} }

View File

@ -45,7 +45,7 @@ struct DistortionState final : public EffectState {
float mBuffer[2][BufferLineSize]{}; float mBuffer[2][BufferLineSize]{};
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -54,7 +54,7 @@ struct DistortionState final : public EffectState {
DEF_NEWDEL(DistortionState) DEF_NEWDEL(DistortionState)
}; };
void DistortionState::deviceUpdate(const ALCdevice*) void DistortionState::deviceUpdate(const ALCdevice*, const BufferStorage*)
{ {
mLowpass.clear(); mLowpass.clear();
mBandpass.clear(); mBandpass.clear();

View File

@ -57,7 +57,7 @@ struct EchoState final : public EffectState {
alignas(16) float mTempBuffer[2][BufferLineSize]; alignas(16) float mTempBuffer[2][BufferLineSize];
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -66,7 +66,7 @@ struct EchoState final : public EffectState {
DEF_NEWDEL(EchoState) DEF_NEWDEL(EchoState)
}; };
void EchoState::deviceUpdate(const ALCdevice *Device) void EchoState::deviceUpdate(const ALCdevice *Device, const BufferStorage* /*buffer*/)
{ {
const auto frequency = static_cast<float>(Device->Frequency); const auto frequency = static_cast<float>(Device->Frequency);

View File

@ -90,7 +90,7 @@ struct EqualizerState final : public EffectState {
FloatBufferLine mSampleBuffer{}; FloatBufferLine mSampleBuffer{};
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -99,7 +99,7 @@ struct EqualizerState final : public EffectState {
DEF_NEWDEL(EqualizerState) DEF_NEWDEL(EqualizerState)
}; };
void EqualizerState::deviceUpdate(const ALCdevice*) void EqualizerState::deviceUpdate(const ALCdevice*, const BufferStorage*)
{ {
for(auto &e : mChans) for(auto &e : mChans)
{ {

View File

@ -81,7 +81,7 @@ struct FshifterState final : public EffectState {
} mGains[2]; } mGains[2];
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -90,7 +90,7 @@ struct FshifterState final : public EffectState {
DEF_NEWDEL(FshifterState) DEF_NEWDEL(FshifterState)
}; };
void FshifterState::deviceUpdate(const ALCdevice*) void FshifterState::deviceUpdate(const ALCdevice*, const BufferStorage*)
{ {
/* (Re-)initializing parameters and clear the buffers. */ /* (Re-)initializing parameters and clear the buffers. */
mCount = FIFO_LATENCY; mCount = FIFO_LATENCY;

View File

@ -81,7 +81,7 @@ struct ModulatorState final : public EffectState {
} mChans[MaxAmbiChannels]; } mChans[MaxAmbiChannels];
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -90,7 +90,7 @@ struct ModulatorState final : public EffectState {
DEF_NEWDEL(ModulatorState) DEF_NEWDEL(ModulatorState)
}; };
void ModulatorState::deviceUpdate(const ALCdevice*) void ModulatorState::deviceUpdate(const ALCdevice*, const BufferStorage*)
{ {
for(auto &e : mChans) for(auto &e : mChans)
{ {

View File

@ -15,7 +15,7 @@ struct NullState final : public EffectState {
NullState(); NullState();
~NullState() override; ~NullState() override;
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, 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 * format) have been changed. Will always be followed by a call to the update
* method, if successful. * method, if successful.
*/ */
void NullState::deviceUpdate(const ALCdevice* /*device*/) void NullState::deviceUpdate(const ALCdevice* /*device*/, const BufferStorage* /*buffer*/)
{ {
} }

View File

@ -91,7 +91,7 @@ struct PshifterState final : public EffectState {
float mTargetGains[MAX_OUTPUT_CHANNELS]; float mTargetGains[MAX_OUTPUT_CHANNELS];
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -100,7 +100,7 @@ struct PshifterState final : public EffectState {
DEF_NEWDEL(PshifterState) DEF_NEWDEL(PshifterState)
}; };
void PshifterState::deviceUpdate(const ALCdevice* /*device*/) void PshifterState::deviceUpdate(const ALCdevice* /*device*/, const BufferStorage* /*buffer*/)
{ {
/* (Re-)initializing parameters and clear the buffers. */ /* (Re-)initializing parameters and clear the buffers. */
mCount = FIFO_LATENCY; mCount = FIFO_LATENCY;

View File

@ -527,7 +527,7 @@ struct ReverbState final : public EffectState {
void lateFaded(const size_t offset, const size_t todo, const float fade, void lateFaded(const size_t offset, const size_t todo, const float fade,
const float fadeStep); const float fadeStep);
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, 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()); mLate.Delay.realizeLineOffset(mSampleBuffer.data());
} }
void ReverbState::deviceUpdate(const ALCdevice *device) void ReverbState::deviceUpdate(const ALCdevice *device, const BufferStorage* /*buffer*/)
{ {
const auto frequency = static_cast<float>(device->Frequency); const auto frequency = static_cast<float>(device->Frequency);

View File

@ -136,7 +136,7 @@ struct VmorpherState final : public EffectState {
alignas(16) float mSampleBufferB[MAX_UPDATE_SAMPLES]{}; alignas(16) float mSampleBufferB[MAX_UPDATE_SAMPLES]{};
alignas(16) float mLfo[MAX_UPDATE_SAMPLES]{}; alignas(16) float mLfo[MAX_UPDATE_SAMPLES]{};
void deviceUpdate(const ALCdevice *device) override; void deviceUpdate(const ALCdevice *device, const BufferStorage *buffer) override;
void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props, void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override; const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
@ -200,7 +200,7 @@ std::array<FormantFilter,4> VmorpherState::getFiltersByPhoneme(VMorpherPhenome p
} }
void VmorpherState::deviceUpdate(const ALCdevice* /*device*/) void VmorpherState::deviceUpdate(const ALCdevice* /*device*/, const BufferStorage* /*buffer*/)
{ {
for(auto &e : mChans) for(auto &e : mChans)
{ {