0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

mplayer: switch back to video PTS for reporting playback time

The main problem with video PTS was that it wasn't very useful when
playing audio files with cover art. Using the audio time instead was an
obvious solution. Unfortunately, this leads to "inexact" reporting of
the playback time in paused mode, and audio is always ahead by small,
essentially random amounts of time ahead. This is possibly because the
times reported by AOs are not entirely accurate when paused (see commit
9b3bf76).

Switch back to video PTS, and use a simpler way to deal with the cover
art case: if the video has ended, use the audio PTS.

Also see commit f9a259e (and the commits referenced from there).
This commit is contained in:
wm4 2013-04-04 01:18:19 +02:00
parent f3c26b6ab4
commit 69436967b9
2 changed files with 8 additions and 10 deletions

View File

@ -215,6 +215,8 @@ typedef struct MPContext {
// As video_pts, but is not reset when seeking away. (For the very short // As video_pts, but is not reset when seeking away. (For the very short
// period of time until a new frame is decoded and shown.) // period of time until a new frame is decoded and shown.)
double last_vo_pts; double last_vo_pts;
// Video PTS, or audio PTS if video has ended.
double playback_pts;
float audio_delay; float audio_delay;

View File

@ -2694,6 +2694,7 @@ static void seek_reset(struct MPContext *mpctx, bool reset_ao, bool reset_ac)
mpctx->total_avsync_change = 0; mpctx->total_avsync_change = 0;
mpctx->drop_frame_cnt = 0; mpctx->drop_frame_cnt = 0;
mpctx->dropped_frames = 0; mpctx->dropped_frames = 0;
mpctx->playback_pts = MP_NOPTS_VALUE;
#ifdef CONFIG_ENCODING #ifdef CONFIG_ENCODING
encode_lavc_discontinuity(mpctx->encode_lavc_ctx); encode_lavc_discontinuity(mpctx->encode_lavc_ctx);
@ -2960,16 +2961,8 @@ double get_current_time(struct MPContext *mpctx)
return 0; return 0;
if (demuxer->stream_pts != MP_NOPTS_VALUE) if (demuxer->stream_pts != MP_NOPTS_VALUE)
return demuxer->stream_pts; return demuxer->stream_pts;
if (!mpctx->restart_playback) { if (mpctx->playback_pts != MP_NOPTS_VALUE)
double apts = playing_audio_pts(mpctx); return mpctx->playback_pts;
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) if (mpctx->last_seek_pts != MP_NOPTS_VALUE)
return mpctx->last_seek_pts; return mpctx->last_seek_pts;
return 0; return 0;
@ -3311,6 +3304,7 @@ static void run_playloop(struct MPContext *mpctx)
struct sh_video *sh_video = mpctx->sh_video; struct sh_video *sh_video = mpctx->sh_video;
mpctx->video_pts = sh_video->pts; mpctx->video_pts = sh_video->pts;
mpctx->last_vo_pts = mpctx->video_pts; mpctx->last_vo_pts = mpctx->video_pts;
mpctx->playback_pts = mpctx->video_pts;
update_subtitles(mpctx, sh_video->pts); update_subtitles(mpctx, sh_video->pts);
update_osd_msg(mpctx); update_osd_msg(mpctx);
draw_osd(mpctx); draw_osd(mpctx);
@ -3392,6 +3386,7 @@ static void run_playloop(struct MPContext *mpctx)
a_pos = (written_audio_pts(mpctx) - a_pos = (written_audio_pts(mpctx) -
mpctx->opts.playback_speed * buffered_audio); mpctx->opts.playback_speed * buffered_audio);
} }
mpctx->playback_pts = a_pos;
print_status(mpctx); print_status(mpctx);
if (!mpctx->sh_video) if (!mpctx->sh_video)
@ -4104,6 +4099,7 @@ goto_enable_cache: ;
mpctx->video_pts = 0; mpctx->video_pts = 0;
mpctx->last_vo_pts = MP_NOPTS_VALUE; mpctx->last_vo_pts = MP_NOPTS_VALUE;
mpctx->last_seek_pts = 0; mpctx->last_seek_pts = 0;
mpctx->playback_pts = MP_NOPTS_VALUE;
mpctx->hrseek_active = false; mpctx->hrseek_active = false;
mpctx->hrseek_framedrop = false; mpctx->hrseek_framedrop = false;
mpctx->step_frames = 0; mpctx->step_frames = 0;