aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-02-17 08:13:34 +0100
committerMax Kellermann <max@duempel.org>2010-02-17 08:13:34 +0100
commit48b49e230352de10bb3f66a1c85d367dade52001 (patch)
treef457ea9daf5f53f11bb62ff91bb52620dbd265bc
parent752dfb3d95482c562e5d24c6ea839c4815de9a6d (diff)
downloadmpd-48b49e230352de10bb3f66a1c85d367dade52001.tar.gz
mpd-48b49e230352de10bb3f66a1c85d367dade52001.tar.xz
mpd-48b49e230352de10bb3f66a1c85d367dade52001.zip
replay_gain: fall back to track gain if album gain is unavailable
Diffstat (limited to '')
-rw-r--r--NEWS1
-rw-r--r--src/filter/replay_gain_filter_plugin.c5
-rw-r--r--src/replay_gain_info.c8
-rw-r--r--src/replay_gain_info.h7
4 files changed, 19 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 4000a1933..480a4c16b 100644
--- a/NEWS
+++ b/NEWS
@@ -72,6 +72,7 @@ ver 0.16 (20??/??/??)
- automatically convert to 16 bit samples
* replay gain:
- reimplemented as a filter plugin
+ - fall back to track gain if album gain is unavailable
* log unused/unknown block parameters
* removed the deprecated "error_file" option
* save state when stopped
diff --git a/src/filter/replay_gain_filter_plugin.c b/src/filter/replay_gain_filter_plugin.c
index 396f185cc..248690d17 100644
--- a/src/filter/replay_gain_filter_plugin.c
+++ b/src/filter/replay_gain_filter_plugin.c
@@ -184,9 +184,10 @@ replay_gain_filter_set_info(struct filter *_filter,
struct replay_gain_filter *filter =
(struct replay_gain_filter *)_filter;
- if (info != NULL)
+ if (info != NULL) {
filter->info = *info;
- else
+ replay_gain_info_complete(&filter->info);
+ } else
replay_gain_info_init(&filter->info);
replay_gain_filter_update(filter);
diff --git a/src/replay_gain_info.c b/src/replay_gain_info.c
index 76bd98acd..9ab5b05fa 100644
--- a/src/replay_gain_info.c
+++ b/src/replay_gain_info.c
@@ -35,3 +35,11 @@ replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp)
return scale;
}
+
+void
+replay_gain_info_complete(struct replay_gain_info *info)
+{
+ if (!replay_gain_tuple_defined(&info->tuples[REPLAY_GAIN_ALBUM]))
+ info->tuples[REPLAY_GAIN_ALBUM] =
+ info->tuples[REPLAY_GAIN_TRACK];
+}
diff --git a/src/replay_gain_info.h b/src/replay_gain_info.h
index c61bac387..f39974d59 100644
--- a/src/replay_gain_info.h
+++ b/src/replay_gain_info.h
@@ -63,4 +63,11 @@ replay_gain_tuple_defined(const struct replay_gain_tuple *tuple)
float
replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp);
+/**
+ * Attempt to auto-complete missing data. In particular, if album
+ * information is missing, track gain is used.
+ */
+void
+replay_gain_info_complete(struct replay_gain_info *info);
+
#endif