diff --git a/src/output/plugins/httpd/HttpdInternal.hxx b/src/output/plugins/httpd/HttpdInternal.hxx index b300866de..6dacef467 100644 --- a/src/output/plugins/httpd/HttpdInternal.hxx +++ b/src/output/plugins/httpd/HttpdInternal.hxx @@ -31,7 +31,7 @@ #include "thread/Mutex.hxx" #include "thread/Cond.hxx" #include "event/ServerSocket.hxx" -#include "event/DeferredMonitor.hxx" +#include "event/DeferEvent.hxx" #include "util/Cast.hxx" #include "Compiler.h" @@ -48,7 +48,7 @@ class PreparedEncoder; class Encoder; struct Tag; -class HttpdOutput final : AudioOutput, ServerSocket, DeferredMonitor { +class HttpdOutput final : AudioOutput, ServerSocket { /** * True if the audio output is open and accepts client * connections. @@ -114,6 +114,8 @@ private: */ std::queue> pages; + DeferEvent defer_broadcast; + public: /** * The configured name. @@ -157,7 +159,7 @@ public: return new HttpdOutput(event_loop, block); } - using DeferredMonitor::GetEventLoop; + using ServerSocket::GetEventLoop; void Bind(); void Unbind(); @@ -255,7 +257,8 @@ public: bool Pause() override; private: - virtual void RunDeferred() override; + /* DeferEvent callback */ + void OnDeferredBroadcast() noexcept; void OnAccept(UniqueSocketDescriptor fd, SocketAddress address, int uid) override; diff --git a/src/output/plugins/httpd/HttpdOutputPlugin.cxx b/src/output/plugins/httpd/HttpdOutputPlugin.cxx index 8bc832e76..d3860b887 100644 --- a/src/output/plugins/httpd/HttpdOutputPlugin.cxx +++ b/src/output/plugins/httpd/HttpdOutputPlugin.cxx @@ -51,7 +51,8 @@ const Domain httpd_output_domain("httpd_output"); inline HttpdOutput::HttpdOutput(EventLoop &_loop, const ConfigBlock &block) :AudioOutput(FLAG_ENABLE_DISABLE|FLAG_PAUSE), - ServerSocket(_loop), DeferredMonitor(_loop) + ServerSocket(_loop), + defer_broadcast(_loop, BIND_THIS_METHOD(OnDeferredBroadcast)) { /* read configuration */ name = block.GetBlockValue("name", "Set name in config"); @@ -128,7 +129,7 @@ HttpdOutput::AddClient(UniqueSocketDescriptor fd) } void -HttpdOutput::RunDeferred() +HttpdOutput::OnDeferredBroadcast() noexcept { /* this method runs in the IOThread; it broadcasts pages from our own queue to all clients */ @@ -258,7 +259,7 @@ HttpdOutput::Close() noexcept delete timer; BlockingCall(GetEventLoop(), [this](){ - DeferredMonitor::Cancel(); + defer_broadcast.Cancel(); const std::lock_guard protect(mutex); open = false; @@ -317,7 +318,7 @@ HttpdOutput::BroadcastPage(PagePtr page) pages.emplace(std::move(page)); } - DeferredMonitor::Schedule(); + defer_broadcast.Schedule(); } void @@ -340,7 +341,7 @@ HttpdOutput::BroadcastFromEncoder() } if (!empty) - DeferredMonitor::Schedule(); + defer_broadcast.Schedule(); } inline void