aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-22 04:53:29 -0800
committerChris Robinson <[email protected]>2018-11-22 04:53:29 -0800
commit671ed1abf8cc246c6e2b5f9ae3bac132fb9af519 (patch)
tree66402274da934f19f30da30b2acb8a25a6958a53
parentcc3e2a838f245770af3d773e8d2c461b9912e392 (diff)
Use a unique_ptr for the FrontStablizer
-rw-r--r--Alc/alc.cpp4
-rw-r--r--Alc/alu.cpp2
-rw-r--r--Alc/filters/splitter.h32
-rw-r--r--Alc/panning.cpp12
-rw-r--r--OpenAL32/Include/alMain.h2
5 files changed, 22 insertions, 30 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index b942064f..9e4d1ac9 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -52,6 +52,7 @@
#include "alu.h"
#include "alconfig.h"
#include "ringbuffer.h"
+#include "filters/splitter.h"
#include "fpu_modes.h"
#include "cpu_caps.h"
@@ -2426,9 +2427,6 @@ ALCdevice_struct::~ALCdevice_struct()
bformatdec_free(&AmbiDecoder);
ambiup_free(&AmbiUp);
-
- al_free(Stablizer);
- Stablizer = nullptr;
}
diff --git a/Alc/alu.cpp b/Alc/alu.cpp
index 4d3ad9b2..da9d10f2 100644
--- a/Alc/alu.cpp
+++ b/Alc/alu.cpp
@@ -1779,7 +1779,7 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples)
int cidx = GetChannelIdxByName(&device->RealOut, FrontCenter);
assert(lidx >= 0 && ridx >= 0 && cidx >= 0);
- ApplyStablizer(device->Stablizer, device->RealOut.Buffer, lidx, ridx, cidx,
+ ApplyStablizer(device->Stablizer.get(), device->RealOut.Buffer, lidx, ridx, cidx,
SamplesToDo, device->RealOut.NumChannels);
}
diff --git a/Alc/filters/splitter.h b/Alc/filters/splitter.h
index a996917c..13f4cd55 100644
--- a/Alc/filters/splitter.h
+++ b/Alc/filters/splitter.h
@@ -2,18 +2,16 @@
#define FILTER_SPLITTER_H
#include "alMain.h"
+#include "almalloc.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
/* Band splitter. Splits a signal into two phase-matching frequency bands. */
-typedef struct BandSplitter {
- ALfloat coeff;
- ALfloat lp_z1;
- ALfloat lp_z2;
- ALfloat hp_z1;
-} BandSplitter;
+struct BandSplitter {
+ ALfloat coeff{0.0f};
+ ALfloat lp_z1{0.0f};
+ ALfloat lp_z2{0.0f};
+ ALfloat hp_z1{0.0f};
+};
void bandsplit_init(BandSplitter *splitter, ALfloat f0norm);
void bandsplit_clear(BandSplitter *splitter);
@@ -23,25 +21,23 @@ void bandsplit_process(BandSplitter *splitter, ALfloat *RESTRICT hpout, ALfloat
/* The all-pass portion of the band splitter. Applies the same phase shift
* without splitting the signal.
*/
-typedef struct SplitterAllpass {
- ALfloat coeff;
- ALfloat z1;
-} SplitterAllpass;
+struct SplitterAllpass {
+ ALfloat coeff{0.0f};
+ ALfloat z1{0.0f};
+};
void splitterap_init(SplitterAllpass *splitter, ALfloat f0norm);
void splitterap_clear(SplitterAllpass *splitter);
void splitterap_process(SplitterAllpass *splitter, ALfloat *RESTRICT samples, ALsizei count);
-typedef struct FrontStablizer {
+struct FrontStablizer {
SplitterAllpass APFilter[MAX_OUTPUT_CHANNELS];
BandSplitter LFilter, RFilter;
alignas(16) ALfloat LSplit[2][BUFFERSIZE];
alignas(16) ALfloat RSplit[2][BUFFERSIZE];
-} FrontStablizer;
-#ifdef __cplusplus
-} // extern "C"
-#endif
+ DEF_NEWDEL(FrontStablizer)
+};
#endif /* FILTER_SPLITTER_H */
diff --git a/Alc/panning.cpp b/Alc/panning.cpp
index c167c227..4ffdf969 100644
--- a/Alc/panning.cpp
+++ b/Alc/panning.cpp
@@ -931,8 +931,8 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf
size_t i;
al_free(device->Hrtf);
- device->Hrtf = NULL;
- device->HrtfHandle = NULL;
+ device->Hrtf = nullptr;
+ device->HrtfHandle = nullptr;
device->HrtfName.clear();
device->Render_Mode = NormalRender;
@@ -945,8 +945,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf
device->AvgSpeakerDist = 0.0f;
device->ChannelDelay.clear();
- al_free(device->Stablizer);
- device->Stablizer = NULL;
+ device->Stablizer = nullptr;
if(device->FmtChans != DevFmtStereo)
{
@@ -1035,8 +1034,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf
* higher).
*/
ALfloat scale = (ALfloat)(5000.0 / device->Frequency);
- FrontStablizer *stablizer = reinterpret_cast<FrontStablizer*>(
- al_calloc(16, sizeof(*stablizer)));
+ std::unique_ptr<FrontStablizer> stablizer{new FrontStablizer{}};
bandsplit_init(&stablizer->LFilter, scale);
stablizer->RFilter = stablizer->LFilter;
@@ -1046,7 +1044,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf
for(i = 1;i < (size_t)device->RealOut.NumChannels;i++)
stablizer->APFilter[i] = stablizer->APFilter[0];
- device->Stablizer = stablizer;
+ device->Stablizer = std::move(stablizer);
}
break;
case DevFmtMono:
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 41465c1d..c57d87ba 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -709,7 +709,7 @@ struct ALCdevice_struct {
*/
RealMixParams RealOut;
- struct FrontStablizer *Stablizer{nullptr};
+ std::unique_ptr<FrontStablizer> Stablizer;
std::unique_ptr<Compressor> Limiter;