output/Thread: move code to InternalClose()

This commit is contained in:
Max Kellermann 2017-08-07 16:34:29 +02:00
parent 89a2e5ded3
commit b4cce80727
2 changed files with 17 additions and 8 deletions

View File

@ -422,6 +422,11 @@ private:
void InternalOpen(AudioFormat audio_format,
const MusicPipe &pipe) noexcept;
/**
* Runs inside the OutputThread.
*/
void InternalClose(bool drain) noexcept;
/**
* Runs inside the OutputThread.
*/

View File

@ -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);