From 3928ab6f8266ef84cc8310cfc4ee6f8ebb0c21e6 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Tue, 9 Jul 2019 23:12:20 +0200 Subject: [PATCH] [player] Fix for resuming playback after long pause (issue #766) After a long pause the input would close the source (due to INPUT_OPEN_TIMEOUT). This change makes the player restart the input when resuming. --- src/player.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/player.c b/src/player.c index 18424d7b..ff219d1f 100644 --- a/src/player.c +++ b/src/player.c @@ -832,7 +832,7 @@ session_update_read_quality(struct media_quality *quality) } static void -session_resume(void) +session_restart(void) { pb_session.start_ts.tv_sec = 0; pb_session.start_ts.tv_nsec = 0; @@ -1658,11 +1658,23 @@ pb_abort(void) db_queue_clear(0); } -// Resets session start timestamp and deficits, which is necessary after pb_suspend -static void -pb_resume() +// Restarts the input (in case it was closed during the pause), resets session +// start timestamp and deficits, which is necessary after pb_suspend +static int +pb_resume(void) { - session_resume(); + int ret; + + ret = source_restart(pb_session.playing_now); + if (ret < 0) + { + pb_abort(); + return -1; + } + + session_restart(); + + return 0; } // Temporarily suspends/resets playback, used when input buffer underruns or in @@ -1865,7 +1877,12 @@ playback_start_item(void *arg, int *retval) DPRINTF(E_DBG, L_PLAYER, "Resume playback of '%s' (id=%d, item-id=%d)\n", ps->path, ps->id, ps->item_id); - pb_resume(); + ret = pb_resume(); + if (ret < 0) + { + *retval = -1; + return COMMAND_END; + } } else {