aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-12-28 13:08:15 -0800
committerChris Robinson <[email protected]>2009-12-28 13:08:15 -0800
commit69ab93a8240d6272c3fbd86e65b7baca516ec8de (patch)
tree6d257345dc5eee5dd6a8324ce774aa18b7890e50 /Alc
parent179b660eee8cfc958057cb237019a939c3361fbb (diff)
Add a function to check if a config option is set to a non-empty value
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c12
-rw-r--r--Alc/alcConfig.c6
-rw-r--r--Alc/dsound.c2
-rw-r--r--Alc/pulseaudio.c4
-rw-r--r--Alc/wave.c2
5 files changed, 17 insertions, 9 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 8db45cff..db63f593 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1213,7 +1213,8 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
attrIdx = 0;
while(attrList[attrIdx])
{
- if(attrList[attrIdx] == ALC_FREQUENCY)
+ if(attrList[attrIdx] == ALC_FREQUENCY &&
+ !ConfigValueExists(NULL, "frequency"))
{
freq = attrList[attrIdx + 1];
if(freq < 8000)
@@ -1230,7 +1231,8 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
numMono = device->MaxNoOfSources - numStereo;
}
- if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS)
+ if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS &&
+ !ConfigValueExists(NULL, "sends"))
{
numSends = attrList[attrIdx + 1];
if(numSends > MAX_SENDS)
@@ -1240,11 +1242,11 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
attrIdx += 2;
}
- device->Bs2bLevel = GetConfigValueInt(NULL, "cf_level", level);
- device->Frequency = GetConfigValueInt(NULL, "frequency", freq);
+ device->Bs2bLevel = level;
+ device->Frequency = freq;
device->lNumMonoSources = numMono;
device->lNumStereoSources = numStereo;
- device->NumAuxSends = GetConfigValueInt(NULL, "sends", numSends);
+ device->NumAuxSends = numSends;
}
if(ALCdevice_ResetPlayback(device) == ALC_FALSE)
diff --git a/Alc/alcConfig.c b/Alc/alcConfig.c
index eee64845..dbdf9639 100644
--- a/Alc/alcConfig.c
+++ b/Alc/alcConfig.c
@@ -294,6 +294,12 @@ const char *GetConfigValue(const char *blockName, const char *keyName, const cha
return def;
}
+int ConfigValueExists(const char *blockName, const char *keyName)
+{
+ const char *val = GetConfigValue(blockName, keyName, "");
+ return !!val[0];
+}
+
int GetConfigValueInt(const char *blockName, const char *keyName, int def)
{
const char *val = GetConfigValue(blockName, keyName, "");
diff --git a/Alc/dsound.c b/Alc/dsound.c
index 63047824..ac54b487 100644
--- a/Alc/dsound.c
+++ b/Alc/dsound.c
@@ -280,7 +280,7 @@ static ALCboolean DSoundResetPlayback(ALCdevice *device)
memset(&OutputType, 0, sizeof(OutputType));
hr = IDirectSound_GetSpeakerConfig(pData->lpDS, &speakers);
- if(SUCCEEDED(hr) && *(GetConfigValue(NULL, "format", "")) != 0)
+ if(SUCCEEDED(hr) && ConfigValueExists(NULL, "format"))
{
if(aluChannelsFromFormat(device->Format) == 1)
speakers = DSSPEAKER_COMBINED(DSSPEAKER_MONO, 0);
diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c
index a85e4b47..9faead99 100644
--- a/Alc/pulseaudio.c
+++ b/Alc/pulseaudio.c
@@ -577,7 +577,7 @@ static ALCboolean pulse_reset_playback(ALCdevice *device) //{{{
ppa_threaded_mainloop_lock(data->loop);
- if(*(GetConfigValue(NULL, "format", "")) == '\0')
+ if(!ConfigValueExists(NULL, "format"))
{
pa_operation *o;
struct {
@@ -600,7 +600,7 @@ static ALCboolean pulse_reset_playback(ALCdevice *device) //{{{
free(server_data.name);
}
}
- if(*(GetConfigValue(NULL, "frequency", "")) == '\0')
+ if(!ConfigValueExists(NULL, "frequency"))
flags |= PA_STREAM_FIX_RATE;
data->frame_size = aluBytesFromFormat(device->Format) *
diff --git a/Alc/wave.c b/Alc/wave.c
index 1d2a39d2..5496e16e 100644
--- a/Alc/wave.c
+++ b/Alc/wave.c
@@ -341,7 +341,7 @@ void alc_wave_deinit(void)
void alc_wave_probe(int type)
{
- if(*(GetConfigValue("wave", "file", "")) == 0)
+ if(!ConfigValueExists("wave", "file"))
return;
if(type == DEVICE_PROBE)