From 575314eafa72f7389686bdb85dff4a104a654856 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 3 Aug 2014 19:09:22 +0200 Subject: 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.) --- player/playloop.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/player/playloop.c b/player/playloop.c index 564b4e739c..7d3309a583 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -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"); -- cgit v1.2.3