diff options
author | Daniel Seuthe <daniel+mpd@seuthe.org> | 2010-04-25 13:42:23 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2010-04-25 13:51:58 +0200 |
commit | 92e66e5ab2c6fa56c4a36da4f959f7321749ab8c (patch) | |
tree | 3ed0903b674b9bc9d4954a0a8b1a5c35cc773e4d /src | |
parent | 54dedef9cf0e85901ac7edaab30e015010603352 (diff) | |
download | mpd-92e66e5ab2c6fa56c4a36da4f959f7321749ab8c.tar.gz mpd-92e66e5ab2c6fa56c4a36da4f959f7321749ab8c.tar.xz mpd-92e66e5ab2c6fa56c4a36da4f959f7321749ab8c.zip |
replay_gain: added mode "auto"
Diffstat (limited to 'src')
-rw-r--r-- | src/filter/replay_gain_filter_plugin.c | 19 | ||||
-rw-r--r-- | src/replay_gain_config.c | 5 | ||||
-rw-r--r-- | src/replay_gain_info.h | 3 |
3 files changed, 23 insertions, 4 deletions
diff --git a/src/filter/replay_gain_filter_plugin.c b/src/filter/replay_gain_filter_plugin.c index c8e74c7fe..159b2eab2 100644 --- a/src/filter/replay_gain_filter_plugin.c +++ b/src/filter/replay_gain_filter_plugin.c @@ -28,6 +28,7 @@ #include "replay_gain_info.h" #include "replay_gain_config.h" #include "mixer_control.h" +#include "playlist.h" #include <assert.h> #include <string.h> @@ -114,7 +115,11 @@ replay_gain_filter_init(G_GNUC_UNUSED const struct config_param *param, filter_init(&filter->filter, &replay_gain_filter_plugin); filter->mixer = NULL; - filter->mode = replay_gain_mode; + if (replay_gain_mode == REPLAY_GAIN_AUTO) { + filter->mode = g_playlist.queue.random ? REPLAY_GAIN_TRACK : REPLAY_GAIN_ALBUM; + } else { + filter->mode = replay_gain_mode; + } replay_gain_info_init(&filter->info); filter->volume = PCM_VOLUME_1; @@ -161,10 +166,18 @@ replay_gain_filter_filter(struct filter *_filter, (struct replay_gain_filter *)_filter; bool success; void *dest; + enum replay_gain_mode rg_mode; /* check if the mode has been changed since the last call */ - if (filter->mode != replay_gain_mode) { - filter->mode = replay_gain_mode; + if (replay_gain_mode == REPLAY_GAIN_AUTO) { + rg_mode = g_playlist.queue.random ? REPLAY_GAIN_TRACK : REPLAY_GAIN_ALBUM; + } else { + rg_mode = replay_gain_mode; + } + + if (filter->mode != rg_mode) { + g_debug("replay gain mode has changed %d->%d\n", filter->mode, rg_mode); + filter->mode = rg_mode; replay_gain_filter_update(filter); } diff --git a/src/replay_gain_config.c b/src/replay_gain_config.c index 7cb08bba3..3eae9d960 100644 --- a/src/replay_gain_config.c +++ b/src/replay_gain_config.c @@ -43,6 +43,9 @@ const char * replay_gain_get_mode_string(void) { switch (replay_gain_mode) { + case REPLAY_GAIN_AUTO: + return "auto"; + case REPLAY_GAIN_OFF: return "off"; @@ -69,6 +72,8 @@ replay_gain_set_mode_string(const char *p) replay_gain_mode = REPLAY_GAIN_TRACK; else if (strcmp(p, "album") == 0) replay_gain_mode = REPLAY_GAIN_ALBUM; + else if (strcmp(p, "auto") == 0) + replay_gain_mode = REPLAY_GAIN_AUTO; else return false; diff --git a/src/replay_gain_info.h b/src/replay_gain_info.h index f39974d59..49f375b04 100644 --- a/src/replay_gain_info.h +++ b/src/replay_gain_info.h @@ -26,7 +26,8 @@ #include <math.h> enum replay_gain_mode { - REPLAY_GAIN_OFF = -1, + REPLAY_GAIN_AUTO = -2, + REPLAY_GAIN_OFF, REPLAY_GAIN_ALBUM, REPLAY_GAIN_TRACK, }; |