osd: fix OSD status symbol display in some cases

The playback status symbol in the OSD status display on video (such as
displayed when seeking or with the show_progress input command)
sometimes kept displaying the last seek, without resetting the symbol.
(For example: disable the OSD, seek, enable the OSD, run show_progress;
but also other cases.)

The main reason for that was the code clearing the OSD bar is also
responsible for clearing the osd_function (which stores the playback
symbol). If no OSD bar was set, the osd_function was never reset.

Fix by always setting the timer for clearing the OSD bar and the
osd_function whenever the osd_function is set. Clearing the OSD bar
when it wasn't set is OK. If the OSD bar is set some time after
osd_function is set, the timer is overwritten - that's a good thing,
as it makes both disappear from the screen at exactly the same time.

Always reset osd_function to 0 and determine the playback status
explicitly from mpctx->paused when displaying the status on screen.
This commit is contained in:
wm4 2012-11-20 17:20:45 +01:00
parent 0e63702ef8
commit 2cdbaaf31c
4 changed files with 22 additions and 14 deletions

View File

@ -1756,23 +1756,21 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
float v = cmd->args[0].v.f;
int abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
int exact = (cmd->nargs > 2) ? cmd->args[2].v.i : 0;
int function;
if (abs == 2) { // Absolute seek to a timestamp in seconds
queue_seek(mpctx, MPSEEK_ABSOLUTE, v, exact);
function = v > get_current_time(mpctx) ? OSD_FFW : OSD_REW;
set_osd_function(mpctx,
v > get_current_time(mpctx) ? OSD_FFW : OSD_REW);
} else if (abs) { /* Absolute seek by percentage */
queue_seek(mpctx, MPSEEK_FACTOR, v / 100.0, exact);
function = OSD_FFW; // Direction isn't set correctly
set_osd_function(mpctx, OSD_FFW); // Direction isn't set correctly
} else {
queue_seek(mpctx, MPSEEK_RELATIVE, v, exact);
function = (v > 0) ? OSD_FFW : OSD_REW;
set_osd_function(mpctx, (v > 0) ? OSD_FFW : OSD_REW);
}
if (bar_osd)
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
if (msg_osd && !auto_osd)
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT;
if (mpctx->add_osd_seek_info)
mpctx->osd_function = function;
break;
}

View File

@ -137,8 +137,8 @@ typedef struct MPContext {
int add_osd_seek_info; // bitfield of enum mp_osd_seek_info
unsigned int osd_visible;
int osd_function;
struct playlist *playlist;
char *filename; // currently playing file
struct mp_resolve_result *resolve_result;

View File

@ -42,4 +42,7 @@ void set_osd_msg(struct MPContext *mpctx, int id, int level, int time, const cha
void set_osd_tmsg(struct MPContext *mpctx, int id, int level, int time, const char* fmt, ...);
void rm_osd_msg(struct MPContext *mpctx, int id);
// osd_function is the symbol appearing in the video status, such as OSD_PLAY
void set_osd_function(struct MPContext *mpctx, int osd_function);
#endif /* MPLAYER_MP_OSD_H */

View File

@ -1335,7 +1335,7 @@ static mp_osd_msg_t *get_osd_msg(struct MPContext *mpctx)
mpctx->osd_visible = 0;
mpctx->osd->progbar_type = -1; // disable
vo_osd_changed(OSDTYPE_PROGBAR);
mpctx->osd_function = mpctx->paused ? OSD_PAUSE : OSD_PLAY;
mpctx->osd_function = 0;
}
}
@ -1403,6 +1403,12 @@ void set_osd_bar(struct MPContext *mpctx, int type, const char *name,
name, ROUND(100 * (val - min) / (max - min)));
}
void set_osd_function(struct MPContext *mpctx, int osd_function)
{
mpctx->osd_function = osd_function;
mpctx->osd_visible = (GetTimerMS() + 1000) | 1;
}
/**
* \brief Display text subtitles on the OSD
*/
@ -1439,7 +1445,10 @@ static void sadd_osd_status(char *buffer, int len, struct MPContext *mpctx,
bool full)
{
bool fractions = mpctx->opts.osd_fractions;
saddf_osd_function_sym(buffer, len, mpctx->osd_function);
int sym = mpctx->osd_function;
if (!sym)
sym = mpctx->paused || mpctx->step_frames ? OSD_PAUSE : OSD_PLAY;
saddf_osd_function_sym(buffer, len, sym);
sadd_hhmmssff(buffer, len, get_current_time(mpctx), fractions);
if (full) {
saddf(buffer, len, " / ");
@ -2537,7 +2546,7 @@ void pause_player(struct MPContext *mpctx)
mpctx->paused = 1;
mpctx->step_frames = 0;
mpctx->time_frame -= get_relative_time(mpctx);
mpctx->osd_function = OSD_PAUSE;
mpctx->osd_function = 0;
if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok)
vo_control(mpctx->video_out, VOCTRL_PAUSE, NULL);
@ -2558,8 +2567,7 @@ void unpause_player(struct MPContext *mpctx)
if (!mpctx->paused)
return;
mpctx->paused = 0;
if (!mpctx->step_frames)
mpctx->osd_function = OSD_PLAY;
mpctx->osd_function = 0;
if (mpctx->ao && mpctx->sh_audio)
ao_resume(mpctx->ao);
@ -3393,7 +3401,7 @@ static void run_playloop(struct MPContext *mpctx)
// handle -sstep
if (step_sec > 0 && !mpctx->paused && !mpctx->restart_playback) {
mpctx->osd_function = OSD_FFW;
set_osd_function(mpctx, OSD_FFW);
queue_seek(mpctx, MPSEEK_RELATIVE, step_sec, 0);
}
@ -4316,7 +4324,6 @@ int main(int argc, char *argv[])
struct MPContext *mpctx = talloc(NULL, MPContext);
*mpctx = (struct MPContext){
.osd_function = OSD_PLAY,
.begin_skip = MP_NOPTS_VALUE,
.file_format = DEMUXER_TYPE_UNKNOWN,
.last_dvb_step = 1,