ReplayGainMode: convert to strictly-typed enum
This commit is contained in:
parent
4f229c254c
commit
5f396e824f
@ -45,10 +45,10 @@ Partition::EmitIdle(unsigned mask)
|
|||||||
void
|
void
|
||||||
Partition::UpdateEffectiveReplayGainMode(ReplayGainMode mode)
|
Partition::UpdateEffectiveReplayGainMode(ReplayGainMode mode)
|
||||||
{
|
{
|
||||||
if (mode == REPLAY_GAIN_AUTO)
|
if (mode == ReplayGainMode::AUTO)
|
||||||
mode = playlist.queue.random
|
mode = playlist.queue.random
|
||||||
? REPLAY_GAIN_TRACK
|
? ReplayGainMode::TRACK
|
||||||
: REPLAY_GAIN_ALBUM;
|
: ReplayGainMode::ALBUM;
|
||||||
|
|
||||||
outputs.SetReplayGainMode(mode);
|
outputs.SetReplayGainMode(mode);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Publishes the effective #ReplayGainMode to all subsystems.
|
* Publishes the effective #ReplayGainMode to all subsystems.
|
||||||
* #REPLAY_GAIN_AUTO is substituted.
|
* #ReplayGainMode::AUTO is substituted.
|
||||||
*
|
*
|
||||||
* @param mode the configured mode
|
* @param mode the configured mode
|
||||||
*/
|
*/
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
ReplayGainMode replay_gain_mode = REPLAY_GAIN_OFF;
|
ReplayGainMode replay_gain_mode = ReplayGainMode::OFF;
|
||||||
|
|
||||||
static constexpr bool DEFAULT_REPLAYGAIN_LIMIT = true;
|
static constexpr bool DEFAULT_REPLAYGAIN_LIMIT = true;
|
||||||
|
|
||||||
@ -40,16 +40,16 @@ const char *
|
|||||||
replay_gain_get_mode_string(void)
|
replay_gain_get_mode_string(void)
|
||||||
{
|
{
|
||||||
switch (replay_gain_mode) {
|
switch (replay_gain_mode) {
|
||||||
case REPLAY_GAIN_AUTO:
|
case ReplayGainMode::AUTO:
|
||||||
return "auto";
|
return "auto";
|
||||||
|
|
||||||
case REPLAY_GAIN_OFF:
|
case ReplayGainMode::OFF:
|
||||||
return "off";
|
return "off";
|
||||||
|
|
||||||
case REPLAY_GAIN_TRACK:
|
case ReplayGainMode::TRACK:
|
||||||
return "track";
|
return "track";
|
||||||
|
|
||||||
case REPLAY_GAIN_ALBUM:
|
case ReplayGainMode::ALBUM:
|
||||||
return "album";
|
return "album";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,13 +63,13 @@ replay_gain_set_mode_string(const char *p)
|
|||||||
assert(p != nullptr);
|
assert(p != nullptr);
|
||||||
|
|
||||||
if (strcmp(p, "off") == 0)
|
if (strcmp(p, "off") == 0)
|
||||||
replay_gain_mode = REPLAY_GAIN_OFF;
|
replay_gain_mode = ReplayGainMode::OFF;
|
||||||
else if (strcmp(p, "track") == 0)
|
else if (strcmp(p, "track") == 0)
|
||||||
replay_gain_mode = REPLAY_GAIN_TRACK;
|
replay_gain_mode = ReplayGainMode::TRACK;
|
||||||
else if (strcmp(p, "album") == 0)
|
else if (strcmp(p, "album") == 0)
|
||||||
replay_gain_mode = REPLAY_GAIN_ALBUM;
|
replay_gain_mode = ReplayGainMode::ALBUM;
|
||||||
else if (strcmp(p, "auto") == 0)
|
else if (strcmp(p, "auto") == 0)
|
||||||
replay_gain_mode = REPLAY_GAIN_AUTO;
|
replay_gain_mode = ReplayGainMode::AUTO;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ struct ReplayGainInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ReplayGainTuple &Get(ReplayGainMode mode) const {
|
const ReplayGainTuple &Get(ReplayGainMode mode) const {
|
||||||
return mode == REPLAY_GAIN_ALBUM
|
return mode == ReplayGainMode::ALBUM
|
||||||
? (album.IsDefined() ? album : track)
|
? (album.IsDefined() ? album : track)
|
||||||
: (track.IsDefined() ? track : album);
|
: (track.IsDefined() ? track : album);
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,13 @@
|
|||||||
#ifndef MPD_REPLAY_GAIN_MODE_HXX
|
#ifndef MPD_REPLAY_GAIN_MODE_HXX
|
||||||
#define MPD_REPLAY_GAIN_MODE_HXX
|
#define MPD_REPLAY_GAIN_MODE_HXX
|
||||||
|
|
||||||
enum ReplayGainMode {
|
#include <stdint.h>
|
||||||
REPLAY_GAIN_AUTO = -2,
|
|
||||||
REPLAY_GAIN_OFF,
|
enum class ReplayGainMode : uint8_t {
|
||||||
REPLAY_GAIN_ALBUM,
|
OFF,
|
||||||
REPLAY_GAIN_TRACK,
|
ALBUM,
|
||||||
|
TRACK,
|
||||||
|
AUTO,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -592,10 +592,10 @@ DecoderBridge::SubmitReplayGain(const ReplayGainInfo *new_replay_gain_info)
|
|||||||
if (++serial == 0)
|
if (++serial == 0)
|
||||||
serial = 1;
|
serial = 1;
|
||||||
|
|
||||||
if (REPLAY_GAIN_OFF != replay_gain_mode) {
|
if (ReplayGainMode::OFF != replay_gain_mode) {
|
||||||
ReplayGainMode rgm = replay_gain_mode;
|
ReplayGainMode rgm = replay_gain_mode;
|
||||||
if (rgm != REPLAY_GAIN_ALBUM)
|
if (rgm != ReplayGainMode::ALBUM)
|
||||||
rgm = REPLAY_GAIN_TRACK;
|
rgm = ReplayGainMode::TRACK;
|
||||||
|
|
||||||
const auto &tuple = new_replay_gain_info->Get(rgm);
|
const auto &tuple = new_replay_gain_info->Get(rgm);
|
||||||
const auto scale =
|
const auto scale =
|
||||||
|
@ -50,7 +50,7 @@ class ReplayGainFilter final : public Filter {
|
|||||||
*/
|
*/
|
||||||
const unsigned base;
|
const unsigned base;
|
||||||
|
|
||||||
ReplayGainMode mode = REPLAY_GAIN_OFF;
|
ReplayGainMode mode = ReplayGainMode::OFF;
|
||||||
|
|
||||||
ReplayGainInfo info;
|
ReplayGainInfo info;
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ public:
|
|||||||
ReplayGainFilter(const AudioFormat &audio_format,
|
ReplayGainFilter(const AudioFormat &audio_format,
|
||||||
Mixer *_mixer, unsigned _base)
|
Mixer *_mixer, unsigned _base)
|
||||||
:Filter(audio_format),
|
:Filter(audio_format),
|
||||||
mixer(_mixer), base(_base), mode(REPLAY_GAIN_OFF) {
|
mixer(_mixer), base(_base) {
|
||||||
info.Clear();
|
info.Clear();
|
||||||
|
|
||||||
pv.Open(out_audio_format.format);
|
pv.Open(out_audio_format.format);
|
||||||
@ -94,7 +94,7 @@ public:
|
|||||||
|
|
||||||
FormatDebug(replay_gain_domain,
|
FormatDebug(replay_gain_domain,
|
||||||
"replay gain mode has changed %d->%d\n",
|
"replay gain mode has changed %d->%d\n",
|
||||||
mode, _mode);
|
(int)mode, (int)_mode);
|
||||||
|
|
||||||
mode = _mode;
|
mode = _mode;
|
||||||
Update();
|
Update();
|
||||||
@ -138,7 +138,7 @@ void
|
|||||||
ReplayGainFilter::Update()
|
ReplayGainFilter::Update()
|
||||||
{
|
{
|
||||||
unsigned volume = PCM_VOLUME_1;
|
unsigned volume = PCM_VOLUME_1;
|
||||||
if (mode != REPLAY_GAIN_OFF) {
|
if (mode != ReplayGainMode::OFF) {
|
||||||
const auto &tuple = info.Get(mode);
|
const auto &tuple = info.Get(mode);
|
||||||
float scale = tuple.CalculateScale(replay_gain_preamp,
|
float scale = tuple.CalculateScale(replay_gain_preamp,
|
||||||
replay_gain_missing_preamp,
|
replay_gain_missing_preamp,
|
||||||
|
@ -148,7 +148,7 @@ struct AudioOutput {
|
|||||||
*/
|
*/
|
||||||
bool woken_for_play = false;
|
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
|
* If not nullptr, the device has failed, and this timer is used
|
||||||
|
Loading…
Reference in New Issue
Block a user