aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-07-24 21:59:02 -0700
committerChris Robinson <[email protected]>2016-07-24 21:59:02 -0700
commitc0e7aab823ce58ebd16ac393e6ed2407174ed535 (patch)
tree3535936ce7466debb6e8a7f57a0e912e0168e7f5 /Alc
parent9f2e416bbddc5f17c95135c327c046e0d1612850 (diff)
Properly skip loading of already-loaded HRTF data sets
Previously, if an HRTF file was loaded it would not only skip loading it, but it would also skip adding it to the output enumeration list. Now it properly skips loading it when it's already loaded, but still adds it to the enumeration list if it's not already in it.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/hrtf.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index c74517e5..9e927e4f 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -512,13 +512,22 @@ static void AddFileEntry(vector_HrtfEntry *list, al_string *filename)
if(!name) name = al_string_get_cstr(*filename);
else ++name;
+#define MATCH_FNAME(i) (al_string_cmp_cstr(*filename, (i)->hrtf->filename) == 0)
+ VECTOR_FIND_IF(iter, const HrtfEntry, *list, MATCH_FNAME);
+ if(iter != VECTOR_END(*list))
+ {
+ TRACE("Skipping duplicate file entry %s\n", al_string_get_cstr(*filename));
+ goto done;
+ }
+#undef MATCH_FNAME
+
entry.hrtf = LoadedHrtfs;
while(entry.hrtf)
{
if(al_string_cmp_cstr(*filename, entry.hrtf->filename) == 0)
{
- TRACE("Skipping duplicate file entry %s\n", al_string_get_cstr(*filename));
- goto done;
+ TRACE("Skipping load of already-loaded file %s\n", al_string_get_cstr(*filename));
+ goto skip_load;
}
entry.hrtf = entry.hrtf->next;
}
@@ -562,6 +571,7 @@ static void AddFileEntry(vector_HrtfEntry *list, al_string *filename)
DevFmtChannelsString(DevFmtStereo), hrtf->sampleRate);
entry.hrtf = hrtf;
+skip_load:
/* TODO: Get a human-readable name from the HRTF data (possibly coming in a
* format update). */
ext = strrchr(name, '.');
@@ -784,13 +794,22 @@ static void AddBuiltInEntry(vector_HrtfEntry *list, const ALubyte *data, size_t
const HrtfEntry *iter;
int i;
+#define MATCH_FNAME(i) (al_string_cmp_cstr(*filename, (i)->hrtf->filename) == 0)
+ VECTOR_FIND_IF(iter, const HrtfEntry, *list, MATCH_FNAME);
+ if(iter != VECTOR_END(*list))
+ {
+ TRACE("Skipping duplicate file entry %s\n", al_string_get_cstr(*filename));
+ goto done;
+ }
+#undef MATCH_FNAME
+
entry.hrtf = LoadedHrtfs;
while(entry.hrtf)
{
if(al_string_cmp_cstr(*filename, entry.hrtf->filename) == 0)
{
- TRACE("Skipping duplicate file entry %s\n", al_string_get_cstr(*filename));
- goto done;
+ TRACE("Skipping load of already-loaded file %s\n", al_string_get_cstr(*filename));
+ goto skip_load;
}
entry.hrtf = entry.hrtf->next;
}
@@ -825,6 +844,7 @@ static void AddBuiltInEntry(vector_HrtfEntry *list, const ALubyte *data, size_t
DevFmtChannelsString(DevFmtStereo), hrtf->sampleRate);
entry.hrtf = hrtf;
+skip_load:
i = 0;
do {
al_string_copy(&entry.name, *filename);