Add a ConfigValueStr function, to return the string through a parameter
This commit is contained in:
parent
cc3dd648ac
commit
edb386eb1e
10
Alc/ALc.c
10
Alc/ALc.c
@ -606,8 +606,7 @@ static void alc_initconfig(void)
|
|||||||
|
|
||||||
EmulateEAXReverb = GetConfigValueBool("reverb", "emulate-eax", AL_FALSE);
|
EmulateEAXReverb = GetConfigValueBool("reverb", "emulate-eax", AL_FALSE);
|
||||||
|
|
||||||
devs = GetConfigValue(NULL, "drivers", "");
|
if(ConfigValueStr(NULL, "drivers", &devs))
|
||||||
if(devs[0])
|
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -690,8 +689,7 @@ static void alc_initconfig(void)
|
|||||||
}
|
}
|
||||||
BackendLoopback.Init(&BackendLoopback.Funcs);
|
BackendLoopback.Init(&BackendLoopback.Funcs);
|
||||||
|
|
||||||
str = GetConfigValue(NULL, "excludefx", "");
|
if(ConfigValueStr(NULL, "excludefx", &str))
|
||||||
if(str[0])
|
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
const char *next = str;
|
const char *next = str;
|
||||||
@ -2453,9 +2451,9 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
|
|||||||
device->Flags |= DEVICE_FREQUENCY_REQUEST;
|
device->Flags |= DEVICE_FREQUENCY_REQUEST;
|
||||||
device->Frequency = maxu(device->Frequency, 8000);
|
device->Frequency = maxu(device->Frequency, 8000);
|
||||||
|
|
||||||
if(ConfigValueExists(NULL, "format"))
|
fmt = "AL_FORMAT_STEREO16";
|
||||||
|
if(ConfigValueStr(NULL, "format", &fmt))
|
||||||
device->Flags |= DEVICE_CHANNELS_REQUEST;
|
device->Flags |= DEVICE_CHANNELS_REQUEST;
|
||||||
fmt = GetConfigValue(NULL, "format", "AL_FORMAT_STEREO16");
|
|
||||||
GetFormatFromString(fmt, &device->FmtChans, &device->FmtType);
|
GetFormatFromString(fmt, &device->FmtChans, &device->FmtType);
|
||||||
|
|
||||||
ConfigValueUInt(NULL, "periods", &device->NumUpdates);
|
ConfigValueUInt(NULL, "periods", &device->NumUpdates);
|
||||||
|
@ -313,6 +313,15 @@ int ConfigValueExists(const char *blockName, const char *keyName)
|
|||||||
return !!val[0];
|
return !!val[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ConfigValueStr(const char *blockName, const char *keyName, const char **ret)
|
||||||
|
{
|
||||||
|
const char *val = GetConfigValue(blockName, keyName, "");
|
||||||
|
if(!val[0]) return 0;
|
||||||
|
|
||||||
|
*ret = val;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int ConfigValueInt(const char *blockName, const char *keyName, int *ret)
|
int ConfigValueInt(const char *blockName, const char *keyName, int *ret)
|
||||||
{
|
{
|
||||||
const char *val = GetConfigValue(blockName, keyName, "");
|
const char *val = GetConfigValue(blockName, keyName, "");
|
||||||
|
@ -525,12 +525,12 @@ static ALuint ALSANoMMapProc(ALvoid *ptr)
|
|||||||
|
|
||||||
static ALCenum alsa_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
static ALCenum alsa_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
||||||
{
|
{
|
||||||
|
const char *driver = "default";
|
||||||
alsa_data *data;
|
alsa_data *data;
|
||||||
char driver[128];
|
char str[128];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
strncpy(driver, GetConfigValue("alsa", "device", "default"), sizeof(driver)-1);
|
ConfigValueStr("alsa", "device", &driver);
|
||||||
driver[sizeof(driver)-1] = 0;
|
|
||||||
|
|
||||||
if(!deviceName)
|
if(!deviceName)
|
||||||
deviceName = alsaDevice;
|
deviceName = alsaDevice;
|
||||||
@ -547,8 +547,11 @@ static ALCenum alsa_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
|||||||
strcmp(deviceName, allDevNameMap[idx].name) == 0)
|
strcmp(deviceName, allDevNameMap[idx].name) == 0)
|
||||||
{
|
{
|
||||||
if(idx > 0)
|
if(idx > 0)
|
||||||
snprintf(driver, sizeof(driver), "%sCARD=%s,DEV=%d", device_prefix,
|
{
|
||||||
allDevNameMap[idx].card, allDevNameMap[idx].dev);
|
snprintf(str, sizeof(str), "%sCARD=%s,DEV=%d", device_prefix,
|
||||||
|
allDevNameMap[idx].card, allDevNameMap[idx].dev);
|
||||||
|
driver = str;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -801,18 +804,18 @@ static void alsa_stop_playback(ALCdevice *device)
|
|||||||
|
|
||||||
static ALCenum alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
|
static ALCenum alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
|
||||||
{
|
{
|
||||||
|
const char *driver = "default";
|
||||||
snd_pcm_hw_params_t *p;
|
snd_pcm_hw_params_t *p;
|
||||||
snd_pcm_uframes_t bufferSizeInFrames;
|
snd_pcm_uframes_t bufferSizeInFrames;
|
||||||
snd_pcm_uframes_t periodSizeInFrames;
|
snd_pcm_uframes_t periodSizeInFrames;
|
||||||
snd_pcm_format_t format;
|
snd_pcm_format_t format;
|
||||||
ALuint frameSize;
|
ALuint frameSize;
|
||||||
alsa_data *data;
|
alsa_data *data;
|
||||||
char driver[128];
|
char str[128];
|
||||||
char *err;
|
char *err;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
strncpy(driver, GetConfigValue("alsa", "capture", "default"), sizeof(driver)-1);
|
ConfigValueStr("alsa", "capture", &driver);
|
||||||
driver[sizeof(driver)-1] = 0;
|
|
||||||
|
|
||||||
if(!allCaptureDevNameMap)
|
if(!allCaptureDevNameMap)
|
||||||
allCaptureDevNameMap = probe_devices(SND_PCM_STREAM_CAPTURE, &numCaptureDevNames);
|
allCaptureDevNameMap = probe_devices(SND_PCM_STREAM_CAPTURE, &numCaptureDevNames);
|
||||||
@ -829,8 +832,11 @@ static ALCenum alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
|
|||||||
strcmp(deviceName, allCaptureDevNameMap[idx].name) == 0)
|
strcmp(deviceName, allCaptureDevNameMap[idx].name) == 0)
|
||||||
{
|
{
|
||||||
if(idx > 0)
|
if(idx > 0)
|
||||||
snprintf(driver, sizeof(driver), "%sCARD=%s,DEV=%d", capture_prefix,
|
{
|
||||||
|
snprintf(str, sizeof(str), "%sCARD=%s,DEV=%d", capture_prefix,
|
||||||
allCaptureDevNameMap[idx].card, allCaptureDevNameMap[idx].dev);
|
allCaptureDevNameMap[idx].card, allCaptureDevNameMap[idx].dev);
|
||||||
|
driver = str;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,10 +315,11 @@ const struct Hrtf *GetHrtf(ALCdevice *device)
|
|||||||
|
|
||||||
void InitHrtf(void)
|
void InitHrtf(void)
|
||||||
{
|
{
|
||||||
char *fnamelist, *next;
|
char *fnamelist=NULL, *next=NULL;
|
||||||
|
const char *val;
|
||||||
|
|
||||||
fnamelist = strdup(GetConfigValue(NULL, "hrtf_tables", ""));
|
if(ConfigValueStr(NULL, "hrtf_tables", &val))
|
||||||
next = fnamelist;
|
next = fnamelist = strdup(val);
|
||||||
while(next && *next)
|
while(next && *next)
|
||||||
{
|
{
|
||||||
const ALubyte maxDelay = SRC_HISTORY_LENGTH-1;
|
const ALubyte maxDelay = SRC_HISTORY_LENGTH-1;
|
||||||
|
@ -34,21 +34,17 @@
|
|||||||
static void SetSpeakerArrangement(const char *name, ALfloat SpeakerAngle[MAXCHANNELS],
|
static void SetSpeakerArrangement(const char *name, ALfloat SpeakerAngle[MAXCHANNELS],
|
||||||
enum Channel Speaker2Chan[MAXCHANNELS], ALint chans)
|
enum Channel Speaker2Chan[MAXCHANNELS], ALint chans)
|
||||||
{
|
{
|
||||||
char layout_str[256];
|
|
||||||
char *confkey, *next;
|
char *confkey, *next;
|
||||||
|
char *layout_str;
|
||||||
char *sep, *end;
|
char *sep, *end;
|
||||||
enum Channel val;
|
enum Channel val;
|
||||||
|
const char *str;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(!ConfigValueExists(NULL, name))
|
if(!ConfigValueStr(NULL, name, &str) && !ConfigValueStr(NULL, "layout", &str))
|
||||||
name = "layout";
|
|
||||||
|
|
||||||
strncpy(layout_str, GetConfigValue(NULL, name, ""), sizeof(layout_str));
|
|
||||||
layout_str[sizeof(layout_str)-1] = 0;
|
|
||||||
|
|
||||||
if(!layout_str[0])
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
layout_str = strdup(str);
|
||||||
next = confkey = layout_str;
|
next = confkey = layout_str;
|
||||||
while(next && *next)
|
while(next && *next)
|
||||||
{
|
{
|
||||||
@ -113,6 +109,8 @@ static void SetSpeakerArrangement(const char *name, ALfloat SpeakerAngle[MAXCHAN
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(layout_str);
|
||||||
|
layout_str = NULL;
|
||||||
|
|
||||||
for(i = 0;i < chans;i++)
|
for(i = 0;i < chans;i++)
|
||||||
{
|
{
|
||||||
|
@ -670,6 +670,7 @@ void FreeALConfig(void);
|
|||||||
int ConfigValueExists(const char *blockName, const char *keyName);
|
int ConfigValueExists(const char *blockName, const char *keyName);
|
||||||
const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
|
const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
|
||||||
int GetConfigValueBool(const char *blockName, const char *keyName, int def);
|
int GetConfigValueBool(const char *blockName, const char *keyName, int def);
|
||||||
|
int ConfigValueStr(const char *blockName, const char *keyName, const char **ret);
|
||||||
int ConfigValueInt(const char *blockName, const char *keyName, int *ret);
|
int ConfigValueInt(const char *blockName, const char *keyName, int *ret);
|
||||||
int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret);
|
int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret);
|
||||||
int ConfigValueFloat(const char *blockName, const char *keyName, float *ret);
|
int ConfigValueFloat(const char *blockName, const char *keyName, float *ret);
|
||||||
|
Loading…
Reference in New Issue
Block a user