conf: use config_get_bool() instead of getBoolConfigParam()
This commit is contained in:
parent
4d472c265e
commit
a1a97cc048
20
src/conf.c
20
src/conf.c
@ -429,30 +429,24 @@ parseConfigFilePath(const char *name, int force)
|
||||
return param;
|
||||
}
|
||||
|
||||
int getBoolConfigParam(const char *name, int force)
|
||||
bool config_get_bool(const char *name, bool default_value)
|
||||
{
|
||||
int ret;
|
||||
struct config_param *param = config_get_param(name);
|
||||
int value;
|
||||
|
||||
if (!param)
|
||||
return CONF_BOOL_UNSET;
|
||||
if (param == NULL)
|
||||
return default_value;
|
||||
|
||||
ret = get_bool(param->value);
|
||||
if (force && ret == CONF_BOOL_INVALID)
|
||||
value = get_bool(param->value);
|
||||
if (value == CONF_BOOL_INVALID)
|
||||
g_error("%s is not a boolean value (yes, true, 1) or "
|
||||
"(no, false, 0) on line %i\n",
|
||||
name, param->line);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool config_get_bool(const char *name, bool default_value)
|
||||
{
|
||||
int value = getBoolConfigParam(name, true);
|
||||
|
||||
if (value == CONF_BOOL_UNSET)
|
||||
return default_value;
|
||||
|
||||
return value;
|
||||
return !!value;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -106,8 +106,6 @@ getBlockParam(struct config_param *param, const char *name);
|
||||
struct config_param *
|
||||
parseConfigFilePath(const char *name, int force);
|
||||
|
||||
int getBoolConfigParam(const char *name, int force);
|
||||
|
||||
bool config_get_bool(const char *name, bool default_value);
|
||||
|
||||
int
|
||||
|
@ -93,10 +93,8 @@ mad_fixed_to_24_buffer(int32_t *dest, const struct mad_synth *synth,
|
||||
|
||||
static bool mp3_plugin_init(void)
|
||||
{
|
||||
int ret = getBoolConfigParam(CONF_GAPLESS_MP3_PLAYBACK, true);
|
||||
gapless_playback = ret != CONF_BOOL_UNSET
|
||||
? !!ret
|
||||
: DEFAULT_GAPLESS_MP3_PLAYBACK;
|
||||
gapless_playback = config_get_bool(CONF_GAPLESS_MP3_PLAYBACK,
|
||||
DEFAULT_GAPLESS_MP3_PLAYBACK);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,8 @@ int normalizationEnabled;
|
||||
|
||||
void initNormalization(void)
|
||||
{
|
||||
normalizationEnabled = getBoolConfigParam(CONF_VOLUME_NORMALIZATION, 1);
|
||||
if (normalizationEnabled == CONF_BOOL_UNSET)
|
||||
normalizationEnabled = DEFAULT_VOLUME_NORMALIZATION;
|
||||
normalizationEnabled = config_get_bool(CONF_VOLUME_NORMALIZATION,
|
||||
DEFAULT_VOLUME_NORMALIZATION);
|
||||
|
||||
if (normalizationEnabled)
|
||||
CompressCfg(0, ANTICLIP, TARGET, GAINMAX, GAINSMOOTH, BUCKETS);
|
||||
|
@ -121,7 +121,6 @@ void initPlaylist(void)
|
||||
{
|
||||
char *test;
|
||||
struct config_param *param;
|
||||
int value;
|
||||
|
||||
g_rand = g_rand_new();
|
||||
|
||||
@ -141,12 +140,9 @@ void initPlaylist(void)
|
||||
"line %i", param->value, param->line);
|
||||
}
|
||||
|
||||
value = getBoolConfigParam(CONF_SAVE_ABSOLUTE_PATHS, 1);
|
||||
if (value != CONF_BOOL_UNSET)
|
||||
playlist_saveAbsolutePaths = value;
|
||||
else
|
||||
playlist_saveAbsolutePaths =
|
||||
DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS;
|
||||
playlist_saveAbsolutePaths =
|
||||
config_get_bool(CONF_SAVE_ABSOLUTE_PATHS,
|
||||
DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS);
|
||||
|
||||
playlist.songs = g_malloc(sizeof(playlist.songs[0]) *
|
||||
playlist_max_length);
|
||||
|
@ -37,10 +37,8 @@ void initZeroconf(void)
|
||||
const char *serviceName = SERVICE_NAME;
|
||||
struct config_param *param;
|
||||
|
||||
zeroconfEnabled = getBoolConfigParam(CONF_ZEROCONF_ENABLED, 1);
|
||||
if (zeroconfEnabled == CONF_BOOL_UNSET)
|
||||
zeroconfEnabled = DEFAULT_ZEROCONF_ENABLED;
|
||||
|
||||
zeroconfEnabled = config_get_bool(CONF_ZEROCONF_ENABLED,
|
||||
DEFAULT_ZEROCONF_ENABLED);
|
||||
if (!zeroconfEnabled)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user