Use a unique_ptr for Uhj2Encoder
This commit is contained in:
parent
dfcc98afbf
commit
eefc379a23
@ -48,6 +48,7 @@
|
||||
#include "alError.h"
|
||||
#include "mastering.h"
|
||||
#include "bformatdec.h"
|
||||
#include "uhjfilter.h"
|
||||
#include "alu.h"
|
||||
#include "alconfig.h"
|
||||
#include "ringbuffer.h"
|
||||
@ -1987,7 +1988,6 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
||||
if((device->Flags&DEVICE_RUNNING))
|
||||
return ALC_NO_ERROR;
|
||||
|
||||
al_free(device->Uhj_Encoder);
|
||||
device->Uhj_Encoder = nullptr;
|
||||
|
||||
al_free(device->Bs2b);
|
||||
@ -2428,9 +2428,6 @@ ALCdevice_struct::~ALCdevice_struct()
|
||||
al_free(Bs2b);
|
||||
Bs2b = nullptr;
|
||||
|
||||
al_free(Uhj_Encoder);
|
||||
Uhj_Encoder = nullptr;
|
||||
|
||||
bformatdec_free(&AmbiDecoder);
|
||||
ambiup_free(&AmbiUp);
|
||||
|
||||
|
@ -162,7 +162,7 @@ void ProcessUhj(ALCdevice *device, ALsizei SamplesToDo)
|
||||
assert(lidx != -1 && ridx != -1);
|
||||
|
||||
/* Encode to stereo-compatible 2-channel UHJ output. */
|
||||
EncodeUhj2(device->Uhj_Encoder,
|
||||
EncodeUhj2(device->Uhj_Encoder.get(),
|
||||
device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx],
|
||||
device->Dry.Buffer, SamplesToDo
|
||||
);
|
||||
|
@ -1199,7 +1199,7 @@ no_hrtf:
|
||||
}
|
||||
if(device->Render_Mode == NormalRender)
|
||||
{
|
||||
device->Uhj_Encoder = reinterpret_cast<Uhj2Encoder*>(al_calloc(16, sizeof(Uhj2Encoder)));
|
||||
device->Uhj_Encoder.reset(new Uhj2Encoder{});
|
||||
TRACE("UHJ enabled\n");
|
||||
InitUhjPanning(device);
|
||||
return;
|
||||
|
@ -4,14 +4,12 @@
|
||||
#include "AL/al.h"
|
||||
|
||||
#include "alMain.h"
|
||||
#include "almalloc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct AllPassState {
|
||||
ALfloat z[2];
|
||||
} AllPassState;
|
||||
struct AllPassState {
|
||||
ALfloat z[2]{0.0f, 0.0f};
|
||||
};
|
||||
|
||||
/* Encoding 2-channel UHJ from B-Format is done as:
|
||||
*
|
||||
@ -38,20 +36,18 @@ typedef struct AllPassState {
|
||||
* other inputs.
|
||||
*/
|
||||
|
||||
typedef struct Uhj2Encoder {
|
||||
struct Uhj2Encoder {
|
||||
AllPassState Filter1_Y[4];
|
||||
AllPassState Filter2_WX[4];
|
||||
AllPassState Filter1_WX[4];
|
||||
ALfloat LastY, LastWX;
|
||||
} Uhj2Encoder;
|
||||
ALfloat LastY{0.0f}, LastWX{0.0f};
|
||||
|
||||
DEF_NEWDEL(Uhj2Encoder)
|
||||
};
|
||||
|
||||
/* Encodes a 2-channel UHJ (stereo-compatible) signal from a B-Format input
|
||||
* signal. The input must use FuMa channel ordering and scaling.
|
||||
*/
|
||||
void EncodeUhj2(Uhj2Encoder *enc, ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, ALfloat (*RESTRICT InSamples)[BUFFERSIZE], ALsizei SamplesToDo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* UHJFILTER_H */
|
||||
|
@ -207,6 +207,7 @@ struct ALbuffer;
|
||||
struct ALeffect;
|
||||
struct ALfilter;
|
||||
struct EffectState;
|
||||
struct Uhj2Encoder;
|
||||
|
||||
|
||||
#define DEFAULT_OUTPUT_RATE (44100)
|
||||
@ -669,7 +670,7 @@ struct ALCdevice_struct {
|
||||
ALCenum HrtfStatus{ALC_FALSE};
|
||||
|
||||
/* UHJ encoder state */
|
||||
struct Uhj2Encoder *Uhj_Encoder{nullptr};
|
||||
std::unique_ptr<Uhj2Encoder> Uhj_Encoder;
|
||||
|
||||
/* High quality Ambisonic decoder */
|
||||
struct BFormatDec *AmbiDecoder{nullptr};
|
||||
|
Loading…
x
Reference in New Issue
Block a user