player: allow redrawing screen during seeks

If seeks take very long, it's better not to freeze up the display.

(This doesn't handle the case when decoding video frames is extremely
slow; just if hr-seek is used, or the demuxer is threaded and blocks on
network I/O.)
This commit is contained in:
wm4 2014-08-03 19:09:22 +02:00
parent 27301ee691
commit 575314eafa
1 changed files with 12 additions and 6 deletions

View File

@ -503,16 +503,23 @@ bool mp_seek_chapter(struct MPContext *mpctx, int chapter)
return true;
}
static bool handle_osd_redraw(struct MPContext *mpctx)
static void handle_osd_redraw(struct MPContext *mpctx)
{
if (!mpctx->video_out || !mpctx->video_out->config_ok)
return false;
return;
// If we're playing normally, let OSD be redrawn naturally as part of
// video display.
if (mpctx->sleeptime < 0.1 && mpctx->video_status == STATUS_PLAYING)
return;
// Don't redraw immediately during a seek (makes it significantly slower).
if (mp_time_sec() - mpctx->start_timestamp < 0.1)
return;
bool want_redraw = vo_get_want_redraw(mpctx->video_out) |
osd_query_and_reset_want_redraw(mpctx->osd);
if (!want_redraw)
return false;
return;
vo_redraw(mpctx->video_out);
return true;
mpctx->sleeptime = 0;
}
static void handle_pause_on_low_cache(struct MPContext *mpctx)
@ -936,8 +943,7 @@ void run_playloop(struct MPContext *mpctx)
if (mpctx->stop_play)
mpctx->sleeptime = 0;
if (mpctx->sleeptime > 0 && handle_osd_redraw(mpctx))
mpctx->sleeptime = 0;
handle_osd_redraw(mpctx);
if (mpctx->sleeptime > 0) {
MP_STATS(mpctx, "start sleep");