aboutsummaryrefslogtreecommitdiffstats
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
parenta7d3c24b511be49d8d0917d5030a0f378af8da87 (diff)
Convert modulator.c to C++
-rw-r--r--Alc/effects/modulator.cpp (renamed from Alc/effects/modulator.c)21
-rw-r--r--CMakeLists.txt2
2 files changed, 13 insertions, 10 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);
}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d5b1d005..9bc240d4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -819,7 +819,7 @@ SET(ALC_OBJS
Alc/effects/echo.c
Alc/effects/equalizer.c
Alc/effects/fshifter.c
- Alc/effects/modulator.c
+ Alc/effects/modulator.cpp
Alc/effects/null.cpp
Alc/effects/pshifter.cpp
Alc/effects/reverb.cpp