diff options
author | wm4 <wm4@nowhere> | 2015-10-16 16:16:10 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-10-16 16:16:10 +0200 |
commit | 8d414e2fe7f79f1bbf9158e8aa034e9ac9cf2222 (patch) | |
tree | 6c5d512e3d79f882e8a5b16599f91b02109cfb6c /player/osd.c | |
parent | 2483dab54d77288db218030910f6b1b4b08292e5 (diff) | |
download | mpv-8d414e2fe7f79f1bbf9158e8aa034e9ac9cf2222.tar.bz2 mpv-8d414e2fe7f79f1bbf9158e8aa034e9ac9cf2222.tar.xz |
command: make time properties unavailable if timestamp is unknown
Let's hope this doesn't confuse client API users too much. It's still
the best solution to get rid of corner cases where it actually return
the wrong timestamp on start, and then suddenly jump.
Diffstat (limited to 'player/osd.c')
-rw-r--r-- | player/osd.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/player/osd.c b/player/osd.c index 8a000862eb..65747bc7cf 100644 --- a/player/osd.c +++ b/player/osd.c @@ -54,6 +54,14 @@ 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); @@ -191,7 +199,7 @@ static void print_status(struct MPContext *mpctx) saddf(&line, ": "); // Playback position - sadd_hhmmssff(&line, get_playback_time(mpctx), mpctx->opts->osd_fractions); + sadd_hhmmssff_u(&line, get_playback_time(mpctx), mpctx->opts->osd_fractions); double len = get_time_length(mpctx); if (len >= 0) { @@ -429,7 +437,7 @@ static void sadd_osd_status(char **buffer, struct MPContext *mpctx, int level) *buffer = talloc_strdup_append(*buffer, text); talloc_free(text); } else { - sadd_hhmmssff(buffer, get_playback_time(mpctx), fractions); + sadd_hhmmssff_u(buffer, get_playback_time(mpctx), fractions); if (level == 3) { double len = get_time_length(mpctx); if (len >= 0) { |