aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-17 01:53:39 -0800
committerChris Robinson <[email protected]>2018-11-17 01:53:39 -0800
commitaa66ed0ea54b282f7b547ebecfa716927aa02cd1 (patch)
tree486f292938d5f3c91c60c2cfd990c228965ee88e /Alc/effects
parenta7d3c24b511be49d8d0917d5030a0f378af8da87 (diff)
Convert modulator.c to C++
Diffstat (limited to 'Alc/effects')
-rw-r--r--Alc/effects/modulator.cpp (renamed from Alc/effects/modulator.c)21
1 files changed, 12 insertions, 9 deletions
diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.cpp
index 87799dd7..19513add 100644
--- a/Alc/effects/modulator.c
+++ b/Alc/effects/modulator.cpp
@@ -32,9 +32,7 @@
#define MAX_UPDATE_SAMPLES 128
-typedef struct ALmodulatorState {
- DERIVE_FROM_TYPE(ALeffectState);
-
+struct ALmodulatorState final : public ALeffectState {
void (*GetSamples)(ALfloat*RESTRICT, ALsizei, const ALsizei, ALsizei);
ALsizei index;
@@ -46,7 +44,7 @@ typedef struct ALmodulatorState {
ALfloat CurrentGains[MAX_OUTPUT_CHANNELS];
ALfloat TargetGains[MAX_OUTPUT_CHANNELS];
} Chans[MAX_EFFECT_CHANNELS];
-} ALmodulatorState;
+};
static ALvoid ALmodulatorState_Destruct(ALmodulatorState *state);
static ALboolean ALmodulatorState_deviceUpdate(ALmodulatorState *state, ALCdevice *device);
@@ -104,6 +102,7 @@ DECL_TEMPLATE(One)
static void ALmodulatorState_Construct(ALmodulatorState *state)
{
+ new (state) ALmodulatorState{};
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
SET_VTABLE2(ALmodulatorState, ALeffectState, state);
@@ -114,6 +113,7 @@ static void ALmodulatorState_Construct(ALmodulatorState *state)
static ALvoid ALmodulatorState_Destruct(ALmodulatorState *state)
{
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
+ state->~ALmodulatorState();
}
static ALboolean ALmodulatorState_deviceUpdate(ALmodulatorState *state, ALCdevice *UNUSED(device))
@@ -194,9 +194,9 @@ static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALsizei SamplesT
}
-typedef struct ModulatorStateFactory {
- DERIVE_FROM_TYPE(EffectStateFactory);
-} ModulatorStateFactory;
+struct ModulatorStateFactory final : public EffectStateFactory {
+ ModulatorStateFactory() noexcept;
+};
static ALeffectState *ModulatorStateFactory_create(ModulatorStateFactory *UNUSED(factory))
{
@@ -210,10 +210,13 @@ static ALeffectState *ModulatorStateFactory_create(ModulatorStateFactory *UNUSED
DEFINE_EFFECTSTATEFACTORY_VTABLE(ModulatorStateFactory);
+ModulatorStateFactory::ModulatorStateFactory() noexcept
+ : EffectStateFactory{GET_VTABLE2(ModulatorStateFactory, EffectStateFactory)}
+{ }
+
EffectStateFactory *ModulatorStateFactory_getFactory(void)
{
- static ModulatorStateFactory ModulatorFactory = { { GET_VTABLE2(ModulatorStateFactory, EffectStateFactory) } };
-
+ static ModulatorStateFactory ModulatorFactory{};
return STATIC_CAST(EffectStateFactory, &ModulatorFactory);
}