summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/output/Control.cxx4
-rw-r--r--src/output/Control.hxx9
-rw-r--r--src/output/Thread.cxx2
3 files changed, 14 insertions, 1 deletions
diff --git a/src/output/Control.cxx b/src/output/Control.cxx
index a50ac5012..efcef67e4 100644
--- a/src/output/Control.cxx
+++ b/src/output/Control.cxx
@@ -377,7 +377,9 @@ AudioOutputControl::BeginDestroy() noexcept
{
if (thread.IsDefined()) {
const std::lock_guard<Mutex> protect(mutex);
- if (IsCommandFinished())
+ if (!killed) {
+ killed = true;
CommandAsync(Command::KILL);
+ }
}
}
diff --git a/src/output/Control.hxx b/src/output/Control.hxx
index 9c6d78f7e..b1e33793f 100644
--- a/src/output/Control.hxx
+++ b/src/output/Control.hxx
@@ -212,6 +212,15 @@ class AudioOutputControl {
*/
bool skip_delay;
+ /**
+ * Has Command::KILL already been sent? This field is only
+ * defined if `thread` is defined. It shall avoid sending the
+ * command twice.
+ *
+ * Protected by #mutex.
+ */
+ bool killed;
+
public:
/**
* This mutex protects #open, #fail_timer, #pipe.
diff --git a/src/output/Thread.cxx b/src/output/Thread.cxx
index 8362fac8c..18193c0e4 100644
--- a/src/output/Thread.cxx
+++ b/src/output/Thread.cxx
@@ -526,6 +526,8 @@ AudioOutputControl::StartThread()
{
assert(command == Command::NONE);
+ killed = false;
+
const ScopeUnlock unlock(mutex);
thread.Start();
}