aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-02-21 02:44:02 -0800
committerChris Robinson <[email protected]>2016-02-21 02:44:02 -0800
commite6f120df23362530e7535ac3d5520f122b9df1e8 (patch)
treeb6f8b471d831cdf358c44280fa9f78e24fe02cbc
parentc2dd681940c706110fe5266ed5d021cfa286ea1e (diff)
Add a config option to specify the preferred HRTF
-rw-r--r--Alc/hrtf.c19
-rw-r--r--alsoftrc.sample6
2 files changed, 25 insertions, 0 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index 8ede3cc5..f8243784 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -605,6 +605,7 @@ vector_HrtfEntry EnumerateHrtf(const_al_string devname)
{
vector_HrtfEntry list = VECTOR_INIT_STATIC();
const char *fnamelist = "%s.mhr";
+ const char *defaulthrtf = "";
ConfigValueStr(al_string_get_cstr(devname), NULL, "hrtf_tables", &fnamelist);
while(fnamelist && *fnamelist)
@@ -641,6 +642,24 @@ vector_HrtfEntry EnumerateHrtf(const_al_string devname)
}
}
+ if(VECTOR_SIZE(list) > 1 && ConfigValueStr(al_string_get_cstr(devname), NULL, "default_hrtf", &defaulthrtf))
+ {
+ const HrtfEntry *iter;
+ /* Find the preferred HRTF and move it to the front of the list. */
+#define FIND_ENTRY(i) (al_string_cmp_cstr((i)->name, defaulthrtf) == 0)
+ VECTOR_FIND_IF(iter, const HrtfEntry, list, FIND_ENTRY);
+ if(iter != VECTOR_ITER_END(list) && iter != VECTOR_ITER_BEGIN(list))
+ {
+ HrtfEntry entry = *iter;
+ memmove(&VECTOR_ELEM(list,1), &VECTOR_ELEM(list,0),
+ (iter-VECTOR_ITER_BEGIN(list))*sizeof(HrtfEntry));
+ VECTOR_ELEM(list,0) = entry;
+ }
+ else
+ WARN("Failed to find default HRTF \"%s\"\n", defaulthrtf);
+#undef FIND_ENTRY
+ }
+
return list;
}
diff --git a/alsoftrc.sample b/alsoftrc.sample
index 039dba6a..c29fae49 100644
--- a/alsoftrc.sample
+++ b/alsoftrc.sample
@@ -96,6 +96,12 @@
# respectively.
#hrtf = auto
+## default_hrtf:
+# Specifies the default HRTF to use. When multiple HRTFs are available, this
+# determines the preferred one to use if none are specifically requested. Note
+# that this is the enumerated HRTF name, not necessarily the filename.
+#default_hrtf =
+
## hrtf_tables:
# Specifies a comma-separated list of files containing HRTF data sets. The
# format of the files are described in hrtf.txt. The filenames may contain