diff options
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alc.cpp | 4 | ||||
-rw-r--r-- | alc/alcmain.h | 2 | ||||
-rw-r--r-- | alc/hrtf.cpp | 48 | ||||
-rw-r--r-- | alc/hrtf.h | 8 | ||||
-rw-r--r-- | alc/panning.cpp | 8 |
5 files changed, 35 insertions, 35 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index bee42fc5..0a8a2c59 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1888,7 +1888,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(hrtf_userreq == Hrtf_Enable || (hrtf_userreq != Hrtf_Disable && hrtf_appreq == Hrtf_Enable)) { - HrtfEntry *hrtf{nullptr}; + HrtfStore *hrtf{nullptr}; if(device->HrtfList.empty()) device->HrtfList = EnumerateHrtf(device->DeviceName.c_str()); if(!device->HrtfList.empty()) @@ -1904,7 +1904,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->FmtChans = DevFmtStereo; device->Frequency = hrtf->sampleRate; device->Flags.set<ChannelsRequest, FrequencyRequest>(); - if(HrtfEntry *oldhrtf{device->mHrtf}) + if(HrtfStore *oldhrtf{device->mHrtf}) oldhrtf->DecRef(); device->mHrtf = hrtf; } diff --git a/alc/alcmain.h b/alc/alcmain.h index 30c5b835..92a1bf88 100644 --- a/alc/alcmain.h +++ b/alc/alcmain.h @@ -295,7 +295,7 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> { /* HRTF state and info */ std::unique_ptr<DirectHrtfState> mHrtfState; - HrtfEntry *mHrtf{nullptr}; + HrtfStore *mHrtf{nullptr}; /* Ambisonic-to-UHJ encoder */ std::unique_ptr<Uhj2Encoder> Uhj_Encoder; diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp index 8e416cf1..20e1fb85 100644 --- a/alc/hrtf.cpp +++ b/alc/hrtf.cpp @@ -55,7 +55,7 @@ struct HrtfHandle { - std::unique_ptr<HrtfEntry> mEntry; + std::unique_ptr<HrtfStore> mEntry; al::FlexArray<char> mFilename; HrtfHandle(size_t fname_len) : mFilename{fname_len} { } @@ -206,7 +206,7 @@ IdxBlend CalcAzIndex(ALsizei azcount, ALfloat az) /* Calculates static HRIR coefficients and delays for the given polar elevation * and azimuth in radians. The coefficients are normalized. */ -void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat distance, +void GetHrtfCoeffs(const HrtfStore *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat distance, ALfloat spread, HrirArray &coeffs, ALsizei (&delays)[2]) { const ALfloat dirfact{1.0f - (spread / al::MathDefs<float>::Tau())}; @@ -288,7 +288,7 @@ std::unique_ptr<DirectHrtfState> DirectHrtfState::Create(size_t num_chans) return std::unique_ptr<DirectHrtfState>{new (FamCount{num_chans}) DirectHrtfState{num_chans}}; } -void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, +void BuildBFormatHrtf(const HrtfStore *Hrtf, DirectHrtfState *state, const al::span<const AngularPoint> AmbiPoints, const ALfloat (*AmbiMatrix)[MAX_AMBI_CHANNELS], const ALfloat *AmbiOrderHFGain) { @@ -488,24 +488,24 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, namespace { -std::unique_ptr<HrtfEntry> CreateHrtfStore(ALuint rate, ALushort irSize, const ALuint fdCount, +std::unique_ptr<HrtfStore> CreateHrtfStore(ALuint rate, ALushort irSize, const ALuint fdCount, const ALubyte *evCount, const ALushort *distance, const ALushort *azCount, const ALushort *irOffset, ALushort irCount, const ALfloat (*coeffs)[2], const ALubyte (*delays)[2], const char *filename) { - std::unique_ptr<HrtfEntry> Hrtf; + std::unique_ptr<HrtfStore> Hrtf; ALuint evTotal{std::accumulate(evCount, evCount+fdCount, 0u)}; - size_t total{sizeof(HrtfEntry)}; - total = RoundUp(total, alignof(HrtfEntry::Field)); /* Align for field infos */ - total += sizeof(HrtfEntry::Field)*fdCount; - total = RoundUp(total, alignof(HrtfEntry::Elevation)); /* Align for elevation infos */ + size_t total{sizeof(HrtfStore)}; + total = RoundUp(total, alignof(HrtfStore::Field)); /* Align for field infos */ + total += sizeof(HrtfStore::Field)*fdCount; + total = RoundUp(total, alignof(HrtfStore::Elevation)); /* Align for elevation infos */ total += sizeof(Hrtf->elev[0])*evTotal; total = RoundUp(total, 16); /* Align for coefficients using SIMD */ total += sizeof(Hrtf->coeffs[0])*HRIR_LENGTH*irCount; total += sizeof(Hrtf->delays[0])*irCount; - Hrtf.reset(new (al_calloc(16, total)) HrtfEntry{}); + Hrtf.reset(new (al_calloc(16, total)) HrtfStore{}); if(!Hrtf) ERR("Out of memory allocating storage for %s.\n", filename); else @@ -517,14 +517,14 @@ std::unique_ptr<HrtfEntry> CreateHrtfStore(ALuint rate, ALushort irSize, const A /* Set up pointers to storage following the main HRTF struct. */ char *base = reinterpret_cast<char*>(Hrtf.get()); - uintptr_t offset = sizeof(HrtfEntry); + uintptr_t offset = sizeof(HrtfStore); - offset = RoundUp(offset, alignof(HrtfEntry::Field)); /* Align for field infos */ - auto field_ = reinterpret_cast<HrtfEntry::Field*>(base + offset); + offset = RoundUp(offset, alignof(HrtfStore::Field)); /* Align for field infos */ + auto field_ = reinterpret_cast<HrtfStore::Field*>(base + offset); offset += sizeof(field_[0])*fdCount; - offset = RoundUp(offset, alignof(HrtfEntry::Elevation)); /* Align for elevation infos */ - auto elev_ = reinterpret_cast<HrtfEntry::Elevation*>(base + offset); + offset = RoundUp(offset, alignof(HrtfStore::Elevation)); /* Align for elevation infos */ + auto elev_ = reinterpret_cast<HrtfStore::Elevation*>(base + offset); offset += sizeof(elev_[0])*evTotal; offset = RoundUp(offset, 16); /* Align for coefficients using SIMD */ @@ -612,7 +612,7 @@ ALuint GetLE_ALuint(std::istream &data) return static_cast<ALuint>(ret); } -std::unique_ptr<HrtfEntry> LoadHrtf00(std::istream &data, const char *filename) +std::unique_ptr<HrtfStore> LoadHrtf00(std::istream &data, const char *filename) { ALuint rate{GetLE_ALuint(data)}; ALushort irCount{GetLE_ALushort(data)}; @@ -730,7 +730,7 @@ std::unique_ptr<HrtfEntry> LoadHrtf00(std::istream &data, const char *filename) &reinterpret_cast<ALubyte(&)[2]>(delays[0]), filename); } -std::unique_ptr<HrtfEntry> LoadHrtf01(std::istream &data, const char *filename) +std::unique_ptr<HrtfStore> LoadHrtf01(std::istream &data, const char *filename) { ALuint rate{GetLE_ALuint(data)}; ALushort irSize{GetLE_ALubyte(data)}; @@ -835,7 +835,7 @@ std::unique_ptr<HrtfEntry> LoadHrtf01(std::istream &data, const char *filename) #define CHANTYPE_LEFTONLY 0 #define CHANTYPE_LEFTRIGHT 1 -std::unique_ptr<HrtfEntry> LoadHrtf02(std::istream &data, const char *filename) +std::unique_ptr<HrtfStore> LoadHrtf02(std::istream &data, const char *filename) { ALuint rate{GetLE_ALuint(data)}; ALubyte sampleType{GetLE_ALubyte(data)}; @@ -1316,13 +1316,13 @@ al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname) return list; } -HrtfEntry *GetLoadedHrtf(HrtfHandle *handle) +HrtfStore *GetLoadedHrtf(HrtfHandle *handle) { std::lock_guard<std::mutex> _{LoadedHrtfLock}; if(handle->mEntry) { - HrtfEntry *hrtf{handle->mEntry.get()}; + HrtfStore *hrtf{handle->mEntry.get()}; hrtf->IncRef(); return hrtf; } @@ -1358,7 +1358,7 @@ HrtfEntry *GetLoadedHrtf(HrtfHandle *handle) stream = std::move(fstr); } - std::unique_ptr<HrtfEntry> hrtf; + std::unique_ptr<HrtfStore> hrtf; char magic[sizeof(magicMarker02)]; stream->read(magic, sizeof(magic)); if(stream->gcount() < static_cast<std::streamsize>(sizeof(magicMarker02))) @@ -1395,13 +1395,13 @@ HrtfEntry *GetLoadedHrtf(HrtfHandle *handle) } -void HrtfEntry::IncRef() +void HrtfStore::IncRef() { auto ref = IncrementRef(mRef); TRACE("HrtfEntry %p increasing refcount to %u\n", decltype(std::declval<void*>()){this}, ref); } -void HrtfEntry::DecRef() +void HrtfStore::DecRef() { auto ref = DecrementRef(mRef); TRACE("HrtfEntry %p decreasing refcount to %u\n", decltype(std::declval<void*>()){this}, ref); @@ -1412,7 +1412,7 @@ void HrtfEntry::DecRef() /* Go through and clear all unused HRTFs. */ auto delete_unused = [](HrtfHandlePtr &handle) -> void { - HrtfEntry *entry{handle->mEntry.get()}; + HrtfStore *entry{handle->mEntry.get()}; if(entry && ReadRef(entry->mRef) == 0) { TRACE("Unloading unused HRTF %s\n", handle->mFilename.data()); @@ -26,7 +26,7 @@ struct HrtfHandle; #define HRIR_MASK (HRIR_LENGTH-1) -struct HrtfEntry { +struct HrtfStore { RefCount mRef; ALuint sampleRate; @@ -97,9 +97,9 @@ struct AngularPoint { al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname); -HrtfEntry *GetLoadedHrtf(HrtfHandle *handle); +HrtfStore *GetLoadedHrtf(HrtfHandle *handle); -void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat distance, +void GetHrtfCoeffs(const HrtfStore *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat distance, ALfloat spread, HrirArray &coeffs, ALsizei (&delays)[2]); /** @@ -108,7 +108,7 @@ void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, AL * frequency gains for the decoder. The calculated impulse responses are * ordered and scaled according to the matrix input. */ -void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, +void BuildBFormatHrtf(const HrtfStore *Hrtf, DirectHrtfState *state, const al::span<const AngularPoint> AmbiPoints, const ALfloat (*AmbiMatrix)[MAX_AMBI_CHANNELS], const ALfloat *AmbiOrderHFGain); diff --git a/alc/panning.cpp b/alc/panning.cpp index e85222bd..b56f74d6 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -684,7 +684,7 @@ void InitHrtfPanning(ALCdevice *device) BuildBFormatHrtf(device->mHrtf, device->mHrtfState.get(), AmbiPoints, AmbiMatrix, AmbiOrderHFGain); - HrtfEntry *Hrtf{device->mHrtf}; + HrtfStore *Hrtf{device->mHrtf}; InitNearFieldCtrl(device, Hrtf->field[0].distance, ambi_order, ChansPerOrder); } @@ -708,7 +708,7 @@ void InitUhjPanning(ALCdevice *device) void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appreq, HrtfRequestMode hrtf_userreq) { /* Hold the HRTF the device last used, in case it's used again. */ - HrtfEntry *old_hrtf{device->mHrtf}; + HrtfStore *old_hrtf{device->mHrtf}; device->mHrtfState = nullptr; device->mHrtf = nullptr; @@ -813,7 +813,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr if(hrtf_id >= 0 && static_cast<ALuint>(hrtf_id) < device->HrtfList.size()) { const EnumeratedHrtf &entry = device->HrtfList[static_cast<ALuint>(hrtf_id)]; - HrtfEntry *hrtf{GetLoadedHrtf(entry.hrtf)}; + HrtfStore *hrtf{GetLoadedHrtf(entry.hrtf)}; if(hrtf && hrtf->sampleRate == device->Frequency) { device->mHrtf = hrtf; @@ -827,7 +827,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr { auto find_hrtf = [device](const EnumeratedHrtf &entry) -> bool { - HrtfEntry *hrtf{GetLoadedHrtf(entry.hrtf)}; + HrtfStore *hrtf{GetLoadedHrtf(entry.hrtf)}; if(!hrtf) return false; if(hrtf->sampleRate != device->Frequency) { |