conf: use config_get_bool() instead of getBoolConfigParam()

This commit is contained in:
Max Kellermann 2009-01-17 20:23:33 +01:00
parent 4d472c265e
commit a1a97cc048
6 changed files with 16 additions and 33 deletions

View File

@ -429,30 +429,24 @@ parseConfigFilePath(const char *name, int force)
return param; 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); struct config_param *param = config_get_param(name);
int value;
if (!param) if (param == NULL)
return CONF_BOOL_UNSET; return default_value;
ret = get_bool(param->value); value = get_bool(param->value);
if (force && ret == CONF_BOOL_INVALID) if (value == CONF_BOOL_INVALID)
g_error("%s is not a boolean value (yes, true, 1) or " g_error("%s is not a boolean value (yes, true, 1) or "
"(no, false, 0) on line %i\n", "(no, false, 0) on line %i\n",
name, param->line); 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) if (value == CONF_BOOL_UNSET)
return default_value; return default_value;
return value; return !!value;
} }
int int

View File

@ -106,8 +106,6 @@ getBlockParam(struct config_param *param, const char *name);
struct config_param * struct config_param *
parseConfigFilePath(const char *name, int force); parseConfigFilePath(const char *name, int force);
int getBoolConfigParam(const char *name, int force);
bool config_get_bool(const char *name, bool default_value); bool config_get_bool(const char *name, bool default_value);
int int

View File

@ -93,10 +93,8 @@ mad_fixed_to_24_buffer(int32_t *dest, const struct mad_synth *synth,
static bool mp3_plugin_init(void) static bool mp3_plugin_init(void)
{ {
int ret = getBoolConfigParam(CONF_GAPLESS_MP3_PLAYBACK, true); gapless_playback = config_get_bool(CONF_GAPLESS_MP3_PLAYBACK,
gapless_playback = ret != CONF_BOOL_UNSET DEFAULT_GAPLESS_MP3_PLAYBACK);
? !!ret
: DEFAULT_GAPLESS_MP3_PLAYBACK;
return true; return true;
} }

View File

@ -27,9 +27,8 @@ int normalizationEnabled;
void initNormalization(void) void initNormalization(void)
{ {
normalizationEnabled = getBoolConfigParam(CONF_VOLUME_NORMALIZATION, 1); normalizationEnabled = config_get_bool(CONF_VOLUME_NORMALIZATION,
if (normalizationEnabled == CONF_BOOL_UNSET) DEFAULT_VOLUME_NORMALIZATION);
normalizationEnabled = DEFAULT_VOLUME_NORMALIZATION;
if (normalizationEnabled) if (normalizationEnabled)
CompressCfg(0, ANTICLIP, TARGET, GAINMAX, GAINSMOOTH, BUCKETS); CompressCfg(0, ANTICLIP, TARGET, GAINMAX, GAINSMOOTH, BUCKETS);

View File

@ -121,7 +121,6 @@ void initPlaylist(void)
{ {
char *test; char *test;
struct config_param *param; struct config_param *param;
int value;
g_rand = g_rand_new(); g_rand = g_rand_new();
@ -141,12 +140,9 @@ void initPlaylist(void)
"line %i", param->value, param->line); "line %i", param->value, param->line);
} }
value = getBoolConfigParam(CONF_SAVE_ABSOLUTE_PATHS, 1); playlist_saveAbsolutePaths =
if (value != CONF_BOOL_UNSET) config_get_bool(CONF_SAVE_ABSOLUTE_PATHS,
playlist_saveAbsolutePaths = value; DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS);
else
playlist_saveAbsolutePaths =
DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS;
playlist.songs = g_malloc(sizeof(playlist.songs[0]) * playlist.songs = g_malloc(sizeof(playlist.songs[0]) *
playlist_max_length); playlist_max_length);

View File

@ -37,10 +37,8 @@ void initZeroconf(void)
const char *serviceName = SERVICE_NAME; const char *serviceName = SERVICE_NAME;
struct config_param *param; struct config_param *param;
zeroconfEnabled = getBoolConfigParam(CONF_ZEROCONF_ENABLED, 1); zeroconfEnabled = config_get_bool(CONF_ZEROCONF_ENABLED,
if (zeroconfEnabled == CONF_BOOL_UNSET) DEFAULT_ZEROCONF_ENABLED);
zeroconfEnabled = DEFAULT_ZEROCONF_ENABLED;
if (!zeroconfEnabled) if (!zeroconfEnabled)
return; return;