diff options
author | Chris Robinson <[email protected]> | 2019-03-22 13:33:58 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-03-22 15:00:37 -0700 |
commit | e7e585f65c43e2ccd2ae71c36c4940f4b2efa80a (patch) | |
tree | 4851d04798701f67e3c6ca437111129cedaf9f65 /Alc/effects/dedicated.cpp | |
parent | f951f4a66b3e9cc8db7ab190b8443fa6c834fee7 (diff) |
Use the effect state factory to set the default effect props
Diffstat (limited to 'Alc/effects/dedicated.cpp')
-rw-r--r-- | Alc/effects/dedicated.cpp | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/Alc/effects/dedicated.cpp b/Alc/effects/dedicated.cpp index 041e951b..7fc46b12 100644 --- a/Alc/effects/dedicated.cpp +++ b/Alc/effects/dedicated.cpp @@ -33,7 +33,7 @@ namespace { -struct ALdedicatedState final : public EffectState { +struct DedicatedState final : public EffectState { ALfloat mCurrentGains[MAX_OUTPUT_CHANNELS]; ALfloat mTargetGains[MAX_OUTPUT_CHANNELS]; @@ -42,16 +42,16 @@ struct ALdedicatedState final : public EffectState { void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; - DEF_NEWDEL(ALdedicatedState) + DEF_NEWDEL(DedicatedState) }; -ALboolean ALdedicatedState::deviceUpdate(const ALCdevice *UNUSED(device)) +ALboolean DedicatedState::deviceUpdate(const ALCdevice *UNUSED(device)) { std::fill(std::begin(mCurrentGains), std::end(mCurrentGains), 0.0f); return AL_TRUE; } -void ALdedicatedState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) +void DedicatedState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) { std::fill(std::begin(mTargetGains), std::end(mTargetGains), 0.0f); @@ -90,42 +90,18 @@ void ALdedicatedState::update(const ALCcontext* UNUSED(context), const ALeffects } } -void ALdedicatedState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) +void DedicatedState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { MixSamples(samplesIn[0], numOutput, samplesOut, mCurrentGains, mTargetGains, samplesToDo, 0, samplesToDo); } -struct DedicatedStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *DedicatedStateFactory::create() -{ return new ALdedicatedState{}; } - -ALeffectProps DedicatedStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Dedicated.Gain = 1.0f; - return props; -} - -} // namespace - -EffectStateFactory *DedicatedStateFactory_getFactory() -{ - static DedicatedStateFactory DedicatedFactory{}; - return &DedicatedFactory; -} - - -void ALdedicated_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) +void Dedicated_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param); } -void ALdedicated_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint *UNUSED(vals)) +void Dedicated_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x", param); } -void ALdedicated_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) +void Dedicated_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { ALeffectProps *props = &effect->Props; switch(param) @@ -140,14 +116,14 @@ void ALdedicated_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, alSetError(context, AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param); } } -void ALdedicated_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ ALdedicated_setParamf(effect, context, param, vals[0]); } +void Dedicated_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) +{ Dedicated_setParamf(effect, context, param, vals[0]); } -void ALdedicated_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) +void Dedicated_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param); } -void ALdedicated_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) +void Dedicated_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x", param); } -void ALdedicated_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) +void Dedicated_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -160,7 +136,29 @@ void ALdedicated_getParamf(const ALeffect *effect, ALCcontext *context, ALenum p alSetError(context, AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param); } } -void ALdedicated_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ ALdedicated_getParamf(effect, context, param, vals); } +void Dedicated_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +{ Dedicated_getParamf(effect, context, param, vals); } -DEFINE_ALEFFECT_VTABLE(ALdedicated); +DEFINE_ALEFFECT_VTABLE(Dedicated); + + +struct DedicatedStateFactory final : public EffectStateFactory { + EffectState *create() override { return new DedicatedState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Dedicated_vtable; } +}; + +ALeffectProps DedicatedStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + props.Dedicated.Gain = 1.0f; + return props; +} + +} // namespace + +EffectStateFactory *DedicatedStateFactory_getFactory() +{ + static DedicatedStateFactory DedicatedFactory{}; + return &DedicatedFactory; +} |