From f793ad9f3ef36a3c870b989ff6ccd635f4deb1ea Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Fri, 10 May 2019 16:47:18 +0200 Subject: [PATCH] [player] Fix incorrect player state while buffering (partial fix for #738) Player would return PLAYER_PLAYING when resuming playback after a pause, but it should initially return PLAYER_PAUSED because it is still buffering. --- src/player.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/player.c b/src/player.c index e80a0d28..92df56d1 100644 --- a/src/player.c +++ b/src/player.c @@ -714,10 +714,6 @@ session_update_play_start(void) pb_session.playing_now = pb_session.reading_now; else pb_session.playing_now = pb_session.reading_prev; - - // This is a stupid work-around to make sure pos_ms is non-zero, because a - // zero value means that get_status() tells the clients that we are paused. - pb_session.playing_now->pos_ms = pb_session.playing_now->seek_ms + 1; } static void @@ -973,11 +969,11 @@ event_read(int nsamples) } } - // Check if the playback position will be passing the play_start position - if (pb_session.pos < pb_session.playing_now->play_start && pb_session.pos + nsamples >= pb_session.playing_now->play_start) - event_play_start(); - session_update_read(nsamples); + + // Check if the playback position passed the play_start position + if (pb_session.pos - nsamples < pb_session.playing_now->play_start && pb_session.pos >= pb_session.playing_now->play_start) + event_play_start(); } @@ -1705,7 +1701,7 @@ get_status(void *arg, int *retval) break; case PLAY_PLAYING: - if (pb_session.playing_now->pos_ms == 0) + if (pb_session.playing_now->play_start == 0 || pb_session.pos < pb_session.playing_now->play_start) { DPRINTF(E_DBG, L_PLAYER, "Player status: playing (buffering)\n");