Add a function to check if a config option is set to a non-empty value
This commit is contained in:
parent
179b660eee
commit
69ab93a824
12
Alc/ALc.c
12
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)
|
||||
|
@ -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, "");
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user