From 166b490eed88f6a15399eb8108082be059422488 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 27 Oct 2015 23:28:13 +0100 Subject: player/Thread: move code to ForwardDecoderError() --- src/player/Thread.cxx | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 40d73a5f1..a262c073d 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -239,6 +239,14 @@ private: */ bool SeekDecoder(); + /** + * Check if the decoder has reported an error, and forward it + * to PlayerControl::SetError(). + * + * @return false if an error has occurred + */ + bool ForwardDecoderError(); + /** * After the decoder has been started asynchronously, wait for * the "START" command to finish. The decoder may not be @@ -344,6 +352,18 @@ Player::StopDecoder() } } +bool +Player::ForwardDecoderError() +{ + Error error = dc.GetError(); + if (error.IsDefined()) { + pc.SetError(PlayerError::DECODER, std::move(error)); + return false; + } + + return true; +} + bool Player::WaitForDecoder() { @@ -353,10 +373,8 @@ Player::WaitForDecoder() queued = false; pc.Lock(); - Error error = dc.GetError(); - if (error.IsDefined()) { - pc.SetError(PlayerError::DECODER, std::move(error)); + if (!ForwardDecoderError()) { delete pc.next_song; pc.next_song = nullptr; @@ -457,10 +475,8 @@ Player::CheckDecoderStartup() pc.Lock(); - Error error = dc.GetError(); - if (error.IsDefined()) { + if (!ForwardDecoderError()) { /* the decoder failed */ - pc.SetError(PlayerError::DECODER, std::move(error)); pc.Unlock(); return false; -- cgit v1.2.3