Commit 37f984ba authored by Max Kellermann's avatar Max Kellermann

output/Control: avoid sending KILL twice

parent cd612c4e
...@@ -377,7 +377,9 @@ AudioOutputControl::BeginDestroy() noexcept ...@@ -377,7 +377,9 @@ AudioOutputControl::BeginDestroy() noexcept
{ {
if (thread.IsDefined()) { if (thread.IsDefined()) {
const std::lock_guard<Mutex> protect(mutex); const std::lock_guard<Mutex> protect(mutex);
if (IsCommandFinished()) if (!killed) {
killed = true;
CommandAsync(Command::KILL); CommandAsync(Command::KILL);
}
} }
} }
...@@ -212,6 +212,15 @@ class AudioOutputControl { ...@@ -212,6 +212,15 @@ class AudioOutputControl {
*/ */
bool skip_delay; 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: public:
/** /**
* This mutex protects #open, #fail_timer, #pipe. * This mutex protects #open, #fail_timer, #pipe.
......
...@@ -526,6 +526,8 @@ AudioOutputControl::StartThread() ...@@ -526,6 +526,8 @@ AudioOutputControl::StartThread()
{ {
assert(command == Command::NONE); assert(command == Command::NONE);
killed = false;
const ScopeUnlock unlock(mutex); const ScopeUnlock unlock(mutex);
thread.Start(); thread.Start();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment