From c0e7aab823ce58ebd16ac393e6ed2407174ed535 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 24 Jul 2016 21:59:02 -0700 Subject: 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. --- Alc/hrtf.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'Alc') 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); -- cgit v1.2.3