Commit 7cb82fe8 authored by Max Kellermann's avatar Max Kellermann

output/Thread: move code to InternalClose()

parent 0494779e
...@@ -385,6 +385,11 @@ private: ...@@ -385,6 +385,11 @@ private:
const MusicPipe &pipe) noexcept; const MusicPipe &pipe) noexcept;
/** /**
* Runs inside the OutputThread.
*/
void InternalClose(bool drain) noexcept;
/**
* Wait until the output's delay reaches zero. * Wait until the output's delay reaches zero.
* *
* @return true if playback should be continued, false if a * @return true if playback should be continued, false if a
......
...@@ -215,8 +215,7 @@ AudioOutputControl::InternalDisable() noexcept ...@@ -215,8 +215,7 @@ AudioOutputControl::InternalDisable() noexcept
if (!really_enabled) if (!really_enabled)
return; return;
if (output->open) InternalClose(false);
output->Close(false);
really_enabled = false; really_enabled = false;
output->Disable(); output->Disable();
...@@ -243,6 +242,15 @@ AudioOutputControl::InternalOpen(const AudioFormat audio_format, ...@@ -243,6 +242,15 @@ AudioOutputControl::InternalOpen(const AudioFormat audio_format,
} }
} }
inline void
AudioOutputControl::InternalClose(bool drain) noexcept
{
if (!IsOpen())
return;
output->Close(drain);
}
void void
AudioOutput::Close(bool drain) noexcept AudioOutput::Close(bool drain) noexcept
{ {
...@@ -299,7 +307,7 @@ try { ...@@ -299,7 +307,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);
output->Close(false); InternalClose(false);
/* don't automatically reopen this device for 10 /* don't automatically reopen this device for 10
seconds */ seconds */
...@@ -347,7 +355,7 @@ AudioOutputControl::PlayChunk() noexcept ...@@ -347,7 +355,7 @@ AudioOutputControl::PlayChunk() noexcept
} }
if (nbytes == 0) { if (nbytes == 0) {
output->Close(false); InternalClose(false);
/* don't automatically reopen this device for /* don't automatically reopen this device for
10 seconds */ 10 seconds */
...@@ -491,8 +499,7 @@ AudioOutputControl::Task() ...@@ -491,8 +499,7 @@ AudioOutputControl::Task()
break; break;
case Command::CLOSE: case Command::CLOSE:
if (IsOpen()) InternalClose(false);
output->Close(false);
CommandFinished(); CommandFinished();
break; break;
......
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