summaryrefslogtreecommitdiffstats
path: root/Alc
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 /Alc
parent9f037e89802a7b4fc6c287bab97b85050bbd6721 (diff)
Make a GetConfigValueBool function and use it
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c6
-rw-r--r--Alc/alcConfig.c9
-rw-r--r--Alc/alsa.c8
3 files changed, 11 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);