osd: properly handle OSD bar timeout

This could just remain stuck on the screen, until the playloop happened
to be run again.
This commit is contained in:
wm4 2014-07-21 19:35:20 +02:00
parent a84517c1d8
commit 17256f13dc
1 changed files with 10 additions and 4 deletions

View File

@ -295,10 +295,15 @@ static mp_osd_msg_t *get_osd_msg(struct MPContext *mpctx)
double now = mp_time_sec(); double now = mp_time_sec();
double diff; double diff;
if (mpctx->osd_visible && now >= mpctx->osd_visible) { if (mpctx->osd_visible) {
mpctx->osd_visible = 0; double sleep = mpctx->osd_visible - now;
mpctx->osd_progbar.type = -1; // disable if (sleep > 0) {
osd_set_progbar(mpctx->osd, &mpctx->osd_progbar); mpctx->sleeptime = MPMIN(mpctx->sleeptime, sleep);
} else {
mpctx->osd_visible = 0;
mpctx->osd_progbar.type = -1; // disable
osd_set_progbar(mpctx->osd, &mpctx->osd_progbar);
}
} }
if (mpctx->osd_function_visible && now >= mpctx->osd_function_visible) { if (mpctx->osd_function_visible && now >= mpctx->osd_function_visible) {
mpctx->osd_function_visible = 0; mpctx->osd_function_visible = 0;
@ -342,6 +347,7 @@ void set_osd_bar(struct MPContext *mpctx, int type, const char* name,
if (mpctx->video_out && opts->term_osd != 1) { if (mpctx->video_out && opts->term_osd != 1) {
mpctx->osd_visible = mp_time_sec() + opts->osd_duration / 1000.0; mpctx->osd_visible = mp_time_sec() + opts->osd_duration / 1000.0;
mpctx->sleeptime = 0;
mpctx->osd_progbar.type = type; mpctx->osd_progbar.type = type;
mpctx->osd_progbar.value = (val - min) / (max - min); mpctx->osd_progbar.value = (val - min) / (max - min);
mpctx->osd_progbar.num_stops = 0; mpctx->osd_progbar.num_stops = 0;