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:
@@ -54,7 +54,9 @@ enum class PlayerCommand : uint8_t {
|
||||
/**
|
||||
* Seek to a certain position in the specified song. This
|
||||
* command can also be used to change the current song or
|
||||
* start playback.
|
||||
* start playback. It "finishes" immediately, but
|
||||
* PlayerControl::seeking will be set until seeking really
|
||||
* completes (or fails).
|
||||
*/
|
||||
SEEK,
|
||||
|
||||
@@ -176,6 +178,11 @@ struct PlayerControl final : AudioOutputClient {
|
||||
|
||||
ReplayGainMode replay_gain_mode = ReplayGainMode::OFF;
|
||||
|
||||
/**
|
||||
* Is the player currently busy with the SEEK command?
|
||||
*/
|
||||
bool seeking = false;
|
||||
|
||||
/**
|
||||
* If this flag is set, then the player will be auto-paused at
|
||||
* the end of the song, before the next song starts to play.
|
||||
|
Reference in New Issue
Block a user