diff options
-rw-r--r-- | Alc/alc.cpp | 6 | ||||
-rw-r--r-- | Alc/helpers.cpp | 9 | ||||
-rw-r--r-- | Alc/hrtf.cpp | 19 | ||||
-rw-r--r-- | Alc/hrtf.h | 1 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 4 |
5 files changed, 9 insertions, 30 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 805ba70c..f4a64199 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -2436,7 +2436,7 @@ ALCdevice_struct::~ALCdevice_struct() VECTOR_DEINIT(FilterList); almtx_destroy(&FilterLock); - FreeHrtfList(HrtfList); + HrtfList.clear(); if(HrtfHandle) Hrtf_DecRef(HrtfHandle); HrtfHandle = nullptr; @@ -3364,7 +3364,7 @@ static ALCsizei GetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALC case ALC_NUM_HRTF_SPECIFIERS_SOFT: almtx_lock(&device->BackendLock); - FreeHrtfList(device->HrtfList); + device->HrtfList.clear(); device->HrtfList = EnumerateHrtf(device->DeviceName.c_str()); values[0] = (ALCint)device->HrtfList.size(); almtx_unlock(&device->BackendLock); @@ -4460,7 +4460,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetStringiSOFT(ALCdevice *device, ALCenum { case ALC_HRTF_SPECIFIER_SOFT: if(index >= 0 && (size_t)index < device->HrtfList.size()) - str = device->HrtfList[index].name; + str = device->HrtfList[index].name.c_str(); else alcSetError(device, ALC_INVALID_VALUE); break; diff --git a/Alc/helpers.cpp b/Alc/helpers.cpp index d31101f7..a78e3d83 100644 --- a/Alc/helpers.cpp +++ b/Alc/helpers.cpp @@ -726,12 +726,3 @@ void SetRTPriority(void) } #endif - - -char *alstrdup(const char *str) -{ - const size_t len{strlen(str)}; - char *ret{static_cast<char*>(al_calloc(DEF_ALIGN, len+1))}; - memcpy(ret, str, len); - return ret; -} diff --git a/Alc/hrtf.cpp b/Alc/hrtf.cpp index 1305c347..89b80074 100644 --- a/Alc/hrtf.cpp +++ b/Alc/hrtf.cpp @@ -1007,10 +1007,10 @@ void AddFileEntry(al::vector<EnumeratedHrtf> &list, const std::string &filename) newname += " #"; newname += std::to_string(++count); } - list.push_back(EnumeratedHrtf{alstrdup(newname.c_str()), loaded_entry}); + list.emplace_back(EnumeratedHrtf{newname, loaded_entry}); const EnumeratedHrtf &entry = list.back(); - TRACE("Adding file entry \"%s\"\n", entry.name); + TRACE("Adding file entry \"%s\"\n", entry.name.c_str()); } /* Unfortunate that we have to duplicate AddFileEntry to take a memory buffer @@ -1066,10 +1066,10 @@ void AddBuiltInEntry(al::vector<EnumeratedHrtf> &list, const std::string &filena newname += " #"; newname += std::to_string(++count); } - list.push_back(EnumeratedHrtf{alstrdup(newname.c_str()), loaded_entry}); + list.emplace_back(EnumeratedHrtf{newname, loaded_entry}); const EnumeratedHrtf &entry = list.back(); - TRACE("Adding built-in entry \"%s\"\n", entry.name); + TRACE("Adding built-in entry \"%s\"\n", entry.name.c_str()); } @@ -1160,7 +1160,7 @@ al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname) { auto iter = std::find_if(list.begin(), list.end(), [defaulthrtf](const EnumeratedHrtf &entry) -> bool - { return strcmp(entry.name, defaulthrtf) == 0; } + { return entry.name == defaulthrtf; } ); if(iter == list.end()) WARN("Failed to find default HRTF \"%s\"\n", defaulthrtf); @@ -1175,15 +1175,6 @@ al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname) return list; } -void FreeHrtfList(al::vector<EnumeratedHrtf> &list) -{ - std::for_each(list.begin(), list.end(), - [](EnumeratedHrtf &entry) noexcept -> void - { al_free(entry.name); } - ); - list.clear(); -} - struct Hrtf *GetLoadedHrtf(struct HrtfEntry *entry) { std::lock_guard<std::mutex> _{LoadedHrtfLock}; @@ -66,7 +66,6 @@ struct AngularPoint { void FreeHrtfs(void); al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname); -void FreeHrtfList(al::vector<EnumeratedHrtf> &list); struct Hrtf *GetLoadedHrtf(struct HrtfEntry *entry); void Hrtf_IncRef(struct Hrtf *hrtf); void Hrtf_DecRef(struct Hrtf *hrtf); diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 57ecd925..e0d1462b 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -528,7 +528,7 @@ TYPEDEF_VECTOR(FilterSubList, vector_FilterSubList) typedef struct EnumeratedHrtf { - char *name; + std::string name; struct HrtfEntry *hrtf; } EnumeratedHrtf; @@ -805,8 +805,6 @@ inline void UnlockFilterList(ALCdevice *device) { almtx_unlock(&device->FilterLo void StartEventThrd(ALCcontext *ctx); void StopEventThrd(ALCcontext *ctx); -char *alstrdup(const char *str); - std::vector<std::string> SearchDataFiles(const char *match, const char *subdir); |