MixerType: convert to strictly-typed enum
This commit is contained in:
parent
21c42819c7
commit
f2bd2c318c
@ -29,11 +29,11 @@ mixer_type_parse(const char *input)
|
|||||||
assert(input != NULL);
|
assert(input != NULL);
|
||||||
|
|
||||||
if (strcmp(input, "none") == 0 || strcmp(input, "disabled") == 0)
|
if (strcmp(input, "none") == 0 || strcmp(input, "disabled") == 0)
|
||||||
return MIXER_TYPE_NONE;
|
return MixerType::NONE;
|
||||||
else if (strcmp(input, "hardware") == 0)
|
else if (strcmp(input, "hardware") == 0)
|
||||||
return MIXER_TYPE_HARDWARE;
|
return MixerType::HARDWARE;
|
||||||
else if (strcmp(input, "software") == 0)
|
else if (strcmp(input, "software") == 0)
|
||||||
return MIXER_TYPE_SOFTWARE;
|
return MixerType::SOFTWARE;
|
||||||
else
|
else
|
||||||
return MIXER_TYPE_UNKNOWN;
|
return MixerType::UNKNOWN;
|
||||||
}
|
}
|
||||||
|
@ -20,26 +20,26 @@
|
|||||||
#ifndef MPD_MIXER_TYPE_HXX
|
#ifndef MPD_MIXER_TYPE_HXX
|
||||||
#define MPD_MIXER_TYPE_HXX
|
#define MPD_MIXER_TYPE_HXX
|
||||||
|
|
||||||
enum MixerType {
|
enum class MixerType {
|
||||||
/** parser error */
|
/** parser error */
|
||||||
MIXER_TYPE_UNKNOWN,
|
UNKNOWN,
|
||||||
|
|
||||||
/** mixer disabled */
|
/** mixer disabled */
|
||||||
MIXER_TYPE_NONE,
|
NONE,
|
||||||
|
|
||||||
/** software mixer with pcm_volume() */
|
/** software mixer with pcm_volume() */
|
||||||
MIXER_TYPE_SOFTWARE,
|
SOFTWARE,
|
||||||
|
|
||||||
/** hardware mixer (output's plugin) */
|
/** hardware mixer (output's plugin) */
|
||||||
MIXER_TYPE_HARDWARE,
|
HARDWARE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a #MixerType setting from the configuration file.
|
* Parses a #MixerType setting from the configuration file.
|
||||||
*
|
*
|
||||||
* @param input the configured string value; must not be NULL
|
* @param input the configured string value; must not be NULL @return
|
||||||
* @return a #MixerType value; MIXER_TYPE_UNKNOWN means #input could
|
* a #MixerType value; #MixerType::UNKNOWN means #input could not be
|
||||||
* not be parsed
|
* parsed
|
||||||
*/
|
*/
|
||||||
MixerType
|
MixerType
|
||||||
mixer_type_parse(const char *input);
|
mixer_type_parse(const char *input);
|
||||||
|
@ -103,7 +103,7 @@ audio_output_mixer_type(const config_param ¶m)
|
|||||||
|
|
||||||
/* try the local "mixer_enabled" setting next (deprecated) */
|
/* try the local "mixer_enabled" setting next (deprecated) */
|
||||||
if (!param.GetBlockValue("mixer_enabled", true))
|
if (!param.GetBlockValue("mixer_enabled", true))
|
||||||
return MIXER_TYPE_NONE;
|
return MixerType::NONE;
|
||||||
|
|
||||||
/* fall back to the global "mixer_type" setting (also
|
/* fall back to the global "mixer_type" setting (also
|
||||||
deprecated) */
|
deprecated) */
|
||||||
@ -122,18 +122,18 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
|
|||||||
Mixer *mixer;
|
Mixer *mixer;
|
||||||
|
|
||||||
switch (audio_output_mixer_type(param)) {
|
switch (audio_output_mixer_type(param)) {
|
||||||
case MIXER_TYPE_NONE:
|
case MixerType::NONE:
|
||||||
case MIXER_TYPE_UNKNOWN:
|
case MixerType::UNKNOWN:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
case MIXER_TYPE_HARDWARE:
|
case MixerType::HARDWARE:
|
||||||
if (plugin == nullptr)
|
if (plugin == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return mixer_new(event_loop, *plugin, ao, listener,
|
return mixer_new(event_loop, *plugin, ao, listener,
|
||||||
param, error);
|
param, error);
|
||||||
|
|
||||||
case MIXER_TYPE_SOFTWARE:
|
case MixerType::SOFTWARE:
|
||||||
mixer = mixer_new(event_loop, software_mixer_plugin, ao,
|
mixer = mixer_new(event_loop, software_mixer_plugin, ao,
|
||||||
listener,
|
listener,
|
||||||
config_param(),
|
config_param(),
|
||||||
|
Loading…
Reference in New Issue
Block a user