aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-08-13 10:37:49 -0700
committerChris Robinson <[email protected]>2012-08-13 10:37:49 -0700
commit17dfaa3aaef28f38b27c5d797be0a938c4ca38e2 (patch)
treef8c9eeae91028edf32b7df98513c39add41d4e40 /Alc
parent0a3eba08d8af653a4e7ec803b86c458560e14484 (diff)
Add a config option to disable use of CPU extensions
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c32
-rw-r--r--Alc/helpers.c19
2 files changed, 42 insertions, 9 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index b017c480..e664d25a 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -769,6 +769,7 @@ static void alc_init(void)
static void alc_initconfig(void)
{
const char *devs, *str;
+ ALuint capfilter;
float valf;
int i, n;
@@ -790,7 +791,36 @@ static void alc_initconfig(void)
ReadALConfig();
- FillCPUCaps();
+ capfilter = CPU_CAP_ALL;
+ if(ConfigValueStr(NULL, "disable-cpu-exts", &str))
+ {
+ if(strcasecmp(str, "all") == 0)
+ capfilter = 0;
+ else
+ {
+ size_t len;
+ const char *next = str;
+
+ i = 0;
+ do {
+ str = next;
+ next = strchr(str, ',');
+
+ while(isspace(str[0]))
+ str++;
+ if(!str[0] || str[0] == ',')
+ continue;
+
+ len = (next ? ((size_t)(next-str)) : strlen(str));
+ if(strncasecmp(str, "neon", len) == 0)
+ capfilter &= ~CPU_CAP_NEON;
+ else
+ WARN("Invalid CPU extension \"%s\"\n", str);
+ } while(next++);
+ }
+ }
+ FillCPUCaps(capfilter);
+
InitHrtf();
#ifdef _WIN32
diff --git a/Alc/helpers.c b/Alc/helpers.c
index 6051573e..d963f3a8 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -63,8 +63,10 @@ DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80,
ALuint CPUCapFlags = 0;
-void FillCPUCaps(void)
+void FillCPUCaps(ALuint capfilter)
{
+ ALuint caps = 0;
+
#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
/* FIXME: We really should get this for all available CPUs in case different
* CPUs have different caps (is that possible on one machine?). */
@@ -90,11 +92,11 @@ void FillCPUCaps(void)
{
#ifdef bit_MMX
if((cpuinf[0].regs[3]&bit_MMX))
- CPUCapFlags |= CPU_CAP_MMX;
+ caps |= CPU_CAP_MMX;
#endif
#ifdef bit_SSE
if((cpuinf[0].regs[3]&bit_SSE))
- CPUCapFlags |= CPU_CAP_SSE;
+ caps |= CPU_CAP_SSE;
#endif
}
}
@@ -102,13 +104,14 @@ void FillCPUCaps(void)
#endif
#ifdef HAVE_ARM_NEON_H
/* Assume Neon support if compiled with it */
- CPUCapFlags |= CPU_CAP_NEON;
+ caps |= CPU_CAP_NEON;
#endif
- TRACE("Got caps:%s%s%s%s\n", ((CPUCapFlags&CPU_CAP_MMX)?" MMX":""),
- ((CPUCapFlags&CPU_CAP_SSE)?" SSE":""),
- ((CPUCapFlags&CPU_CAP_NEON)?" Neon":""),
- ((!CPUCapFlags)?" (none)":""));
+ TRACE("Got caps:%s%s%s%s\n", ((caps&CPU_CAP_MMX)?((capfilter&CPU_CAP_MMX)?" MMX":" (MMX)"):""),
+ ((caps&CPU_CAP_SSE)?((capfilter&CPU_CAP_SSE)?" SSE":" (SSE)"):""),
+ ((caps&CPU_CAP_NEON)?((capfilter&CPU_CAP_NEON)?" Neon":" (Neon)"):""),
+ ((!caps)?" (none)":""));
+ CPUCapFlags = caps & capfilter;
}