Commit b4cce807 authored by Max Kellermann's avatar Max Kellermann

output/Thread: move code to InternalClose()

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