From b93e3b2cf6f7e0ae9909f9fab4587e2fde5829c1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Jan 2018 17:15:10 +0100 Subject: [PATCH] output/Thread: move code to method InternalCloseError() --- src/output/Control.hxx | 8 ++++++++ src/output/Thread.cxx | 7 ++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/output/Control.hxx b/src/output/Control.hxx index eea02989a..51e9f5d4e 100644 --- a/src/output/Control.hxx +++ b/src/output/Control.hxx @@ -466,6 +466,14 @@ private: */ void InternalClose(bool drain) noexcept; + /** + * An error has occurred, and this output must be closed. + */ + void InternalCloseError(std::exception_ptr e) noexcept { + Failure(e); + InternalClose(false); + } + /** * Runs inside the OutputThread. * Caller must lock the mutex. diff --git a/src/output/Thread.cxx b/src/output/Thread.cxx index 0ad3800bf..2a355eb11 100644 --- a/src/output/Thread.cxx +++ b/src/output/Thread.cxx @@ -232,8 +232,7 @@ try { } catch (...) { FormatError(std::current_exception(), "Failed to filter for %s", GetLogName()); - Failure(std::current_exception()); - InternalClose(false); + InternalCloseError(std::current_exception()); return false; } @@ -273,9 +272,7 @@ AudioOutputControl::PlayChunk() noexcept } catch (...) { FormatError(std::current_exception(), "Failed to play on %s", GetLogName()); - Failure(std::current_exception()); - - InternalClose(false); + InternalCloseError(std::current_exception()); return false; }