diff options
Diffstat (limited to '')
-rw-r--r-- | src/mixer/AlsaMixerPlugin.cxx | 48 | ||||
-rw-r--r-- | src/mixer/OssMixerPlugin.cxx | 4 | ||||
-rw-r--r-- | src/mixer/PulseMixerPlugin.cxx | 2 | ||||
-rw-r--r-- | src/mixer/PulseMixerPlugin.hxx | 7 | ||||
-rw-r--r-- | src/mixer/RoarMixerPlugin.cxx | 2 | ||||
-rw-r--r-- | src/mixer/SoftwareMixerPlugin.cxx | 2 |
6 files changed, 18 insertions, 47 deletions
diff --git a/src/mixer/AlsaMixerPlugin.cxx b/src/mixer/AlsaMixerPlugin.cxx index 4a4ca433c..4f92e697d 100644 --- a/src/mixer/AlsaMixerPlugin.cxx +++ b/src/mixer/AlsaMixerPlugin.cxx @@ -23,10 +23,11 @@ #include "GlobalEvents.hxx" #include "Main.hxx" #include "event/MultiSocketMonitor.hxx" +#include "event/DeferredMonitor.hxx" #include "event/Loop.hxx" -#include "event/Call.hxx" #include "util/ASCII.hxx" #include "util/ReusableArray.hxx" +#include "util/Clamp.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "Log.hxx" @@ -39,29 +40,22 @@ #define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "PCM" static constexpr unsigned VOLUME_MIXER_ALSA_INDEX_DEFAULT = 0; -class AlsaMixerMonitor final : private MultiSocketMonitor { +class AlsaMixerMonitor final : MultiSocketMonitor, DeferredMonitor { snd_mixer_t *mixer; ReusableArray<pollfd> pfd_buffer; public: AlsaMixerMonitor(EventLoop &_loop, snd_mixer_t *_mixer) - :MultiSocketMonitor(_loop), mixer(_mixer) { -#ifdef USE_EPOLL - _loop.AddCall([this](){ InvalidateSockets(); }); -#else - _loop.AddIdle(InitAlsaMixerMonitor, this); -#endif + :MultiSocketMonitor(_loop), DeferredMonitor(_loop), + mixer(_mixer) { + DeferredMonitor::Schedule(); } private: -#ifndef USE_EPOLL - static gboolean InitAlsaMixerMonitor(gpointer data) { - AlsaMixerMonitor &amm = *(AlsaMixerMonitor *)data; - amm.InvalidateSockets(); - return false; + virtual void RunDeferred() override { + InvalidateSockets(); } -#endif virtual int PrepareSockets() override; virtual void DispatchSockets() override; @@ -97,8 +91,10 @@ static constexpr Domain alsa_mixer_domain("alsa_mixer"); int AlsaMixerMonitor::PrepareSockets() { - if (mixer == nullptr) + if (mixer == nullptr) { + ClearSocketList(); return -1; + } int count = snd_mixer_poll_descriptors_count(mixer); if (count < 0) @@ -110,24 +106,7 @@ AlsaMixerMonitor::PrepareSockets() if (count < 0) count = 0; - struct pollfd *end = pfds + count; - - UpdateSocketList([pfds, end](int fd) -> unsigned { - auto i = std::find_if(pfds, end, [fd](const struct pollfd &pfd){ - return pfd.fd == fd; - }); - if (i == end) - return 0; - - auto events = i->events; - i->events = 0; - return events; - }); - - for (auto i = pfds; i != end; ++i) - if (i->events != 0) - AddSocket(i->fd, i->events); - + ReplaceSocketList(pfds, count); return -1; } @@ -372,8 +351,7 @@ AlsaMixer::SetVolume(unsigned volume, Error &error) level = (long)(((vol / 100.0) * (volume_max - volume_min) + volume_min) + 0.5); - level = level > volume_max ? volume_max : level; - level = level < volume_min ? volume_min : level; + level = Clamp(level, volume_min, volume_max); err = snd_mixer_selem_set_playback_volume_all(elem, level); if (err < 0) { diff --git a/src/mixer/OssMixerPlugin.cxx b/src/mixer/OssMixerPlugin.cxx index 0a459bc97..7a91cfcb1 100644 --- a/src/mixer/OssMixerPlugin.cxx +++ b/src/mixer/OssMixerPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "MixerInternal.hxx" -#include "OutputAPI.hxx" +#include "ConfigData.hxx" #include "system/fd_util.h" #include "util/ASCII.hxx" #include "util/Error.hxx" @@ -28,10 +28,8 @@ #include <assert.h> #include <string.h> -#include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> -#include <errno.h> #include <stdlib.h> #include <unistd.h> diff --git a/src/mixer/PulseMixerPlugin.cxx b/src/mixer/PulseMixerPlugin.cxx index ff10256cb..84d42c392 100644 --- a/src/mixer/PulseMixerPlugin.cxx +++ b/src/mixer/PulseMixerPlugin.cxx @@ -26,7 +26,6 @@ #include "util/Domain.hxx" #include "Log.hxx" -#include <pulse/thread-mainloop.h> #include <pulse/context.h> #include <pulse/introspect.h> #include <pulse/stream.h> @@ -34,7 +33,6 @@ #include <pulse/error.h> #include <assert.h> -#include <string.h> struct PulseMixer final : public Mixer { PulseOutput *output; diff --git a/src/mixer/PulseMixerPlugin.hxx b/src/mixer/PulseMixerPlugin.hxx index fa73e0f5e..46bd06a01 100644 --- a/src/mixer/PulseMixerPlugin.hxx +++ b/src/mixer/PulseMixerPlugin.hxx @@ -20,20 +20,17 @@ #ifndef MPD_PULSE_MIXER_PLUGIN_HXX #define MPD_PULSE_MIXER_PLUGIN_HXX -#include <pulse/def.h> - struct PulseMixer; struct pa_context; struct pa_stream; void -pulse_mixer_on_connect(PulseMixer *pm, struct pa_context *context); +pulse_mixer_on_connect(PulseMixer *pm, pa_context *context); void pulse_mixer_on_disconnect(PulseMixer *pm); void -pulse_mixer_on_change(PulseMixer *pm, - struct pa_context *context, struct pa_stream *stream); +pulse_mixer_on_change(PulseMixer *pm, pa_context *context, pa_stream *stream); #endif diff --git a/src/mixer/RoarMixerPlugin.cxx b/src/mixer/RoarMixerPlugin.cxx index 6bd700551..75147329e 100644 --- a/src/mixer/RoarMixerPlugin.cxx +++ b/src/mixer/RoarMixerPlugin.cxx @@ -21,8 +21,8 @@ #include "config.h" #include "MixerInternal.hxx" -#include "OutputAPI.hxx" #include "output/RoarOutputPlugin.hxx" +#include "Compiler.h" struct RoarMixer final : public Mixer { /** the base mixer class */ diff --git a/src/mixer/SoftwareMixerPlugin.cxx b/src/mixer/SoftwareMixerPlugin.cxx index 193e68f23..e5f4b1659 100644 --- a/src/mixer/SoftwareMixerPlugin.cxx +++ b/src/mixer/SoftwareMixerPlugin.cxx @@ -24,7 +24,7 @@ #include "FilterRegistry.hxx" #include "FilterInternal.hxx" #include "filter/VolumeFilterPlugin.hxx" -#include "pcm/PcmVolume.hxx" +#include "pcm/Volume.hxx" #include "ConfigData.hxx" #include "util/Error.hxx" |