From d4680aaecdc8711a878d973c74e223d49cdf9da3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 28 Jun 2013 22:28:21 +0200 Subject: command: make raw percent-pos property return fractions percent-pos was an integer (0-100). Sometimes higher precision is wanted, but the property is this way because fractional parts would look silly with normal OSD usage. As a compromise, make percent-pos double (i.e. includes fractional parts), but print it as integer. So ${percent-pos} is like an integer, but not ${=percent-pos}. --- core/command.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'core/command.c') diff --git a/core/command.c b/core/command.c index 5a617c20f5..828bf21a08 100644 --- a/core/command.c +++ b/core/command.c @@ -322,11 +322,14 @@ static int mp_property_percent_pos(m_option_t *prop, int action, switch (action) { case M_PROPERTY_SET: ; - int pos = *(int *)arg; + double pos = *(double *)arg; queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, 0); return M_PROPERTY_OK; case M_PROPERTY_GET: - *(int *)arg = get_percent_pos(mpctx); + *(double *)arg = get_current_pos_ratio(mpctx, false) * 100.0; + return M_PROPERTY_OK; + case M_PROPERTY_PRINT: + *(char **)arg = talloc_asprintf(NULL, "%d", get_percent_pos(mpctx)); return M_PROPERTY_OK; } return M_PROPERTY_NOT_IMPLEMENTED; @@ -1623,7 +1626,7 @@ static const m_option_t mp_properties[] = { { "length", mp_property_length, CONF_TYPE_TIME, M_OPT_MIN, 0, 0, NULL }, { "avsync", mp_property_avsync, CONF_TYPE_DOUBLE }, - { "percent-pos", mp_property_percent_pos, CONF_TYPE_INT, + { "percent-pos", mp_property_percent_pos, CONF_TYPE_DOUBLE, M_OPT_RANGE, 0, 100, NULL }, { "time-pos", mp_property_time_pos, CONF_TYPE_TIME, M_OPT_MIN, 0, 0, NULL }, -- cgit v1.2.3