diff options
author | Max Kellermann <max@duempel.org> | 2015-11-05 00:34:42 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-11-05 00:39:30 +0100 |
commit | 30cad0c5f1db1363dd2225598e2e2b4237cf537b (patch) | |
tree | 56b4448b6c1410fc6ca68848d481eab2b8127ba6 /src | |
parent | 3a387643b34d11d17c37e83812aedbf5f8171029 (diff) | |
download | mpd-30cad0c5f1db1363dd2225598e2e2b4237cf537b.tar.gz mpd-30cad0c5f1db1363dd2225598e2e2b4237cf537b.tar.xz mpd-30cad0c5f1db1363dd2225598e2e2b4237cf537b.zip |
player/Thread: move code to WaitDecoderStartup()
Diffstat (limited to 'src')
-rw-r--r-- | src/player/Thread.cxx | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 3c315ebcf..7a9715f1b 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -203,6 +203,25 @@ private: bool CheckDecoderStartup(); /** + * Call CheckDecoderStartup() repeatedly until the decoder has + * finished startup. Returns false on decoder error (and + * finishes the #PlayerCommand). + * + * This method does not check for commands. It is only + * allowed to be used while a command is being handled. + */ + bool WaitDecoderStartup() { + while (decoder_starting) { + if (!CheckDecoderStartup()) { + pc.LockCommandFinished(); + return false; + } + } + + return true; + } + + /** * Stop the decoder and clears (and frees) its music pipe. * * Player lock is not held. @@ -570,13 +589,8 @@ Player::SeekDecoder() /* wait for the decoder to complete initialization */ - while (decoder_starting) { - if (!CheckDecoderStartup()) { - /* decoder failure */ - pc.LockCommandFinished(); - return false; - } - } + if (!WaitDecoderStartup()) + return false; /* send the SEEK command */ |