From 5f656dffda1f62604cc97553b2cf4951be206328 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 8 Mar 2021 19:55:14 +0100 Subject: [PATCH] output/wasapi: implement Cancel() --- src/output/plugins/wasapi/WasapiOutputPlugin.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx index 970f6e8cd..508d3f71d 100644 --- a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx +++ b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx @@ -258,6 +258,7 @@ public: std::chrono::steady_clock::duration Delay() const noexcept override; size_t Play(const void *chunk, size_t size) override; void Drain() override; + void Cancel() noexcept override; bool Pause() override; void Interrupt() noexcept override; @@ -664,6 +665,14 @@ WasapiOutput::Drain() thread->CheckException(); } +void +WasapiOutput::Cancel() noexcept +{ + assert(thread); + + thread->spsc_buffer.consume_all([](auto &&) {}); +} + /// run inside COMWorkerThread void WasapiOutput::OpenDevice()