summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-11-24 16:52:31 +0100
committerMax Kellermann <max@musicpd.org>2016-11-24 17:34:57 +0100
commit1261327fa61fbf01adaab639bb012dae58ddab1a (patch)
treecded186fbde9eacef7ee8e931b25115de6995dd2 /src
parent09c3cc58e4bd7ce32f3c7368339f8fc537a0dbdf (diff)
ReplayGainInfo: implement fallback in Get()
Eliminates Complete().
Diffstat (limited to 'src')
-rw-r--r--src/ReplayGainInfo.cxx7
-rw-r--r--src/ReplayGainInfo.hxx14
-rw-r--r--src/filter/plugins/ReplayGainFilterPlugin.cxx5
3 files changed, 9 insertions, 17 deletions
diff --git a/src/ReplayGainInfo.cxx b/src/ReplayGainInfo.cxx
index a87ae551f..3524811a0 100644
--- a/src/ReplayGainInfo.cxx
+++ b/src/ReplayGainInfo.cxx
@@ -41,10 +41,3 @@ ReplayGainTuple::CalculateScale(float preamp, float missing_preamp,
return scale;
}
-
-void
-ReplayGainInfo::Complete()
-{
- if (!tuples[REPLAY_GAIN_ALBUM].IsDefined())
- tuples[REPLAY_GAIN_ALBUM] = tuples[REPLAY_GAIN_TRACK];
-}
diff --git a/src/ReplayGainInfo.hxx b/src/ReplayGainInfo.hxx
index baa041bf7..432171b3f 100644
--- a/src/ReplayGainInfo.hxx
+++ b/src/ReplayGainInfo.hxx
@@ -57,19 +57,19 @@ struct ReplayGainInfo {
}
const ReplayGainTuple &Get(ReplayGainMode mode) const {
- return tuples[mode];
+ return mode == REPLAY_GAIN_ALBUM
+ ? (tuples[REPLAY_GAIN_ALBUM].IsDefined()
+ ? tuples[REPLAY_GAIN_ALBUM]
+ : tuples[REPLAY_GAIN_TRACK])
+ : (tuples[REPLAY_GAIN_TRACK].IsDefined()
+ ? tuples[REPLAY_GAIN_TRACK]
+ : tuples[REPLAY_GAIN_ALBUM]);
}
void Clear() {
tuples[REPLAY_GAIN_ALBUM].Clear();
tuples[REPLAY_GAIN_TRACK].Clear();
}
-
- /**
- * Attempt to auto-complete missing data. In particular, if
- * album information is missing, track gain is used.
- */
- void Complete();
};
#endif
diff --git a/src/filter/plugins/ReplayGainFilterPlugin.cxx b/src/filter/plugins/ReplayGainFilterPlugin.cxx
index 1f72a12ae..da4a3bca2 100644
--- a/src/filter/plugins/ReplayGainFilterPlugin.cxx
+++ b/src/filter/plugins/ReplayGainFilterPlugin.cxx
@@ -79,10 +79,9 @@ public:
}
void SetInfo(const ReplayGainInfo *_info) {
- if (_info != nullptr) {
+ if (_info != nullptr)
info = *_info;
- info.Complete();
- } else
+ else
info.Clear();
Update();