aboutsummaryrefslogtreecommitdiffstats
path: root/src/mixer
diff options
context:
space:
mode:
Diffstat (limited to 'src/mixer')
-rw-r--r--src/mixer/MixerList.hxx1
-rw-r--r--src/mixer/MixerType.cxx12
-rw-r--r--src/mixer/MixerType.hxx23
-rw-r--r--src/mixer/plugins/NullMixerPlugin.cxx67
4 files changed, 88 insertions, 15 deletions
diff --git a/src/mixer/MixerList.hxx b/src/mixer/MixerList.hxx
index e75b2e6ff..8be74adf2 100644
--- a/src/mixer/MixerList.hxx
+++ b/src/mixer/MixerList.hxx
@@ -27,6 +27,7 @@
struct MixerPlugin;
+extern const MixerPlugin null_mixer_plugin;
extern const MixerPlugin software_mixer_plugin;
extern const MixerPlugin alsa_mixer_plugin;
extern const MixerPlugin oss_mixer_plugin;
diff --git a/src/mixer/MixerType.cxx b/src/mixer/MixerType.cxx
index cd45db0d9..8972118e5 100644
--- a/src/mixer/MixerType.cxx
+++ b/src/mixer/MixerType.cxx
@@ -23,17 +23,19 @@
#include <assert.h>
#include <string.h>
-enum mixer_type
+MixerType
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 if (strcmp(input, "null") == 0)
+ return MixerType::NULL_;
else
- return MIXER_TYPE_UNKNOWN;
+ return MixerType::UNKNOWN;
}
diff --git a/src/mixer/MixerType.hxx b/src/mixer/MixerType.hxx
index bfa2637b7..40f60203d 100644
--- a/src/mixer/MixerType.hxx
+++ b/src/mixer/MixerType.hxx
@@ -20,28 +20,31 @@
#ifndef MPD_MIXER_TYPE_HXX
#define MPD_MIXER_TYPE_HXX
-enum mixer_type {
+enum class MixerType {
/** parser error */
- MIXER_TYPE_UNKNOWN,
+ UNKNOWN,
/** mixer disabled */
- MIXER_TYPE_NONE,
+ NONE,
+
+ /** "null" mixer (virtual fake) */
+ NULL_,
/** software mixer with pcm_volume() */
- MIXER_TYPE_SOFTWARE,
+ SOFTWARE,
/** hardware mixer (output's plugin) */
- MIXER_TYPE_HARDWARE,
+ HARDWARE,
};
/**
- * Parses a "mixer_type" setting from the configuration file.
+ * Parses a #MixerType setting from the configuration file.
*
- * @param input the configured string value; must not be NULL
- * @return a #mixer_type 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
*/
-enum mixer_type
+MixerType
mixer_type_parse(const char *input);
#endif
diff --git a/src/mixer/plugins/NullMixerPlugin.cxx b/src/mixer/plugins/NullMixerPlugin.cxx
new file mode 100644
index 000000000..b8894d443
--- /dev/null
+++ b/src/mixer/plugins/NullMixerPlugin.cxx
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * http://www.musicpd.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+#include "mixer/MixerInternal.hxx"
+
+class NullMixer final : public Mixer {
+ /**
+ * The current volume in percent (0..100).
+ */
+ unsigned volume;
+
+public:
+ NullMixer(MixerListener &_listener)
+ :Mixer(null_mixer_plugin, _listener),
+ volume(100)
+ {
+ }
+
+ /* virtual methods from class Mixer */
+ bool Open(gcc_unused Error &error) override {
+ return true;
+ }
+
+ void Close() override {
+ }
+
+ int GetVolume(gcc_unused Error &error) override {
+ return volume;
+ }
+
+ bool SetVolume(unsigned _volume, gcc_unused Error &error) override {
+ volume = _volume;
+ return true;
+ }
+};
+
+static Mixer *
+null_mixer_init(gcc_unused EventLoop &event_loop,
+ gcc_unused AudioOutput &ao,
+ MixerListener &listener,
+ gcc_unused const config_param &param,
+ gcc_unused Error &error)
+{
+ return new NullMixer(listener);
+}
+
+const MixerPlugin null_mixer_plugin = {
+ null_mixer_init,
+ true,
+};