summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-11-24 17:21:23 +0100
committerMax Kellermann <max@musicpd.org>2016-11-24 17:34:57 +0100
commit5f396e824fd25b9d27b0866070d5c9addcbc3a07 (patch)
tree6abf00ca1ad9f0f0f2ca63a840572f723b68e42c /src
parent4f229c254c5a99a95e080ec3e3c429990f29a41d (diff)
ReplayGainMode: convert to strictly-typed enum
Diffstat (limited to 'src')
-rw-r--r--src/Partition.cxx6
-rw-r--r--src/Partition.hxx2
-rw-r--r--src/ReplayGainConfig.cxx18
-rw-r--r--src/ReplayGainInfo.hxx2
-rw-r--r--src/ReplayGainMode.hxx12
-rw-r--r--src/decoder/Bridge.cxx6
-rw-r--r--src/filter/plugins/ReplayGainFilterPlugin.cxx8
-rw-r--r--src/output/Internal.hxx2
8 files changed, 29 insertions, 27 deletions
diff --git a/src/Partition.cxx b/src/Partition.cxx
index 8aca29dde..f3027e05c 100644
--- a/src/Partition.cxx
+++ b/src/Partition.cxx
@@ -45,10 +45,10 @@ Partition::EmitIdle(unsigned mask)
void
Partition::UpdateEffectiveReplayGainMode(ReplayGainMode mode)
{
- if (mode == REPLAY_GAIN_AUTO)
+ if (mode == ReplayGainMode::AUTO)
mode = playlist.queue.random
- ? REPLAY_GAIN_TRACK
- : REPLAY_GAIN_ALBUM;
+ ? ReplayGainMode::TRACK
+ : ReplayGainMode::ALBUM;
outputs.SetReplayGainMode(mode);
}
diff --git a/src/Partition.hxx b/src/Partition.hxx
index 5cfba615e..b7bccca6b 100644
--- a/src/Partition.hxx
+++ b/src/Partition.hxx
@@ -178,7 +178,7 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
/**
* Publishes the effective #ReplayGainMode to all subsystems.
- * #REPLAY_GAIN_AUTO is substituted.
+ * #ReplayGainMode::AUTO is substituted.
*
* @param mode the configured mode
*/
diff --git a/src/ReplayGainConfig.cxx b/src/ReplayGainConfig.cxx
index 98b555abe..68b8c4b77 100644
--- a/src/ReplayGainConfig.cxx
+++ b/src/ReplayGainConfig.cxx
@@ -28,7 +28,7 @@
#include <string.h>
#include <math.h>
-ReplayGainMode replay_gain_mode = REPLAY_GAIN_OFF;
+ReplayGainMode replay_gain_mode = ReplayGainMode::OFF;
static constexpr bool DEFAULT_REPLAYGAIN_LIMIT = true;
@@ -40,16 +40,16 @@ const char *
replay_gain_get_mode_string(void)
{
switch (replay_gain_mode) {
- case REPLAY_GAIN_AUTO:
+ case ReplayGainMode::AUTO:
return "auto";
- case REPLAY_GAIN_OFF:
+ case ReplayGainMode::OFF:
return "off";
- case REPLAY_GAIN_TRACK:
+ case ReplayGainMode::TRACK:
return "track";
- case REPLAY_GAIN_ALBUM:
+ case ReplayGainMode::ALBUM:
return "album";
}
@@ -63,13 +63,13 @@ replay_gain_set_mode_string(const char *p)
assert(p != nullptr);
if (strcmp(p, "off") == 0)
- replay_gain_mode = REPLAY_GAIN_OFF;
+ replay_gain_mode = ReplayGainMode::OFF;
else if (strcmp(p, "track") == 0)
- replay_gain_mode = REPLAY_GAIN_TRACK;
+ replay_gain_mode = ReplayGainMode::TRACK;
else if (strcmp(p, "album") == 0)
- replay_gain_mode = REPLAY_GAIN_ALBUM;
+ replay_gain_mode = ReplayGainMode::ALBUM;
else if (strcmp(p, "auto") == 0)
- replay_gain_mode = REPLAY_GAIN_AUTO;
+ replay_gain_mode = ReplayGainMode::AUTO;
else
return false;
diff --git a/src/ReplayGainInfo.hxx b/src/ReplayGainInfo.hxx
index 9bcd3f0f0..ae14635ad 100644
--- a/src/ReplayGainInfo.hxx
+++ b/src/ReplayGainInfo.hxx
@@ -50,7 +50,7 @@ struct ReplayGainInfo {
}
const ReplayGainTuple &Get(ReplayGainMode mode) const {
- return mode == REPLAY_GAIN_ALBUM
+ return mode == ReplayGainMode::ALBUM
? (album.IsDefined() ? album : track)
: (track.IsDefined() ? track : album);
}
diff --git a/src/ReplayGainMode.hxx b/src/ReplayGainMode.hxx
index 8893aba14..c564cda9c 100644
--- a/src/ReplayGainMode.hxx
+++ b/src/ReplayGainMode.hxx
@@ -20,11 +20,13 @@
#ifndef MPD_REPLAY_GAIN_MODE_HXX
#define MPD_REPLAY_GAIN_MODE_HXX
-enum ReplayGainMode {
- REPLAY_GAIN_AUTO = -2,
- REPLAY_GAIN_OFF,
- REPLAY_GAIN_ALBUM,
- REPLAY_GAIN_TRACK,
+#include <stdint.h>
+
+enum class ReplayGainMode : uint8_t {
+ OFF,
+ ALBUM,
+ TRACK,
+ AUTO,
};
#endif
diff --git a/src/decoder/Bridge.cxx b/src/decoder/Bridge.cxx
index 633f2a55a..f878a6708 100644
--- a/src/decoder/Bridge.cxx
+++ b/src/decoder/Bridge.cxx
@@ -592,10 +592,10 @@ DecoderBridge::SubmitReplayGain(const ReplayGainInfo *new_replay_gain_info)
if (++serial == 0)
serial = 1;
- if (REPLAY_GAIN_OFF != replay_gain_mode) {
+ if (ReplayGainMode::OFF != replay_gain_mode) {
ReplayGainMode rgm = replay_gain_mode;
- if (rgm != REPLAY_GAIN_ALBUM)
- rgm = REPLAY_GAIN_TRACK;
+ if (rgm != ReplayGainMode::ALBUM)
+ rgm = ReplayGainMode::TRACK;
const auto &tuple = new_replay_gain_info->Get(rgm);
const auto scale =
diff --git a/src/filter/plugins/ReplayGainFilterPlugin.cxx b/src/filter/plugins/ReplayGainFilterPlugin.cxx
index da4a3bca2..3c8ce751d 100644
--- a/src/filter/plugins/ReplayGainFilterPlugin.cxx
+++ b/src/filter/plugins/ReplayGainFilterPlugin.cxx
@@ -50,7 +50,7 @@ class ReplayGainFilter final : public Filter {
*/
const unsigned base;
- ReplayGainMode mode = REPLAY_GAIN_OFF;
+ ReplayGainMode mode = ReplayGainMode::OFF;
ReplayGainInfo info;
@@ -72,7 +72,7 @@ public:
ReplayGainFilter(const AudioFormat &audio_format,
Mixer *_mixer, unsigned _base)
:Filter(audio_format),
- mixer(_mixer), base(_base), mode(REPLAY_GAIN_OFF) {
+ mixer(_mixer), base(_base) {
info.Clear();
pv.Open(out_audio_format.format);
@@ -94,7 +94,7 @@ public:
FormatDebug(replay_gain_domain,
"replay gain mode has changed %d->%d\n",
- mode, _mode);
+ (int)mode, (int)_mode);
mode = _mode;
Update();
@@ -138,7 +138,7 @@ void
ReplayGainFilter::Update()
{
unsigned volume = PCM_VOLUME_1;
- if (mode != REPLAY_GAIN_OFF) {
+ if (mode != ReplayGainMode::OFF) {
const auto &tuple = info.Get(mode);
float scale = tuple.CalculateScale(replay_gain_preamp,
replay_gain_missing_preamp,
diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx
index 2c5f4ba56..393269690 100644
--- a/src/output/Internal.hxx
+++ b/src/output/Internal.hxx
@@ -148,7 +148,7 @@ struct AudioOutput {
*/
bool woken_for_play = false;
- ReplayGainMode replay_gain_mode = REPLAY_GAIN_OFF;
+ ReplayGainMode replay_gain_mode = ReplayGainMode::OFF;
/**
* If not nullptr, the device has failed, and this timer is used