From cfc651a80562c26c8e789af28efb707b47750d03 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Mon, 3 Jun 2024 08:11:33 -0400 Subject: [PATCH] osd: don't use get_percent_pos function Use get_current_pos_ratio instead, and round the value to integer with printf precision specifier. --- player/osd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/player/osd.c b/player/osd.c index d3ab644c77..f218f47ce9 100644 --- a/player/osd.c +++ b/player/osd.c @@ -54,9 +54,9 @@ static void sadd_hhmmssff(char **buf, double time, bool fractions) talloc_free(s); } -static void sadd_percentage(char **buf, int percent) { - if (percent >= 0) - *buf = talloc_asprintf_append(*buf, " (%d%%)", percent); +static void sadd_percentage(char **buf, double ratio) { + if (ratio >= 0) + *buf = talloc_asprintf_append(*buf, " (%.f%%)", ratio * 100); } static char *join_lines(void *ta_ctx, char **parts, int num_parts) @@ -194,7 +194,7 @@ static char *get_term_status_msg(struct MPContext *mpctx) saddf(&line, " / "); sadd_hhmmssff(&line, get_time_length(mpctx), opts->osd_fractions); - sadd_percentage(&line, get_percent_pos(mpctx)); + sadd_percentage(&line, get_current_pos_ratio(mpctx, false)); // other if (opts->playback_speed != 1) @@ -447,7 +447,7 @@ static void sadd_osd_status(char **buffer, struct MPContext *mpctx, int level) if (level == 3) { saddf(buffer, " / "); sadd_hhmmssff(buffer, get_time_length(mpctx), fractions); - sadd_percentage(buffer, get_percent_pos(mpctx)); + sadd_percentage(buffer, get_current_pos_ratio(mpctx, false)); } } }