summaryrefslogtreecommitdiffstats
path: root/player/osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-25 20:25:24 +0200
committerwm4 <wm4@nowhere>2014-09-25 21:32:56 +0200
commitd23ffd243f33ce5d6a5649c7909664b0ae1e858e (patch)
treed237b384b4967682ead44f08d9fd0b7d78632776 /player/osd.c
parent9537e33057d99db65bb12d902d660e3b8c47c5ea (diff)
downloadmpv-d23ffd243f33ce5d6a5649c7909664b0ae1e858e.tar.bz2
mpv-d23ffd243f33ce5d6a5649c7909664b0ae1e858e.tar.xz
player: rate-limit OSD text update
There's no need to update OSD messages and the terminal status if nobody is going to see it. Since the player doesn't block on video display anymore, this update happens to often and probably burns slightly more CPU than necessary. (OSD redrawing is handled separately, so it's just mostly useless text processing and such.) Change it so that it's updated only on every video frame or all 50ms (whatever comes first). For VO OSD, we could in theory try to lock to the OSD redraw heuristic or the display refresh rate, but that's more complicated and doesn't work for the terminal status.
Diffstat (limited to 'player/osd.c')
-rw-r--r--player/osd.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/player/osd.c b/player/osd.c
index 26fee5dec3..757af6a4c6 100644
--- a/player/osd.c
+++ b/player/osd.c
@@ -287,6 +287,7 @@ static mp_osd_msg_t *add_osd_msg(struct MPContext *mpctx, int level, int time)
.msg = "",
.time = time / 1000.0,
});
+ mpctx->osd_force_update = true;
return mpctx->osd_msg_stack;
}
@@ -519,20 +520,23 @@ static void add_seek_osd_messages(struct MPContext *mpctx)
mpctx->add_osd_seek_info = 0;
}
-/**
- * \brief Update the OSD message line.
- *
- * This function displays the current message on the vo OSD or on the term.
- * If the stack is empty and the OSD level is high enough the timer
- * is displayed (only on the vo OSD).
- *
- */
-
+// Update the OSD text (both on VO and terminal status line).
void update_osd_msg(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
struct osd_state *osd = mpctx->osd;
+ if (!mpctx->osd_force_update) {
+ double now = mp_time_sec();
+ double delay = 0.050; // update the OSD at most this often
+ double diff = now - mpctx->osd_last_update;
+ if (diff < delay) {
+ mpctx->sleeptime = MPMIN(mpctx->sleeptime, delay - diff);
+ return;
+ }
+ }
+ mpctx->osd_force_update = false;
+
add_seek_osd_messages(mpctx);
double pos = get_current_pos_ratio(mpctx, false);
update_osd_bar(mpctx, OSD_BAR_SEEK, 0, 1, MPCLAMP(pos, 0, 1));