From 7cb82fe8f3762ca33fc2c4912ffcb7f0e6f54af9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 8 Jun 2017 21:59:48 +0200 Subject: [PATCH] output/Thread: move code to InternalClose() --- src/output/Control.hxx | 5 +++++ src/output/Thread.cxx | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/output/Control.hxx b/src/output/Control.hxx index 14e4033b4..6306e9625 100644 --- a/src/output/Control.hxx +++ b/src/output/Control.hxx @@ -384,6 +384,11 @@ private: void InternalOpen(AudioFormat audio_format, const MusicPipe &pipe) noexcept; + /** + * Runs inside the OutputThread. + */ + void InternalClose(bool drain) noexcept; + /** * Wait until the output's delay reaches zero. * diff --git a/src/output/Thread.cxx b/src/output/Thread.cxx index 91d7dccd7..19a315328 100644 --- a/src/output/Thread.cxx +++ b/src/output/Thread.cxx @@ -215,8 +215,7 @@ AudioOutputControl::InternalDisable() noexcept if (!really_enabled) return; - if (output->open) - output->Close(false); + InternalClose(false); really_enabled = false; output->Disable(); @@ -243,6 +242,15 @@ AudioOutputControl::InternalOpen(const AudioFormat audio_format, } } +inline void +AudioOutputControl::InternalClose(bool drain) noexcept +{ + if (!IsOpen()) + return; + + output->Close(drain); +} + void AudioOutput::Close(bool drain) noexcept { @@ -299,7 +307,7 @@ try { FormatError(e, "Failed to filter for output \"%s\" [%s]", GetName(), output->plugin.name); - output->Close(false); + InternalClose(false); /* don't automatically reopen this device for 10 seconds */ @@ -347,7 +355,7 @@ AudioOutputControl::PlayChunk() noexcept } if (nbytes == 0) { - output->Close(false); + InternalClose(false); /* don't automatically reopen this device for 10 seconds */ @@ -491,8 +499,7 @@ AudioOutputControl::Task() break; case Command::CLOSE: - if (IsOpen()) - output->Close(false); + InternalClose(false); CommandFinished(); break;