diff options
author | wm4 <wm4@nowhere> | 2017-11-24 13:58:57 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-11-24 13:58:57 +0100 |
commit | efbb91999796a33c91761d2c206d0f42beb4954c (patch) | |
tree | 58635fb0959f02cd4d34b9f72c44704e801114e5 /player/osd.c | |
parent | 274cc06aaf7ce764164898b31951c0d03b8c3638 (diff) | |
download | mpv-efbb91999796a33c91761d2c206d0f42beb4954c.tar.bz2 mpv-efbb91999796a33c91761d2c206d0f42beb4954c.tar.xz |
player: minor fix/simplification of OSD time/duration handling
Always display the duration as "unknown" if the duration is known. Also
fix that at least demux_lavf reported unknown duration as 0 (fix by
setting the default to unknown in demux.c).
Remove the dumb _u formatter function, and use a different approach to
avoiding displaying "unknown" as playback time on playback start (set
last_seek_pts for that).
Diffstat (limited to 'player/osd.c')
-rw-r--r-- | player/osd.c | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/player/osd.c b/player/osd.c index a95a6c56b1..70dbd1640a 100644 --- a/player/osd.c +++ b/player/osd.c @@ -57,14 +57,6 @@ static void sadd_hhmmssff(char **buf, double time, bool fractions) talloc_free(s); } -// If time unknown (MP_NOPTS_VALUE), use 0 instead. -static void sadd_hhmmssff_u(char **buf, double time, bool fractions) -{ - if (time == MP_NOPTS_VALUE) - time = 0; - sadd_hhmmssff(buf, time, fractions); -} - static void sadd_percentage(char **buf, int percent) { if (percent >= 0) *buf = talloc_asprintf_append(*buf, " (%d%%)", percent); @@ -207,13 +199,9 @@ static void term_osd_print_status_lazy(struct MPContext *mpctx) saddf(&line, ": "); // Playback position - sadd_hhmmssff_u(&line, get_playback_time(mpctx), mpctx->opts->osd_fractions); - - double len = get_time_length(mpctx); - if (len >= 0) { - saddf(&line, " / "); - sadd_hhmmssff(&line, len, mpctx->opts->osd_fractions); - } + sadd_hhmmssff(&line, get_playback_time(mpctx), mpctx->opts->osd_fractions); + saddf(&line, " / "); + sadd_hhmmssff(&line, get_time_length(mpctx), mpctx->opts->osd_fractions); sadd_percentage(&line, get_percent_pos(mpctx)); @@ -442,15 +430,12 @@ static void sadd_osd_status(char **buffer, struct MPContext *mpctx, int level) *buffer = talloc_strdup_append(*buffer, text); talloc_free(text); } else { - sadd_hhmmssff_u(buffer, get_playback_time(mpctx), fractions); + sadd_hhmmssff(buffer, get_playback_time(mpctx), fractions); #if HAVE_GPL // Potentially GPL due to 8d190244d21a4d40bb9e8f7d51aa09ca1888de09. if (level == 3) { - double len = get_time_length(mpctx); - if (len >= 0) { - saddf(buffer, " / "); - sadd_hhmmssff(buffer, len, fractions); - } + saddf(buffer, " / "); + sadd_hhmmssff(buffer, get_time_length(mpctx), fractions); sadd_percentage(buffer, get_percent_pos(mpctx)); } #endif |