Use a standard string for the enumerated HRTF names
This commit is contained in:
+3
-3
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+5
-14
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user