ReplayGainMode: convert to strictly-typed enum
This commit is contained in:
parent
4f229c254c
commit
5f396e824f
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 =
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user