From a6ca1677941b817cce401eb4d75f9c049b789b55 Mon Sep 17 00:00:00 2001 From: Leo Izen Date: Sun, 3 Dec 2017 20:26:42 -0500 Subject: player: add get_play_start_pts Added a get_play_start_pts function to coincide with the already-existing get_play_end_pts. This prevents code duplication and also serves to make it so code that probes the start time (such as get_current_pos_ratio) will work correctly with chapters. Included is a bug fix for misc.c/rel_time_to_abs that makes it work correctly with chapters when --rebase-start-time=no is set. --- player/loadfile.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'player/loadfile.c') diff --git a/player/loadfile.c b/player/loadfile.c index b5c7cae6cb..46f5d4e4f3 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1330,17 +1330,16 @@ reopen_file: goto terminate_playback; } - double startpos = rel_time_to_abs(mpctx, opts->play_start); - if (startpos == MP_NOPTS_VALUE && opts->chapterrange[0] > 0) { - double start = chapter_start_time(mpctx, opts->chapterrange[0] - 1); - if (start != MP_NOPTS_VALUE) - startpos = start; - } - if (startpos != MP_NOPTS_VALUE) { - if (!opts->rebase_start_time) { - startpos += mpctx->demuxer->start_time; + double play_start_pts = get_play_start_pts(mpctx); + if (play_start_pts != MP_NOPTS_VALUE) { + /* + * get_play_start_pts returns rebased values, but + * we want an un rebased value to feed to seeker. + */ + if (!opts->rebase_start_time){ + play_start_pts += mpctx->demuxer->start_time; } - queue_seek(mpctx, MPSEEK_ABSOLUTE, startpos, MPSEEK_DEFAULT, 0); + queue_seek(mpctx, MPSEEK_ABSOLUTE, play_start_pts, MPSEEK_DEFAULT, 0); execute_queued_seek(mpctx); } -- cgit v1.2.3