aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-17 06:53:20 -0800
committerChris Robinson <[email protected]>2018-11-17 06:53:20 -0800
commit93d96ced9cef7200b04dbfec51325a3c9c55af19 (patch)
treeefea25569bc6e5df48a4837ad276a96cc6e44c3c /Alc
parentad34855a2bb9312d3f21ff3fdca20bca767b9224 (diff)
Convert the dedicated, distortion, echo, and equalizer to C++
Diffstat (limited to 'Alc')
-rw-r--r--Alc/effects/dedicated.cpp (renamed from Alc/effects/dedicated.c)21
-rw-r--r--Alc/effects/distortion.cpp (renamed from Alc/effects/distortion.c)21
-rw-r--r--Alc/effects/echo.cpp (renamed from Alc/effects/echo.c)24
-rw-r--r--Alc/effects/equalizer.cpp (renamed from Alc/effects/equalizer.c)22
4 files changed, 51 insertions, 37 deletions
diff --git a/Alc/effects/dedicated.c b/Alc/effects/dedicated.cpp
index 59c13b77..dd250e64 100644
--- a/Alc/effects/dedicated.c
+++ b/Alc/effects/dedicated.cpp
@@ -29,12 +29,10 @@
#include "filters/defs.h"
-typedef struct ALdedicatedState {
- DERIVE_FROM_TYPE(ALeffectState);
-
+struct ALdedicatedState final : public ALeffectState {
ALfloat CurrentGains[MAX_OUTPUT_CHANNELS];
ALfloat TargetGains[MAX_OUTPUT_CHANNELS];
-} ALdedicatedState;
+};
static ALvoid ALdedicatedState_Destruct(ALdedicatedState *state);
static ALboolean ALdedicatedState_deviceUpdate(ALdedicatedState *state, ALCdevice *device);
@@ -47,6 +45,7 @@ DEFINE_ALEFFECTSTATE_VTABLE(ALdedicatedState);
static void ALdedicatedState_Construct(ALdedicatedState *state)
{
+ new (state) ALdedicatedState{};
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
SET_VTABLE2(ALdedicatedState, ALeffectState, state);
}
@@ -54,6 +53,7 @@ static void ALdedicatedState_Construct(ALdedicatedState *state)
static ALvoid ALdedicatedState_Destruct(ALdedicatedState *state)
{
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
+ state->~ALdedicatedState();
}
static ALboolean ALdedicatedState_deviceUpdate(ALdedicatedState *state, ALCdevice *UNUSED(device))
@@ -114,9 +114,9 @@ static ALvoid ALdedicatedState_process(ALdedicatedState *state, ALsizei SamplesT
}
-typedef struct DedicatedStateFactory {
- DERIVE_FROM_TYPE(EffectStateFactory);
-} DedicatedStateFactory;
+struct DedicatedStateFactory final : public EffectStateFactory {
+ DedicatedStateFactory() noexcept;
+};
ALeffectState *DedicatedStateFactory_create(DedicatedStateFactory *UNUSED(factory))
{
@@ -130,11 +130,14 @@ ALeffectState *DedicatedStateFactory_create(DedicatedStateFactory *UNUSED(factor
DEFINE_EFFECTSTATEFACTORY_VTABLE(DedicatedStateFactory);
+DedicatedStateFactory::DedicatedStateFactory() noexcept
+ : EffectStateFactory{GET_VTABLE2(DedicatedStateFactory, EffectStateFactory)}
+{
+}
EffectStateFactory *DedicatedStateFactory_getFactory(void)
{
- static DedicatedStateFactory DedicatedFactory = { { GET_VTABLE2(DedicatedStateFactory, EffectStateFactory) } };
-
+ static DedicatedStateFactory DedicatedFactory{};
return STATIC_CAST(EffectStateFactory, &DedicatedFactory);
}
diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.cpp
index f2a70bff..75629d9c 100644
--- a/Alc/effects/distortion.c
+++ b/Alc/effects/distortion.cpp
@@ -30,9 +30,7 @@
#include "filters/defs.h"
-typedef struct ALdistortionState {
- DERIVE_FROM_TYPE(ALeffectState);
-
+struct ALdistortionState final : public ALeffectState {
/* Effect gains for each channel */
ALfloat Gain[MAX_OUTPUT_CHANNELS];
@@ -43,7 +41,7 @@ typedef struct ALdistortionState {
ALfloat edge_coeff;
ALfloat Buffer[2][BUFFERSIZE];
-} ALdistortionState;
+};
static ALvoid ALdistortionState_Destruct(ALdistortionState *state);
static ALboolean ALdistortionState_deviceUpdate(ALdistortionState *state, ALCdevice *device);
@@ -56,6 +54,7 @@ DEFINE_ALEFFECTSTATE_VTABLE(ALdistortionState);
static void ALdistortionState_Construct(ALdistortionState *state)
{
+ new (state) ALdistortionState{};
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
SET_VTABLE2(ALdistortionState, ALeffectState, state);
}
@@ -63,6 +62,7 @@ static void ALdistortionState_Construct(ALdistortionState *state)
static ALvoid ALdistortionState_Destruct(ALdistortionState *state)
{
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
+ state->~ALdistortionState();
}
static ALboolean ALdistortionState_deviceUpdate(ALdistortionState *state, ALCdevice *UNUSED(device))
@@ -174,9 +174,9 @@ static ALvoid ALdistortionState_process(ALdistortionState *state, ALsizei Sample
}
-typedef struct DistortionStateFactory {
- DERIVE_FROM_TYPE(EffectStateFactory);
-} DistortionStateFactory;
+struct DistortionStateFactory final : public EffectStateFactory {
+ DistortionStateFactory() noexcept;
+};
static ALeffectState *DistortionStateFactory_create(DistortionStateFactory *UNUSED(factory))
{
@@ -190,11 +190,14 @@ static ALeffectState *DistortionStateFactory_create(DistortionStateFactory *UNUS
DEFINE_EFFECTSTATEFACTORY_VTABLE(DistortionStateFactory);
+DistortionStateFactory::DistortionStateFactory() noexcept
+ : EffectStateFactory{GET_VTABLE2(DistortionStateFactory, EffectStateFactory)}
+{
+}
EffectStateFactory *DistortionStateFactory_getFactory(void)
{
- static DistortionStateFactory DistortionFactory = { { GET_VTABLE2(DistortionStateFactory, EffectStateFactory) } };
-
+ static DistortionStateFactory DistortionFactory{};
return STATIC_CAST(EffectStateFactory, &DistortionFactory);
}
diff --git a/Alc/effects/echo.c b/Alc/effects/echo.cpp
index 5c323986..f987e582 100644
--- a/Alc/effects/echo.c
+++ b/Alc/effects/echo.cpp
@@ -31,9 +31,7 @@
#include "filters/defs.h"
-typedef struct ALechoState {
- DERIVE_FROM_TYPE(ALeffectState);
-
+struct ALechoState final : public ALeffectState {
ALfloat *SampleBuffer;
ALsizei BufferLength;
@@ -53,7 +51,7 @@ typedef struct ALechoState {
ALfloat FeedGain;
BiquadFilter Filter;
-} ALechoState;
+};
static ALvoid ALechoState_Destruct(ALechoState *state);
static ALboolean ALechoState_deviceUpdate(ALechoState *state, ALCdevice *Device);
@@ -66,6 +64,7 @@ DEFINE_ALEFFECTSTATE_VTABLE(ALechoState);
static void ALechoState_Construct(ALechoState *state)
{
+ new (state) ALechoState{};
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
SET_VTABLE2(ALechoState, ALeffectState, state);
@@ -84,6 +83,7 @@ static ALvoid ALechoState_Destruct(ALechoState *state)
al_free(state->SampleBuffer);
state->SampleBuffer = NULL;
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
+ state->~ALechoState();
}
static ALboolean ALechoState_deviceUpdate(ALechoState *state, ALCdevice *Device)
@@ -103,7 +103,7 @@ static ALboolean ALechoState_deviceUpdate(ALechoState *state, ALCdevice *Device)
if(!temp) return AL_FALSE;
al_free(state->SampleBuffer);
- state->SampleBuffer = temp;
+ state->SampleBuffer = static_cast<float*>(temp);
state->BufferLength = maxlen;
}
@@ -201,9 +201,9 @@ static ALvoid ALechoState_process(ALechoState *state, ALsizei SamplesToDo, const
}
-typedef struct EchoStateFactory {
- DERIVE_FROM_TYPE(EffectStateFactory);
-} EchoStateFactory;
+struct EchoStateFactory final : public EffectStateFactory {
+ EchoStateFactory() noexcept;
+};
ALeffectState *EchoStateFactory_create(EchoStateFactory *UNUSED(factory))
{
@@ -217,10 +217,14 @@ ALeffectState *EchoStateFactory_create(EchoStateFactory *UNUSED(factory))
DEFINE_EFFECTSTATEFACTORY_VTABLE(EchoStateFactory);
-EffectStateFactory *EchoStateFactory_getFactory(void)
+EchoStateFactory::EchoStateFactory() noexcept
+ : EffectStateFactory{GET_VTABLE2(EchoStateFactory, EffectStateFactory)}
{
- static EchoStateFactory EchoFactory = { { GET_VTABLE2(EchoStateFactory, EffectStateFactory) } };
+}
+EffectStateFactory *EchoStateFactory_getFactory(void)
+{
+ static EchoStateFactory EchoFactory{};
return STATIC_CAST(EffectStateFactory, &EchoFactory);
}
diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.cpp
index c62f8e80..8388a123 100644
--- a/Alc/effects/equalizer.c
+++ b/Alc/effects/equalizer.cpp
@@ -72,9 +72,7 @@
* http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt */
-typedef struct ALequalizerState {
- DERIVE_FROM_TYPE(ALeffectState);
-
+struct ALequalizerState final : public ALeffectState {
struct {
/* Effect parameters */
BiquadFilter filter[4];
@@ -85,7 +83,7 @@ typedef struct ALequalizerState {
} Chans[MAX_EFFECT_CHANNELS];
ALfloat SampleBuffer[MAX_EFFECT_CHANNELS][BUFFERSIZE];
-} ALequalizerState;
+};
static ALvoid ALequalizerState_Destruct(ALequalizerState *state);
static ALboolean ALequalizerState_deviceUpdate(ALequalizerState *state, ALCdevice *device);
@@ -98,6 +96,7 @@ DEFINE_ALEFFECTSTATE_VTABLE(ALequalizerState);
static void ALequalizerState_Construct(ALequalizerState *state)
{
+ new (state) ALequalizerState{};
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
SET_VTABLE2(ALequalizerState, ALeffectState, state);
}
@@ -105,6 +104,7 @@ static void ALequalizerState_Construct(ALequalizerState *state)
static ALvoid ALequalizerState_Destruct(ALequalizerState *state)
{
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
+ state->~ALequalizerState();
}
static ALboolean ALequalizerState_deviceUpdate(ALequalizerState *state, ALCdevice *UNUSED(device))
@@ -196,9 +196,9 @@ static ALvoid ALequalizerState_process(ALequalizerState *state, ALsizei SamplesT
}
-typedef struct EqualizerStateFactory {
- DERIVE_FROM_TYPE(EffectStateFactory);
-} EqualizerStateFactory;
+struct EqualizerStateFactory final : public EffectStateFactory {
+ EqualizerStateFactory() noexcept;
+};
ALeffectState *EqualizerStateFactory_create(EqualizerStateFactory *UNUSED(factory))
{
@@ -212,10 +212,14 @@ ALeffectState *EqualizerStateFactory_create(EqualizerStateFactory *UNUSED(factor
DEFINE_EFFECTSTATEFACTORY_VTABLE(EqualizerStateFactory);
-EffectStateFactory *EqualizerStateFactory_getFactory(void)
+EqualizerStateFactory::EqualizerStateFactory() noexcept
+ : EffectStateFactory{GET_VTABLE2(EqualizerStateFactory, EffectStateFactory)}
{
- static EqualizerStateFactory EqualizerFactory = { { GET_VTABLE2(EqualizerStateFactory, EffectStateFactory) } };
+}
+EffectStateFactory *EqualizerStateFactory_getFactory(void)
+{
+ static EqualizerStateFactory EqualizerFactory{};
return STATIC_CAST(EffectStateFactory, &EqualizerFactory);
}