aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-09-15 22:18:13 -0700
committerChris Robinson <[email protected]>2009-09-15 22:18:13 -0700
commit49648fe22dec8fb5a783d8a7e3929b3231f6f4f4 (patch)
tree91476b2a2a76072128fe586400577fadfc179080
parent9f037e89802a7b4fc6c287bab97b85050bbd6721 (diff)
Make a GetConfigValueBool function and use it
-rw-r--r--Alc/ALc.c6
-rw-r--r--Alc/alcConfig.c9
-rw-r--r--Alc/alsa.c8
-rw-r--r--OpenAL32/Include/alMain.h1
4 files changed, 12 insertions, 12 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 049a62d7..0202f60a 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -302,11 +302,7 @@ static void alc_init(void)
BackendList[i].Probe(CAPTURE_DEVICE_PROBE);
}
- str = GetConfigValue(NULL, "stereodup", "false");
- DuplicateStereo = (strcasecmp(str, "true") == 0 ||
- strcasecmp(str, "yes") == 0 ||
- strcasecmp(str, "on") == 0 ||
- atoi(str) != 0);
+ DuplicateStereo = GetConfigValueBool(NULL, "stereodup", 0);
str = GetConfigValue(NULL, "excludefx", "");
if(str[0])
diff --git a/Alc/alcConfig.c b/Alc/alcConfig.c
index b6e46139..de42f154 100644
--- a/Alc/alcConfig.c
+++ b/Alc/alcConfig.c
@@ -313,3 +313,12 @@ float GetConfigValueFloat(const char *blockName, const char *keyName, float def)
return (float)strtod(val, NULL);
#endif
}
+
+int GetConfigValueBool(const char *blockName, const char *keyName, float def)
+{
+ const char *val = GetConfigValue(blockName, keyName, "");
+
+ if(!val[0]) return !!def;
+ return (strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0 ||
+ strcasecmp(val, "on") == 0 || atoi(val) != 0);
+}
diff --git a/Alc/alsa.c b/Alc/alsa.c
index aad0835a..ec80973a 100644
--- a/Alc/alsa.c
+++ b/Alc/alsa.c
@@ -417,7 +417,6 @@ static ALCboolean alsa_start_context(ALCdevice *device, ALCcontext *context)
snd_pcm_access_t access;
unsigned int periods;
unsigned int rate;
- const char *str;
int allowmmap;
char *err;
int i;
@@ -440,16 +439,11 @@ static ALCboolean alsa_start_context(ALCdevice *device, ALCcontext *context)
AL_PRINT("Unknown format?! %x\n", device->Format);
}
+ allowmmap = GetConfigValueBool("alsa", "mmap", 1);
periods = GetConfigValueInt("alsa", "periods", 0);
bufferSizeInFrames = device->BufferSize;
rate = device->Frequency;
- str = GetConfigValue("alsa", "mmap", "true");
- allowmmap = (strcasecmp(str, "true") == 0 ||
- strcasecmp(str, "yes") == 0 ||
- strcasecmp(str, "on") == 0 ||
- atoi(str) != 0);
-
err = NULL;
psnd_pcm_hw_params_malloc(&p);
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index cc48aee4..3205e467 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -327,6 +327,7 @@ void FreeALConfig(void);
const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
int GetConfigValueInt(const char *blockName, const char *keyName, int def);
float GetConfigValueFloat(const char *blockName, const char *keyName, float def);
+int GetConfigValueBool(const char *blockName, const char *keyName, float def);
ALCboolean ALCAPIENTRY alcMakeCurrent(ALCcontext *context);
ALCcontext* ALCAPIENTRY alcGetThreadContext(void);