diff options
author | Chris Robinson <[email protected]> | 2018-11-22 07:54:29 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-22 07:54:29 -0800 |
commit | 9c155a57fb37e3869f16e2f6502ee7d95d7d6a75 (patch) | |
tree | 268be0a8db18d013476b6e19dd6d60969a2b1e6c | |
parent | ba8c865513d33019962a02e00ab496365de17abf (diff) |
Use unique_ptr for DirectHrtfState
-rw-r--r-- | Alc/alc.cpp | 2 | ||||
-rw-r--r-- | Alc/alu.cpp | 2 | ||||
-rw-r--r-- | Alc/hrtf.h | 3 | ||||
-rw-r--r-- | Alc/panning.cpp | 9 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 2 |
5 files changed, 9 insertions, 9 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 10b4c007..42856dbf 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -2418,8 +2418,6 @@ ALCdevice_struct::~ALCdevice_struct() if(HrtfHandle) Hrtf_DecRef(HrtfHandle); HrtfHandle = nullptr; - al_free(mHrtfState); - mHrtfState = nullptr; } diff --git a/Alc/alu.cpp b/Alc/alu.cpp index c67e8705..fc386908 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -119,7 +119,7 @@ void ProcessHrtf(ALCdevice *device, ALsizei SamplesToDo) int ridx{GetChannelIdxByName(&device->RealOut, FrontRight)}; assert(lidx != -1 && ridx != -1); - DirectHrtfState *state{device->mHrtfState}; + DirectHrtfState *state{device->mHrtfState.get()}; for(ALsizei c{0};c < device->Dry.NumChannels;c++) { MixDirectHrtf(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx], @@ -7,6 +7,7 @@ #include "alMain.h" #include "atomic.h" #include "vector.h" +#include "almalloc.h" #define HRTF_HISTORY_BITS (6) @@ -55,6 +56,8 @@ struct DirectHrtfState { alignas(16) ALfloat Values[HRIR_LENGTH][2]; alignas(16) ALfloat Coeffs[HRIR_LENGTH][2]; } Chan[]; + + DEF_PLACE_NEWDEL() }; struct AngularPoint { diff --git a/Alc/panning.cpp b/Alc/panning.cpp index e0677600..a67234ec 100644 --- a/Alc/panning.cpp +++ b/Alc/panning.cpp @@ -857,8 +857,8 @@ static void InitHrtfPanning(ALCdevice *device) count = COUNTOF(IndexMap); } - device->mHrtfState = reinterpret_cast<DirectHrtfState*>( - al_calloc(16, FAM_SIZE(DirectHrtfState, Chan, count))); + device->mHrtfState.reset( + new (al_calloc(16, FAM_SIZE(DirectHrtfState, Chan, count))) DirectHrtfState{}); for(i = 0;i < count;i++) { @@ -892,8 +892,8 @@ static void InitHrtfPanning(ALCdevice *device) device->RealOut.NumChannels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder); BuildBFormatHrtf(device->HrtfHandle, - device->mHrtfState, device->Dry.NumChannels, AmbiPoints, AmbiMatrix, COUNTOF(AmbiPoints), - AmbiOrderHFGain + device->mHrtfState.get(), device->Dry.NumChannels, AmbiPoints, AmbiMatrix, + COUNTOF(AmbiPoints), AmbiOrderHFGain ); InitNearFieldCtrl(device, device->HrtfHandle->distance, device->AmbiUp ? 2 : 1, @@ -930,7 +930,6 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf int bs2blevel; size_t i; - al_free(device->mHrtfState); device->mHrtfState = nullptr; device->HrtfHandle = nullptr; device->HrtfName.clear(); diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 3a8e28fc..744e3609 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -666,7 +666,7 @@ struct ALCdevice_struct { POSTPROCESS PostProcess{}; /* HRTF state and info */ - DirectHrtfState *mHrtfState{nullptr}; + std::unique_ptr<DirectHrtfState> mHrtfState; std::string HrtfName; Hrtf *HrtfHandle{nullptr}; al::vector<EnumeratedHrtf> HrtfList; |