aboutsummaryrefslogtreecommitdiffstats
path: root/src/player
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-10-27 23:28:13 +0100
committerMax Kellermann <max@duempel.org>2015-10-27 23:28:13 +0100
commit166b490eed88f6a15399eb8108082be059422488 (patch)
tree615a26211d6bcd34f3fcc28d78c46d6d73cdd71f /src/player
parentefd871ad2f0b8eb776d973ca09b3c239c7502b01 (diff)
downloadmpd-166b490eed88f6a15399eb8108082be059422488.tar.gz
mpd-166b490eed88f6a15399eb8108082be059422488.tar.xz
mpd-166b490eed88f6a15399eb8108082be059422488.zip
player/Thread: move code to ForwardDecoderError()
Diffstat (limited to 'src/player')
-rw-r--r--src/player/Thread.cxx28
1 files changed, 22 insertions, 6 deletions
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
@@ -240,6 +240,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
* initialized yet, i.e. there is no audio_format information
@@ -345,6 +353,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()
{
assert(queued || pc.command == PlayerCommand::SEEK);
@@ -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;