Remove another unnecessary return value

This commit is contained in:
Chris Robinson 2020-04-16 17:29:32 -07:00
parent cf4a848fd0
commit 27ac637a66
16 changed files with 41 additions and 82 deletions

View File

@ -645,23 +645,18 @@ ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect
EffectState *State{factory->create()};
if(!State) return AL_OUT_OF_MEMORY;
FPUCtl mixer_mode{};
ALCdevice *Device{Context->mDevice.get()};
std::unique_lock<std::mutex> statelock{Device->StateLock};
State->mOutTarget = Device->Dry.Buffer;
if(State->deviceUpdate(Device) == AL_FALSE)
{
statelock.unlock();
mixer_mode.leave();
State->release();
return AL_OUT_OF_MEMORY;
FPUCtl mixer_mode{};
State->deviceUpdate(Device);
}
mixer_mode.leave();
if(!effect)
{
EffectSlot->Effect.Type = AL_EFFECT_NULL;
EffectSlot->Effect.Props = EffectProps {};
EffectSlot->Effect.Props = EffectProps{};
}
else
{

View File

@ -2214,21 +2214,17 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
TRACE("Fixed device latency: %" PRId64 "ns\n", int64_t{device->FixedLatency.count()});
/* Need to delay returning failure until the Send arrays have been cleared. */
bool update_failed{false};
FPUCtl mixer_mode{};
for(ALCcontext *context : *device->mContexts.load())
{
if(context->mDefaultSlot && !update_failed)
if(ALeffectslot *slot{context->mDefaultSlot.get()})
{
ALeffectslot *slot{context->mDefaultSlot.get()};
aluInitEffectPanning(slot, device);
EffectState *state{slot->Effect.State};
state->mOutTarget = device->Dry.Buffer;
update_failed = !state->deviceUpdate(device);
if(!update_failed)
UpdateEffectSlotProps(slot, context);
state->deviceUpdate(device);
UpdateEffectSlotProps(slot, context);
}
std::unique_lock<std::mutex> proplock{context->mPropLock};
@ -2237,7 +2233,6 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
std::fill_n(curarray->end(), curarray->size(), nullptr);
for(auto &sublist : context->mEffectSlotList)
{
if(update_failed) break;
uint64_t usemask{~sublist.FreeMask};
while(usemask)
{
@ -2249,8 +2244,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
EffectState *state{slot->Effect.State};
state->mOutTarget = device->Dry.Buffer;
update_failed = !state->deviceUpdate(device);
if(update_failed) break;
state->deviceUpdate(device);
UpdateEffectSlotProps(slot, context);
}
}
@ -2380,8 +2374,6 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
UpdateAllSourceProps(context);
}
mixer_mode.leave();
if(update_failed)
return ALC_INVALID_DEVICE;
if(!device->Flags.get<DevicePaused>())
{

View File

@ -69,14 +69,14 @@ struct AutowahState final : public EffectState {
alignas(16) float mBufferOut[BUFFERSIZE];
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
DEF_NEWDEL(AutowahState)
};
bool AutowahState::deviceUpdate(const ALCdevice*)
void AutowahState::deviceUpdate(const ALCdevice*)
{
/* (Re-)initializing parameters and clear the buffers. */
@ -100,8 +100,6 @@ bool AutowahState::deviceUpdate(const ALCdevice*)
chan.Filter.z1 = 0.0f;
chan.Filter.z2 = 0.0f;
}
return true;
}
void AutowahState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)

View File

@ -165,7 +165,7 @@ struct EffectState : public al::intrusive_ref<EffectState> {
virtual ~EffectState() = default;
virtual bool deviceUpdate(const ALCdevice *device) = 0;
virtual void deviceUpdate(const ALCdevice *device) = 0;
virtual void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) = 0;
virtual void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) = 0;
};

View File

@ -80,24 +80,21 @@ struct ChorusState final : public EffectState {
void getTriangleDelays(ALuint (*delays)[MAX_UPDATE_SAMPLES], const size_t todo);
void getSinusoidDelays(ALuint (*delays)[MAX_UPDATE_SAMPLES], const size_t todo);
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
DEF_NEWDEL(ChorusState)
};
bool ChorusState::deviceUpdate(const ALCdevice *Device)
void ChorusState::deviceUpdate(const ALCdevice *Device)
{
constexpr float max_delay{maxf(AL_CHORUS_MAX_DELAY, AL_FLANGER_MAX_DELAY)};
const auto frequency = static_cast<float>(Device->Frequency);
const size_t maxlen{NextPowerOf2(float2uint(max_delay*2.0f*frequency) + 1u)};
if(maxlen != mSampleBuffer.size())
{
mSampleBuffer.resize(maxlen);
mSampleBuffer.shrink_to_fit();
}
al::vector<float,16>(maxlen).swap(mSampleBuffer);
std::fill(mSampleBuffer.begin(), mSampleBuffer.end(), 0.0f);
for(auto &e : mGains)
@ -105,8 +102,6 @@ bool ChorusState::deviceUpdate(const ALCdevice *Device)
std::fill(std::begin(e.Current), std::end(e.Current), 0.0f);
std::fill(std::begin(e.Target), std::end(e.Target), 0.0f);
}
return true;
}
void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, const EffectProps *props, const EffectTarget target)

View File

@ -49,28 +49,26 @@ struct CompressorState final : public EffectState {
float mEnvFollower{1.0f};
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
DEF_NEWDEL(CompressorState)
};
bool CompressorState::deviceUpdate(const ALCdevice *device)
void CompressorState::deviceUpdate(const ALCdevice *device)
{
/* Number of samples to do a full attack and release (non-integer sample
* counts are okay).
*/
const float attackCount = static_cast<float>(device->Frequency) * ATTACK_TIME;
const float releaseCount = static_cast<float>(device->Frequency) * RELEASE_TIME;
const float attackCount{static_cast<float>(device->Frequency) * ATTACK_TIME};
const float releaseCount{static_cast<float>(device->Frequency) * RELEASE_TIME};
/* Calculate per-sample multipliers to attack and release at the desired
* rates.
*/
mAttackMult = std::pow(AMP_ENVELOPE_MAX/AMP_ENVELOPE_MIN, 1.0f/attackCount);
mReleaseMult = std::pow(AMP_ENVELOPE_MIN/AMP_ENVELOPE_MAX, 1.0f/releaseCount);
return true;
}
void CompressorState::update(const ALCcontext*, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)

View File

@ -37,17 +37,16 @@ struct DedicatedState final : public EffectState {
float mTargetGains[MAX_OUTPUT_CHANNELS];
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
DEF_NEWDEL(DedicatedState)
};
bool DedicatedState::deviceUpdate(const ALCdevice*)
void DedicatedState::deviceUpdate(const ALCdevice*)
{
std::fill(std::begin(mCurrentGains), std::end(mCurrentGains), 0.0f);
return true;
}
void DedicatedState::update(const ALCcontext*, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)

View File

@ -46,18 +46,17 @@ struct DistortionState final : public EffectState {
float mBuffer[2][BUFFERSIZE]{};
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
DEF_NEWDEL(DistortionState)
};
bool DistortionState::deviceUpdate(const ALCdevice*)
void DistortionState::deviceUpdate(const ALCdevice*)
{
mLowpass.clear();
mBandpass.clear();
return true;
}
void DistortionState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)

View File

@ -57,14 +57,14 @@ struct EchoState final : public EffectState {
alignas(16) float mTempBuffer[2][BUFFERSIZE];
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
DEF_NEWDEL(EchoState)
};
bool EchoState::deviceUpdate(const ALCdevice *Device)
void EchoState::deviceUpdate(const ALCdevice *Device)
{
const auto frequency = static_cast<float>(Device->Frequency);
@ -73,10 +73,7 @@ bool EchoState::deviceUpdate(const ALCdevice *Device)
const ALuint maxlen{NextPowerOf2(float2uint(AL_ECHO_MAX_DELAY*frequency + 0.5f) +
float2uint(AL_ECHO_MAX_LRDELAY*frequency + 0.5f))};
if(maxlen != mSampleBuffer.size())
{
mSampleBuffer.resize(maxlen);
mSampleBuffer.shrink_to_fit();
}
al::vector<float,16>(maxlen).swap(mSampleBuffer);
std::fill(mSampleBuffer.begin(), mSampleBuffer.end(), 0.0f);
for(auto &e : mGains)
@ -84,8 +81,6 @@ bool EchoState::deviceUpdate(const ALCdevice *Device)
std::fill(std::begin(e.Current), std::end(e.Current), 0.0f);
std::fill(std::begin(e.Target), std::end(e.Target), 0.0f);
}
return true;
}
void EchoState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)

View File

@ -91,22 +91,20 @@ struct EqualizerState final : public EffectState {
FloatBufferLine mSampleBuffer{};
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
DEF_NEWDEL(EqualizerState)
};
bool EqualizerState::deviceUpdate(const ALCdevice*)
void EqualizerState::deviceUpdate(const ALCdevice*)
{
for(auto &e : mChans)
{
std::for_each(std::begin(e.filter), std::end(e.filter),
std::mem_fn(&BiquadFilter::clear));
std::for_each(std::begin(e.filter), std::end(e.filter), std::mem_fn(&BiquadFilter::clear));
std::fill(std::begin(e.CurrentGains), std::end(e.CurrentGains), 0.0f);
}
return true;
}
void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)

View File

@ -82,14 +82,14 @@ struct FshifterState final : public EffectState {
} mGains[2];
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
DEF_NEWDEL(FshifterState)
};
bool FshifterState::deviceUpdate(const ALCdevice*)
void FshifterState::deviceUpdate(const ALCdevice*)
{
/* (Re-)initializing parameters and clear the buffers. */
mCount = FIFO_LATENCY;
@ -107,8 +107,6 @@ bool FshifterState::deviceUpdate(const ALCdevice*)
std::fill(std::begin(gain.Current), std::end(gain.Current), 0.0f);
std::fill(std::begin(gain.Target), std::end(gain.Target), 0.0f);
}
return true;
}
void FshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)

View File

@ -82,21 +82,20 @@ struct ModulatorState final : public EffectState {
} mChans[MAX_AMBI_CHANNELS];
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
DEF_NEWDEL(ModulatorState)
};
bool ModulatorState::deviceUpdate(const ALCdevice*)
void ModulatorState::deviceUpdate(const ALCdevice*)
{
for(auto &e : mChans)
{
e.Filter.clear();
std::fill(std::begin(e.CurrentGains), std::end(e.CurrentGains), 0.0f);
}
return true;
}
void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)

View File

@ -18,7 +18,7 @@ struct NullState final : public EffectState {
NullState();
~NullState() override;
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
@ -40,9 +40,8 @@ NullState::~NullState() = default;
* format) have been changed. Will always be followed by a call to the update
* method, if successful.
*/
bool NullState::deviceUpdate(const ALCdevice* /*device*/)
void NullState::deviceUpdate(const ALCdevice* /*device*/)
{
return true;
}
/* This updates the effect state with new properties. This is called any time

View File

@ -96,14 +96,14 @@ struct PshifterState final : public EffectState {
float mTargetGains[MAX_OUTPUT_CHANNELS];
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
DEF_NEWDEL(PshifterState)
};
bool PshifterState::deviceUpdate(const ALCdevice *device)
void PshifterState::deviceUpdate(const ALCdevice *device)
{
/* (Re-)initializing parameters and clear the buffers. */
mCount = FIFO_LATENCY;
@ -121,8 +121,6 @@ bool PshifterState::deviceUpdate(const ALCdevice *device)
std::fill(std::begin(mCurrentGains), std::end(mCurrentGains), 0.0f);
std::fill(std::begin(mTargetGains), std::end(mTargetGains), 0.0f);
return true;
}
void PshifterState::update(const ALCcontext*, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)

View File

@ -531,7 +531,7 @@ struct ReverbState final : public EffectState {
void lateFaded(const size_t offset, const size_t todo, const float fade,
const float fadeStep);
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
@ -597,10 +597,10 @@ void ReverbState::allocLines(const float frequency)
totalSamples += mLate.Delay.calcLineLength(length, totalSamples, frequency, 1);
if(totalSamples != mSampleBuffer.size())
decltype(mSampleBuffer){totalSamples}.swap(mSampleBuffer);
decltype(mSampleBuffer)(totalSamples).swap(mSampleBuffer);
/* Clear the sample buffer. */
std::fill(mSampleBuffer.begin(), mSampleBuffer.end(), std::array<float,NUM_LINES>{});
std::fill(mSampleBuffer.begin(), mSampleBuffer.end(), decltype(mSampleBuffer)::value_type{});
/* Update all delays to reflect the new sample buffer. */
mDelay.realizeLineOffset(mSampleBuffer.data());
@ -610,7 +610,7 @@ void ReverbState::allocLines(const float frequency)
mLate.Delay.realizeLineOffset(mSampleBuffer.data());
}
bool ReverbState::deviceUpdate(const ALCdevice *device)
void ReverbState::deviceUpdate(const ALCdevice *device)
{
const auto frequency = static_cast<float>(device->Frequency);
@ -678,8 +678,6 @@ bool ReverbState::deviceUpdate(const ALCdevice *device)
mAmbiSplitter[0][0].init(400.0f / frequency);
std::fill(mAmbiSplitter[0].begin()+1, mAmbiSplitter[0].end(), mAmbiSplitter[0][0]);
std::fill(mAmbiSplitter[1].begin(), mAmbiSplitter[1].end(), mAmbiSplitter[0][0]);
return true;
}
/**************************************

View File

@ -135,7 +135,7 @@ struct VmorpherState final : public EffectState {
float mSampleBufferA[MAX_UPDATE_SAMPLES]{};
float mSampleBufferB[MAX_UPDATE_SAMPLES]{};
bool deviceUpdate(const ALCdevice *device) override;
void deviceUpdate(const ALCdevice *device) 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;
@ -193,7 +193,7 @@ std::array<FormantFilter,4> VmorpherState::getFiltersByPhoneme(ALenum phoneme, f
}
bool VmorpherState::deviceUpdate(const ALCdevice* /*device*/)
void VmorpherState::deviceUpdate(const ALCdevice* /*device*/)
{
for(auto &e : mChans)
{
@ -203,8 +203,6 @@ bool VmorpherState::deviceUpdate(const ALCdevice* /*device*/)
std::mem_fn(&FormantFilter::clear));
std::fill(std::begin(e.CurrentGains), std::end(e.CurrentGains), 0.0f);
}
return true;
}
void VmorpherState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)