diff options
author | Max Kellermann <max@duempel.org> | 2009-01-17 20:23:33 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-17 20:23:33 +0100 |
commit | a1a97cc048a443eb71944848592b9827991600fd (patch) | |
tree | e3bfbf5bd38a851d2823b99a00f4abba9ba1db43 /src | |
parent | 4d472c265ed0b3f7f61ee624c01c8ef319db7c99 (diff) | |
download | mpd-a1a97cc048a443eb71944848592b9827991600fd.tar.gz mpd-a1a97cc048a443eb71944848592b9827991600fd.tar.xz mpd-a1a97cc048a443eb71944848592b9827991600fd.zip |
conf: use config_get_bool() instead of getBoolConfigParam()
Diffstat (limited to 'src')
-rw-r--r-- | src/conf.c | 20 | ||||
-rw-r--r-- | src/conf.h | 2 | ||||
-rw-r--r-- | src/decoder/mp3_plugin.c | 6 | ||||
-rw-r--r-- | src/normalize.c | 5 | ||||
-rw-r--r-- | src/playlist.c | 10 | ||||
-rw-r--r-- | src/zeroconf.c | 6 |
6 files changed, 16 insertions, 33 deletions
diff --git a/src/conf.c b/src/conf.c index be4db9018..d1decadcd 100644 --- a/src/conf.c +++ b/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 diff --git a/src/conf.h b/src/conf.h index 97713f0af..33782beb5 100644 --- a/src/conf.h +++ b/src/conf.h @@ -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 diff --git a/src/decoder/mp3_plugin.c b/src/decoder/mp3_plugin.c index fd0ac21a9..fda866133 100644 --- a/src/decoder/mp3_plugin.c +++ b/src/decoder/mp3_plugin.c @@ -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; } diff --git a/src/normalize.c b/src/normalize.c index da655a648..60da15e75 100644 --- a/src/normalize.c +++ b/src/normalize.c @@ -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); diff --git a/src/playlist.c b/src/playlist.c index 4d4e0102d..20ea05907 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -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); diff --git a/src/zeroconf.c b/src/zeroconf.c index f2945c4cc..dad9a8b7a 100644 --- a/src/zeroconf.c +++ b/src/zeroconf.c @@ -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; |