diff options
author | Chris Robinson <[email protected]> | 2009-12-28 13:08:15 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-12-28 13:08:15 -0800 |
commit | 69ab93a8240d6272c3fbd86e65b7baca516ec8de (patch) | |
tree | 6d257345dc5eee5dd6a8324ce774aa18b7890e50 | |
parent | 179b660eee8cfc958057cb237019a939c3361fbb (diff) |
Add a function to check if a config option is set to a non-empty value
-rw-r--r-- | Alc/ALc.c | 12 | ||||
-rw-r--r-- | Alc/alcConfig.c | 6 | ||||
-rw-r--r-- | Alc/dsound.c | 2 | ||||
-rw-r--r-- | Alc/pulseaudio.c | 4 | ||||
-rw-r--r-- | Alc/wave.c | 2 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 1 |
6 files changed, 18 insertions, 9 deletions
@@ -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) * @@ -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) diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index ed03bea8..87eb2576 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -378,6 +378,7 @@ void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len); void ReadALConfig(void); void FreeALConfig(void); +int ConfigValueExists(const char *blockName, const char *keyName); 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); |