player: do not update OSD all the time when paused

Normally, OSD is updated every time the playloop is run. This has to be
done, because the OSD may implicitly reference various properties,
without knowing whether they really need to be updated or not. (There's
a property update mechanism, but it's mostly unavailable, because OSD is
special-cased and can not use the client API mechanism properly.)

Normally, these updates are no problem, because the OSD is only actually
printed when the OSD text actually changes.

But commit d23ffd24 added a rate-limiting mechanism, which tries to
limit OSD updates at most every 50ms (or the next video frame). Since it
can't know in advance whether the OSD is going to change or not, this
simply waked up the player every 50ms.

Change this so that the player is updated only as part of general
updates determined through mp_notify(). (This function also notifies the
client API of changed properties.) The desired result is that the player
will not wake up at all in normal idle mode, but still update properties
that can change when paused, such as the cache.

This is mostly a cosmetic change (in the sense of making runtime
behavior just slightly better). It has the slightly more negative
consequence that properties which update implicitly (such as "clock")
will not update periodically anymore.
This commit is contained in:
wm4 2016-06-11 18:40:08 +02:00
parent 9fcc517cee
commit bb9aad097a
3 changed files with 9 additions and 1 deletions

View File

@ -5397,6 +5397,9 @@ void handle_command_updates(struct MPContext *mpctx)
void mp_notify(struct MPContext *mpctx, int event, void *arg)
{
// The OSD can implicitly reference some properties.
mpctx->osd_idle_update = true;
command_event(mpctx, event, arg);
mp_client_broadcast_event(mpctx, event, arg);

View File

@ -243,7 +243,7 @@ typedef struct MPContext {
double osd_msg_visible;
double osd_msg_next_duration;
double osd_last_update;
bool osd_force_update;
bool osd_force_update, osd_idle_update;
char *osd_msg_text;
bool osd_show_pos;
struct osd_progbar_state osd_progbar;

View File

@ -492,6 +492,10 @@ void update_osd_msg(struct MPContext *mpctx)
double now = mp_time_sec();
if (!mpctx->osd_force_update) {
// Assume nothing is going on at all.
if (!mpctx->osd_idle_update)
return;
double delay = 0.050; // update the OSD at most this often
double diff = now - mpctx->osd_last_update;
if (diff < delay) {
@ -500,6 +504,7 @@ void update_osd_msg(struct MPContext *mpctx)
}
}
mpctx->osd_force_update = false;
mpctx->osd_idle_update = false;
mpctx->osd_last_update = now;
if (mpctx->osd_visible) {