diff options
-rw-r--r-- | Alc/alc.cpp | 6 | ||||
-rw-r--r-- | Alc/alu.cpp | 2 | ||||
-rw-r--r-- | Alc/panning.cpp | 6 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 3 | ||||
-rw-r--r-- | OpenAL32/Include/bs2b.h | 22 |
5 files changed, 16 insertions, 23 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index d96f6df0..4c724fd6 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -53,6 +53,7 @@ #include "alconfig.h" #include "ringbuffer.h" #include "filters/splitter.h" +#include "bs2b.h" #include "fpu_modes.h" #include "cpu_caps.h" @@ -1990,8 +1991,6 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) return ALC_NO_ERROR; device->Uhj_Encoder = nullptr; - - al_free(device->Bs2b); device->Bs2b = nullptr; device->ChannelDelay.clear(); @@ -2421,9 +2420,6 @@ ALCdevice_struct::~ALCdevice_struct() HrtfHandle = nullptr; al_free(Hrtf); Hrtf = nullptr; - - al_free(Bs2b); - Bs2b = nullptr; } diff --git a/Alc/alu.cpp b/Alc/alu.cpp index 9372da85..a8f2f402 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -175,7 +175,7 @@ void ProcessBs2b(ALCdevice *device, ALsizei SamplesToDo) assert(lidx != -1 && ridx != -1); /* Apply binaural/crossfeed filter */ - bs2b_cross_feed(device->Bs2b, device->RealOut.Buffer[lidx], + bs2b_cross_feed(device->Bs2b.get(), device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx], SamplesToDo); } diff --git a/Alc/panning.cpp b/Alc/panning.cpp index e9a410e1..29c708f6 100644 --- a/Alc/panning.cpp +++ b/Alc/panning.cpp @@ -1163,7 +1163,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf no_hrtf: if(old_hrtf) Hrtf_DecRef(old_hrtf); - old_hrtf = NULL; + old_hrtf = nullptr; TRACE("HRTF disabled\n"); device->Render_Mode = StereoPair; @@ -1176,8 +1176,8 @@ no_hrtf: ConfigValueInt(device->DeviceName.c_str(), NULL, "cf_level", &bs2blevel); if(bs2blevel > 0 && bs2blevel <= 6) { - device->Bs2b = reinterpret_cast<struct bs2b*>(al_calloc(16, sizeof(*device->Bs2b))); - bs2b_set_params(device->Bs2b, bs2blevel, device->Frequency); + device->Bs2b.reset(new bs2b{}); + bs2b_set_params(device->Bs2b.get(), bs2blevel, device->Frequency); TRACE("BS2B enabled\n"); InitPanning(device); return; diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index de602d35..3fdd4e02 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -210,6 +210,7 @@ struct EffectState; struct Uhj2Encoder; struct BFormatDec; struct AmbiUpsampler; +struct bs2b; #define DEFAULT_OUTPUT_RATE (44100) @@ -678,7 +679,7 @@ struct ALCdevice_struct { std::unique_ptr<BFormatDec> AmbiDecoder; /* Stereo-to-binaural filter */ - struct bs2b *Bs2b{nullptr}; + std::unique_ptr<bs2b> Bs2b; /* First-order ambisonic upsampler for higher-order output */ std::unique_ptr<AmbiUpsampler> AmbiUp; diff --git a/OpenAL32/Include/bs2b.h b/OpenAL32/Include/bs2b.h index 13cdf9a6..e235e765 100644 --- a/OpenAL32/Include/bs2b.h +++ b/OpenAL32/Include/bs2b.h @@ -24,6 +24,8 @@ #ifndef BS2B_H #define BS2B_H +#include "almalloc.h" + /* Number of crossfeed levels */ #define BS2B_CLEVELS 3 @@ -42,10 +44,6 @@ /* Default sample rate (Hz) */ #define BS2B_DEFAULT_SRATE 44100 -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - struct bs2b { int level; /* Crossfeed level */ int srate; /* Sample rate (Hz) */ @@ -67,6 +65,8 @@ struct bs2b { float lo; float hi; } last_sample[2]; + + DEF_NEWDEL(bs2b) }; /* Clear buffers and set new coefficients with new crossfeed level and sample @@ -74,21 +74,17 @@ struct bs2b { * level - crossfeed level of *LEVEL values. * srate - sample rate by Hz. */ -void bs2b_set_params(struct bs2b *bs2b, int level, int srate); +void bs2b_set_params(bs2b *bs2b, int level, int srate); /* Return current crossfeed level value */ -int bs2b_get_level(struct bs2b *bs2b); +int bs2b_get_level(bs2b *bs2b); /* Return current sample rate value */ -int bs2b_get_srate(struct bs2b *bs2b); +int bs2b_get_srate(bs2b *bs2b); /* Clear buffer */ -void bs2b_clear(struct bs2b *bs2b); - -void bs2b_cross_feed(struct bs2b *bs2b, float *RESTRICT Left, float *RESTRICT Right, int SamplesToDo); +void bs2b_clear(bs2b *bs2b); -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ +void bs2b_cross_feed(bs2b *bs2b, float *RESTRICT Left, float *RESTRICT Right, int SamplesToDo); #endif /* BS2B_H */ |