From f9a259e5d5a3aa7eb34a7278e549636b5138655d Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 13 Feb 2013 13:22:12 +0100 Subject: mplayer: fix seek display during seeking when playing ordered chapters The seek bar appeared to be "stuck" to the start of the current chapter. This is a regression from 630a2b1. This commit assumed that hrseek_pts would always contain the hrseek target time (when hrseek_active==true). But this is not always the case: when playing timeline stuff (e.g. ordered chapters), hrseek framedropping is abused to handle an obscure corner case, and then hrseek_pts contains something completely unrelated to the current playback time. See the added comment in mplayer.c and commit c1232c9. Fix this by trying something else to get a correct time "during" hr-seeks. mpctx->restart_playback looks ideal, because it's set while audio is being synced / audio buffers being filled, so we know that the audio time is probably bogus while it is set. Let's hope this is correct. --- core/mplayer.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'core') diff --git a/core/mplayer.c b/core/mplayer.c index dbcebf9f4e..048d7ab3e1 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -2872,6 +2872,12 @@ static int seek(MPContext *mpctx, struct seek_params seek, } else mpctx->last_seek_pts = MP_NOPTS_VALUE; + // The hr_seek==false case is for skipping frames with PTS before the + // current timeline chapter start. It's not really known where the demuxer + // level seek will end up, so the hrseek mechanism is abused to skip all + // frames before chapter start by setting hrseek_pts to the chapter start. + // It does nothing when the seek is inside of the current chapter, and + // seeking past the chapter is handled elsewhere. if (hr_seek || mpctx->timeline) { mpctx->hrseek_active = true; mpctx->hrseek_framedrop = true; @@ -2958,15 +2964,15 @@ double get_current_time(struct MPContext *mpctx) return 0; if (demuxer->stream_pts != MP_NOPTS_VALUE) return demuxer->stream_pts; - if (mpctx->hrseek_active) - return mpctx->hrseek_pts; - double apts = playing_audio_pts(mpctx); - if (apts != MP_NOPTS_VALUE) - return apts; - if (mpctx->sh_video) { - double pts = mpctx->video_pts; - if (pts != MP_NOPTS_VALUE) - return pts; + if (!mpctx->restart_playback) { + double apts = playing_audio_pts(mpctx); + if (apts != MP_NOPTS_VALUE) + return apts; + if (mpctx->sh_video) { + double pts = mpctx->video_pts; + if (pts != MP_NOPTS_VALUE) + return pts; + } } if (mpctx->last_seek_pts != MP_NOPTS_VALUE) return mpctx->last_seek_pts; -- cgit v1.2.3