From afef26425d41f34079698891ea71f59212bdef2c Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 3 Mar 2011 12:54:36 +0200 Subject: [PATCH] core: hr-seek: fix soft hang with hrseek past EOF When doing a precise seek video_out->frame_loaded was left to true while frames were being skipped. However vo_get_buffered_frame() always returns success if a frame is already loaded; due to this the EOF detection in update_video() never triggered, and a hr-seek past EOF could cause a soft hang (commands were still processed and it was possible to seek again to exit the loop). This could also happen with Matroska files using ordered chapters if an underlying file was actually shorter than the chapter that was supposed to come from it. Then seeking to a timestamp after the end of the file but before the end of the chapter would trigger the bug. Fix the problem by setting frame_loaded to false when we decide to skip the frame in question. --- libvo/video_out.c | 5 +++++ libvo/video_out.h | 1 + mplayer.c | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libvo/video_out.c b/libvo/video_out.c index 679d111e6f..070a66c679 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -298,6 +298,11 @@ int vo_get_buffered_frame(struct vo *vo, bool eof) return vo->frame_loaded ? 0 : -1; } +void vo_skip_frame(struct vo *vo) +{ + vo->frame_loaded = false; +} + int vo_draw_frame(struct vo *vo, uint8_t *src[]) { assert(!vo->driver->is_new); diff --git a/libvo/video_out.h b/libvo/video_out.h index 5fac7dd02d..5fde30d153 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -283,6 +283,7 @@ void list_video_out(void); int vo_control(struct vo *vo, uint32_t request, void *data); int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts); int vo_get_buffered_frame(struct vo *vo, bool eof); +void vo_skip_frame(struct vo *vo); int vo_draw_frame(struct vo *vo, uint8_t *src[]); int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y); void vo_draw_osd(struct vo *vo, struct osd_state *osd); diff --git a/mplayer.c b/mplayer.c index 743a364065..b9c7dcdac4 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2800,8 +2800,10 @@ static double update_video(struct MPContext *mpctx) if (pts == MP_NOPTS_VALUE) pts = sh_video->last_pts; } - if (mpctx->hrseek_active && pts < mpctx->hrseek_pts - .005) + if (mpctx->hrseek_active && pts < mpctx->hrseek_pts - .005) { + vo_skip_frame(video_out); return 0; + } mpctx->hrseek_active = false; sh_video->pts = pts; if (sh_video->last_pts == MP_NOPTS_VALUE) @@ -3364,7 +3366,6 @@ static void run_playloop(struct MPContext *mpctx) if (!blit_frame || mpctx->hrseek_active) { double frame_time = update_video(mpctx); blit_frame = mpctx->video_out->frame_loaded; - blit_frame &= !mpctx->hrseek_active; mp_dbg(MSGT_AVSYNC, MSGL_DBG2, "*** ftime=%5.3f ***\n", frame_time); if (mpctx->sh_video->vf_initialized < 0) { mp_tmsg(MSGT_CPLAYER, MSGL_FATAL,