diff options
Diffstat (limited to '')
-rw-r--r-- | src/mixer/plugins/AlsaMixerPlugin.cxx | 16 | ||||
-rw-r--r-- | src/mixer/plugins/NullMixerPlugin.cxx | 67 | ||||
-rw-r--r-- | src/mixer/plugins/OssMixerPlugin.cxx | 16 | ||||
-rw-r--r-- | src/mixer/plugins/PulseMixerPlugin.cxx | 30 | ||||
-rw-r--r-- | src/mixer/plugins/PulseMixerPlugin.hxx | 2 | ||||
-rw-r--r-- | src/mixer/plugins/RoarMixerPlugin.cxx | 4 | ||||
-rw-r--r-- | src/mixer/plugins/SoftwareMixerPlugin.cxx | 8 | ||||
-rw-r--r-- | src/mixer/plugins/SoftwareMixerPlugin.hxx | 2 | ||||
-rw-r--r-- | src/mixer/plugins/WinmmMixerPlugin.cxx | 4 |
9 files changed, 106 insertions, 43 deletions
diff --git a/src/mixer/plugins/AlsaMixerPlugin.cxx b/src/mixer/plugins/AlsaMixerPlugin.cxx index cd787182a..2b89f24e1 100644 --- a/src/mixer/plugins/AlsaMixerPlugin.cxx +++ b/src/mixer/plugins/AlsaMixerPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -82,7 +82,7 @@ public: virtual ~AlsaMixer(); - void Configure(const config_param ¶m); + void Configure(const ConfigBlock &block); bool Setup(Error &error); /* virtual methods from class Mixer */ @@ -162,24 +162,24 @@ alsa_mixer_elem_callback(snd_mixer_elem_t *elem, unsigned mask) */ inline void -AlsaMixer::Configure(const config_param ¶m) +AlsaMixer::Configure(const ConfigBlock &block) { - device = param.GetBlockValue("mixer_device", + device = block.GetBlockValue("mixer_device", VOLUME_MIXER_ALSA_DEFAULT); - control = param.GetBlockValue("mixer_control", + control = block.GetBlockValue("mixer_control", VOLUME_MIXER_ALSA_CONTROL_DEFAULT); - index = param.GetBlockValue("mixer_index", + index = block.GetBlockValue("mixer_index", VOLUME_MIXER_ALSA_INDEX_DEFAULT); } static Mixer * alsa_mixer_init(EventLoop &event_loop, gcc_unused AudioOutput &ao, MixerListener &listener, - const config_param ¶m, + const ConfigBlock &block, gcc_unused Error &error) { AlsaMixer *am = new AlsaMixer(event_loop, listener); - am->Configure(param); + am->Configure(block); return am; } diff --git a/src/mixer/plugins/NullMixerPlugin.cxx b/src/mixer/plugins/NullMixerPlugin.cxx new file mode 100644 index 000000000..d846a6be1 --- /dev/null +++ b/src/mixer/plugins/NullMixerPlugin.cxx @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2003-2015 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 ConfigBlock &block, + gcc_unused Error &error) +{ + return new NullMixer(listener); +} + +const MixerPlugin null_mixer_plugin = { + null_mixer_init, + true, +}; diff --git a/src/mixer/plugins/OssMixerPlugin.cxx b/src/mixer/plugins/OssMixerPlugin.cxx index 6615c7022..ae198492c 100644 --- a/src/mixer/plugins/OssMixerPlugin.cxx +++ b/src/mixer/plugins/OssMixerPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -19,7 +19,7 @@ #include "config.h" #include "mixer/MixerInternal.hxx" -#include "config/ConfigData.hxx" +#include "config/Block.hxx" #include "system/fd_util.h" #include "util/ASCII.hxx" #include "util/Error.hxx" @@ -52,7 +52,7 @@ public: OssMixer(MixerListener &_listener) :Mixer(oss_mixer_plugin, _listener) {} - bool Configure(const config_param ¶m, Error &error); + bool Configure(const ConfigBlock &block, Error &error); /* virtual methods from class Mixer */ virtual bool Open(Error &error) override; @@ -79,10 +79,10 @@ oss_find_mixer(const char *name) } inline bool -OssMixer::Configure(const config_param ¶m, Error &error) +OssMixer::Configure(const ConfigBlock &block, Error &error) { - device = param.GetBlockValue("mixer_device", VOLUME_MIXER_OSS_DEFAULT); - control = param.GetBlockValue("mixer_control"); + device = block.GetBlockValue("mixer_device", VOLUME_MIXER_OSS_DEFAULT); + control = block.GetBlockValue("mixer_control"); if (control != NULL) { volume_control = oss_find_mixer(control); @@ -100,12 +100,12 @@ OssMixer::Configure(const config_param ¶m, Error &error) static Mixer * oss_mixer_init(gcc_unused EventLoop &event_loop, gcc_unused AudioOutput &ao, MixerListener &listener, - const config_param ¶m, + const ConfigBlock &block, Error &error) { OssMixer *om = new OssMixer(listener); - if (!om->Configure(param, error)) { + if (!om->Configure(block, error)) { delete om; return nullptr; } diff --git a/src/mixer/plugins/PulseMixerPlugin.cxx b/src/mixer/plugins/PulseMixerPlugin.cxx index c5f20723b..f2b17a75a 100644 --- a/src/mixer/plugins/PulseMixerPlugin.cxx +++ b/src/mixer/plugins/PulseMixerPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -19,18 +19,18 @@ #include "config.h" #include "PulseMixerPlugin.hxx" +#include "lib/pulse/Domain.hxx" +#include "lib/pulse/LogError.hxx" #include "mixer/MixerInternal.hxx" #include "mixer/Listener.hxx" #include "output/plugins/PulseOutputPlugin.hxx" #include "util/Error.hxx" -#include "util/Domain.hxx" #include "Log.hxx" #include <pulse/context.h> #include <pulse/introspect.h> #include <pulse/stream.h> #include <pulse/subscribe.h> -#include <pulse/error.h> #include <assert.h> @@ -55,19 +55,17 @@ public: int GetVolumeInternal(Error &error); /* virtual methods from class Mixer */ - virtual bool Open(gcc_unused Error &error) override { + bool Open(gcc_unused Error &error) override { return true; } - virtual void Close() override { + void Close() override { } - virtual int GetVolume(Error &error) override; - virtual bool SetVolume(unsigned volume, Error &error) override; + int GetVolume(Error &error) override; + bool SetVolume(unsigned volume, Error &error) override; }; -static constexpr Domain pulse_mixer_domain("pulse_mixer"); - void PulseMixer::Offline() { @@ -120,9 +118,8 @@ PulseMixer::Update(pa_context *context, pa_stream *stream) pa_stream_get_index(stream), pulse_mixer_volume_cb, this); if (o == nullptr) { - FormatError(pulse_mixer_domain, - "pa_context_get_sink_input_info() failed: %s", - pa_strerror(pa_context_errno(context))); + LogPulseError(context, + "pa_context_get_sink_input_info() failed"); Offline(); return; } @@ -142,9 +139,8 @@ pulse_mixer_on_connect(gcc_unused PulseMixer &pm, (pa_subscription_mask_t)PA_SUBSCRIPTION_MASK_SINK_INPUT, nullptr, nullptr); if (o == nullptr) { - FormatError(pulse_mixer_domain, - "pa_context_subscribe() failed: %s", - pa_strerror(pa_context_errno(context))); + LogPulseError(context, + "pa_context_subscribe() failed"); return; } @@ -167,7 +163,7 @@ pulse_mixer_on_change(PulseMixer &pm, static Mixer * pulse_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao, MixerListener &listener, - gcc_unused const config_param ¶m, + gcc_unused const ConfigBlock &block, gcc_unused Error &error) { PulseOutput &po = (PulseOutput &)ao; @@ -212,7 +208,7 @@ PulseMixer::SetVolume(unsigned new_volume, Error &error) if (!online) { pulse_output_unlock(output); - error.Set(pulse_mixer_domain, "disconnected"); + error.Set(pulse_domain, "disconnected"); return false; } diff --git a/src/mixer/plugins/PulseMixerPlugin.hxx b/src/mixer/plugins/PulseMixerPlugin.hxx index 9b3a6daf1..64605ea8d 100644 --- a/src/mixer/plugins/PulseMixerPlugin.hxx +++ b/src/mixer/plugins/PulseMixerPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/mixer/plugins/RoarMixerPlugin.cxx b/src/mixer/plugins/RoarMixerPlugin.cxx index 8e198478d..9123762f2 100644 --- a/src/mixer/plugins/RoarMixerPlugin.cxx +++ b/src/mixer/plugins/RoarMixerPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * Copyright (C) 2010-2011 Philipp 'ph3-der-loewe' Schafft * Copyright (C) 2010-2011 Hans-Kristian 'maister' Arntzen * @@ -48,7 +48,7 @@ public: static Mixer * roar_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao, MixerListener &listener, - gcc_unused const config_param ¶m, + gcc_unused const ConfigBlock &block, gcc_unused Error &error) { return new RoarMixer((RoarOutput &)ao, listener); diff --git a/src/mixer/plugins/SoftwareMixerPlugin.cxx b/src/mixer/plugins/SoftwareMixerPlugin.cxx index f14766002..d35e7f469 100644 --- a/src/mixer/plugins/SoftwareMixerPlugin.cxx +++ b/src/mixer/plugins/SoftwareMixerPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -25,7 +25,7 @@ #include "filter/FilterInternal.hxx" #include "filter/plugins/VolumeFilterPlugin.hxx" #include "pcm/Volume.hxx" -#include "config/ConfigData.hxx" +#include "config/Block.hxx" #include "util/Error.hxx" #include <assert.h> @@ -34,7 +34,7 @@ static Filter * CreateVolumeFilter() { - return filter_new(&volume_filter_plugin, config_param(), + return filter_new(&volume_filter_plugin, ConfigBlock(), IgnoreError()); } @@ -90,7 +90,7 @@ static Mixer * software_mixer_init(gcc_unused EventLoop &event_loop, gcc_unused AudioOutput &ao, MixerListener &listener, - gcc_unused const config_param ¶m, + gcc_unused const ConfigBlock &block, gcc_unused Error &error) { return new SoftwareMixer(listener); diff --git a/src/mixer/plugins/SoftwareMixerPlugin.hxx b/src/mixer/plugins/SoftwareMixerPlugin.hxx index 581d2ac17..f9be1d9d9 100644 --- a/src/mixer/plugins/SoftwareMixerPlugin.hxx +++ b/src/mixer/plugins/SoftwareMixerPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/mixer/plugins/WinmmMixerPlugin.cxx b/src/mixer/plugins/WinmmMixerPlugin.cxx index e0436011a..51d8092f9 100644 --- a/src/mixer/plugins/WinmmMixerPlugin.cxx +++ b/src/mixer/plugins/WinmmMixerPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -69,7 +69,7 @@ winmm_volume_encode(int volume) static Mixer * winmm_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao, MixerListener &listener, - gcc_unused const config_param ¶m, + gcc_unused const ConfigBlock &block, gcc_unused Error &error) { return new WinmmMixer((WinmmOutput &)ao, listener); |