player/Thread: make SEEK (partially) non-blocking

When the decoder is still starting up while we handle a SEEK, finish
the "player SEEK" immediately and re-enter the player loop, being able
to handle commands (and even cancel the pending seek).

This is the first part in a series of patches to solve the "blocking
input blocks decoder, blocks player, blocks the main thread" problem.
There are many other blocking code locations left, and the main thread
isn't non-blocking either because it waits for "seeking" to become
false.
This commit is contained in:
Max Kellermann
2017-11-26 11:27:06 +01:00
parent f76262ef79
commit dee378b775
3 changed files with 59 additions and 11 deletions

View File

@@ -256,6 +256,11 @@ PlayerControl::SeekLocked(std::unique_ptr<DetachedSong> song, SongTime t)
assert(next_song == nullptr);
/* the SEEK command is asynchronous; until completion, the
"seeking" flag is set */
while (seeking)
ClientWait();
if (error_type != PlayerError::NONE) {
assert(error);
std::rethrow_exception(error);