From f2bd2c318c810645b4e3c7518d695d6d4b1c06a7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Dec 2014 18:17:47 +0100 Subject: [PATCH] MixerType: convert to strictly-typed enum --- src/mixer/MixerType.cxx | 8 ++++---- src/mixer/MixerType.hxx | 16 ++++++++-------- src/output/Init.cxx | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/mixer/MixerType.cxx b/src/mixer/MixerType.cxx index 47016fd0a..0605f0979 100644 --- a/src/mixer/MixerType.cxx +++ b/src/mixer/MixerType.cxx @@ -29,11 +29,11 @@ mixer_type_parse(const char *input) assert(input != NULL); if (strcmp(input, "none") == 0 || strcmp(input, "disabled") == 0) - return MIXER_TYPE_NONE; + return MixerType::NONE; else if (strcmp(input, "hardware") == 0) - return MIXER_TYPE_HARDWARE; + return MixerType::HARDWARE; else if (strcmp(input, "software") == 0) - return MIXER_TYPE_SOFTWARE; + return MixerType::SOFTWARE; else - return MIXER_TYPE_UNKNOWN; + return MixerType::UNKNOWN; } diff --git a/src/mixer/MixerType.hxx b/src/mixer/MixerType.hxx index a5e635e06..9831e3db6 100644 --- a/src/mixer/MixerType.hxx +++ b/src/mixer/MixerType.hxx @@ -20,26 +20,26 @@ #ifndef MPD_MIXER_TYPE_HXX #define MPD_MIXER_TYPE_HXX -enum MixerType { +enum class MixerType { /** parser error */ - MIXER_TYPE_UNKNOWN, + UNKNOWN, /** mixer disabled */ - MIXER_TYPE_NONE, + NONE, /** software mixer with pcm_volume() */ - MIXER_TYPE_SOFTWARE, + SOFTWARE, /** hardware mixer (output's plugin) */ - MIXER_TYPE_HARDWARE, + HARDWARE, }; /** * Parses a #MixerType setting from the configuration file. * - * @param input the configured string value; must not be NULL - * @return a #MixerType value; MIXER_TYPE_UNKNOWN means #input could - * not be parsed + * @param input the configured string value; must not be NULL @return + * a #MixerType value; #MixerType::UNKNOWN means #input could not be + * parsed */ MixerType mixer_type_parse(const char *input); diff --git a/src/output/Init.cxx b/src/output/Init.cxx index f195f6b8b..3518c5c64 100644 --- a/src/output/Init.cxx +++ b/src/output/Init.cxx @@ -103,7 +103,7 @@ audio_output_mixer_type(const config_param ¶m) /* try the local "mixer_enabled" setting next (deprecated) */ if (!param.GetBlockValue("mixer_enabled", true)) - return MIXER_TYPE_NONE; + return MixerType::NONE; /* fall back to the global "mixer_type" setting (also deprecated) */ @@ -122,18 +122,18 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao, Mixer *mixer; switch (audio_output_mixer_type(param)) { - case MIXER_TYPE_NONE: - case MIXER_TYPE_UNKNOWN: + case MixerType::NONE: + case MixerType::UNKNOWN: return nullptr; - case MIXER_TYPE_HARDWARE: + case MixerType::HARDWARE: if (plugin == nullptr) return nullptr; return mixer_new(event_loop, *plugin, ao, listener, param, error); - case MIXER_TYPE_SOFTWARE: + case MixerType::SOFTWARE: mixer = mixer_new(event_loop, software_mixer_plugin, ao, listener, config_param(),