diff --git a/src/event/MultiSocketMonitor.cxx b/src/event/MultiSocketMonitor.cxx index f22b0a022..5ef8b98af 100644 --- a/src/event/MultiSocketMonitor.cxx +++ b/src/event/MultiSocketMonitor.cxx @@ -19,6 +19,7 @@ #include "config.h" #include "MultiSocketMonitor.hxx" +#include "Loop.hxx" #include @@ -35,6 +36,14 @@ MultiSocketMonitor::~MultiSocketMonitor() // TODO } +void +MultiSocketMonitor::ClearSocketList() +{ + assert(GetEventLoop().IsInsideOrNull()); + + fds.clear(); +} + #ifndef WIN32 void diff --git a/src/event/MultiSocketMonitor.hxx b/src/event/MultiSocketMonitor.hxx index 963745be1..150f7baad 100644 --- a/src/event/MultiSocketMonitor.hxx +++ b/src/event/MultiSocketMonitor.hxx @@ -125,6 +125,11 @@ public: fds.emplace_front(*this, fd, events); } + /** + * Remove all sockets. + */ + void ClearSocketList(); + /** * Update the known sockets by invoking the given function for * each one; its return value is the events bit mask. A diff --git a/src/mixer/AlsaMixerPlugin.cxx b/src/mixer/AlsaMixerPlugin.cxx index f0d9b8007..4f92e697d 100644 --- a/src/mixer/AlsaMixerPlugin.cxx +++ b/src/mixer/AlsaMixerPlugin.cxx @@ -91,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)