Commit b4cce807 authored by Max Kellermann's avatar Max Kellermann

output/Thread: move code to InternalClose()

parent 89a2e5de
...@@ -425,6 +425,11 @@ private: ...@@ -425,6 +425,11 @@ private:
/** /**
* Runs inside the OutputThread. * Runs inside the OutputThread.
*/ */
void InternalClose(bool drain) noexcept;
/**
* Runs inside the OutputThread.
*/
void InternalCheckClose(bool drain) noexcept; void InternalCheckClose(bool drain) noexcept;
/** /**
......
...@@ -172,16 +172,22 @@ AudioOutputControl::InternalOpen(const AudioFormat in_audio_format, ...@@ -172,16 +172,22 @@ AudioOutputControl::InternalOpen(const AudioFormat in_audio_format,
} }
inline void inline void
AudioOutputControl::InternalCheckClose(bool drain) noexcept AudioOutputControl::InternalClose(bool drain) noexcept
{ {
if (!IsOpen()) assert(IsOpen());
return;
open = false; open = false;
output->Close(drain); output->Close(drain);
source.Close(); source.Close();
} }
inline void
AudioOutputControl::InternalCheckClose(bool drain) noexcept
{
if (IsOpen())
InternalClose(drain);
}
/** /**
* Wait until the output's delay reaches zero. * Wait until the output's delay reaches zero.
* *
...@@ -211,7 +217,7 @@ try { ...@@ -211,7 +217,7 @@ try {
FormatError(e, "Failed to filter for output \"%s\" [%s]", FormatError(e, "Failed to filter for output \"%s\" [%s]",
GetName(), output->plugin.name); GetName(), output->plugin.name);
InternalCheckClose(false); InternalClose(false);
/* don't automatically reopen this device for 10 /* don't automatically reopen this device for 10
seconds */ seconds */
...@@ -259,7 +265,7 @@ AudioOutputControl::PlayChunk() noexcept ...@@ -259,7 +265,7 @@ AudioOutputControl::PlayChunk() noexcept
} }
if (nbytes == 0) { if (nbytes == 0) {
InternalCheckClose(false); InternalClose(false);
/* don't automatically reopen this device for /* don't automatically reopen this device for
10 seconds */ 10 seconds */
...@@ -330,9 +336,7 @@ AudioOutputControl::InternalPause() noexcept ...@@ -330,9 +336,7 @@ AudioOutputControl::InternalPause() noexcept
break; break;
if (!output->IteratePause()) { if (!output->IteratePause()) {
open = false; InternalClose(false);
output->Close(false);
source.Close();
break; break;
} }
} while (command == Command::NONE); } while (command == Command::NONE);
......
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