aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-10-17 22:40:50 +0200
committerMax Kellermann <max@duempel.org>2009-10-17 22:40:50 +0200
commit7ec32704f9b0cd22f7bde1654a5e80bb28ee9e22 (patch)
treedd41b98a7ba6d56d3d9a0f18d2ea9041a833245c
parent8d217567c6494c42bf849ea27f66e14e20788857 (diff)
downloadmpd-7ec32704f9b0cd22f7bde1654a5e80bb28ee9e22.tar.gz
mpd-7ec32704f9b0cd22f7bde1654a5e80bb28ee9e22.tar.xz
mpd-7ec32704f9b0cd22f7bde1654a5e80bb28ee9e22.zip
replay_gain: moved mode parser to replay_gain_set_mode_string()
-rw-r--r--src/replay_gain.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/replay_gain.c b/src/replay_gain.c
index e1c7db9fe..5bfa765fe 100644
--- a/src/replay_gain.c
+++ b/src/replay_gain.c
@@ -26,6 +26,8 @@
#include "pcm_volume.h"
#include <glib.h>
+
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
@@ -40,17 +42,28 @@ enum replay_gain_mode replay_gain_mode = REPLAY_GAIN_OFF;
static float replay_gain_preamp = 1.0;
static float replay_gain_missing_preamp = 1.0;
-void replay_gain_global_init(void)
+static bool
+replay_gain_set_mode_string(const char *p)
{
- const struct config_param *param = config_get_param(CONF_REPLAYGAIN);
+ assert(p != NULL);
- if (param == NULL || strcmp(param->value, "off") == 0) {
+ if (strcmp(p, "off") == 0)
replay_gain_mode = REPLAY_GAIN_OFF;
- } else if (strcmp(param->value, "track") == 0) {
+ else if (strcmp(p, "track") == 0)
replay_gain_mode = REPLAY_GAIN_TRACK;
- } else if (strcmp(param->value, "album") == 0) {
+ else if (strcmp(p, "album") == 0)
replay_gain_mode = REPLAY_GAIN_ALBUM;
- } else {
+ else
+ return false;
+
+ return true;
+}
+
+void replay_gain_global_init(void)
+{
+ const struct config_param *param = config_get_param(CONF_REPLAYGAIN);
+
+ if (param != NULL && !replay_gain_set_mode_string(param->value)) {
g_error("replaygain value \"%s\" at line %i is invalid\n",
param->value, param->line);
}