diff options
author | Max Kellermann <max@duempel.org> | 2014-01-04 15:35:38 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-04 15:58:59 +0100 |
commit | 87fce8ef27dd86d492cb3072a3b3a5a756607b1e (patch) | |
tree | d4d157f2b3852316fbcf6d02c4554bdb324d437f | |
parent | d2a4f64fd605d7192f62977376c0928cef3a1efc (diff) | |
download | mpd-87fce8ef27dd86d492cb3072a3b3a5a756607b1e.tar.gz mpd-87fce8ef27dd86d492cb3072a3b3a5a756607b1e.tar.xz mpd-87fce8ef27dd86d492cb3072a3b3a5a756607b1e.zip |
mixer/alsa: use DeferredMonitor to update file descriptors
EventLoop::AddCall() and EventLoop::AddIdle() are unsafe, because we
can't cancel those calls.
-rw-r--r-- | src/mixer/AlsaMixerPlugin.cxx | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/mixer/AlsaMixerPlugin.cxx b/src/mixer/AlsaMixerPlugin.cxx index 75ba8825c..2691f9406 100644 --- a/src/mixer/AlsaMixerPlugin.cxx +++ b/src/mixer/AlsaMixerPlugin.cxx @@ -23,8 +23,8 @@ #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" @@ -40,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_INTERNAL_EVENTLOOP - _loop.AddCall([this](){ InvalidateSockets(); }); -#else - _loop.AddIdle(InitAlsaMixerMonitor, this); -#endif + :MultiSocketMonitor(_loop), DeferredMonitor(_loop), + mixer(_mixer) { + DeferredMonitor::Schedule(); } private: -#ifndef USE_INTERNAL_EVENTLOOP - 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; |