summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-28 22:28:21 +0200
committerwm4 <wm4@nowhere>2013-06-29 22:58:13 +0200
commitd4680aaecdc8711a878d973c74e223d49cdf9da3 (patch)
tree476f5f8550fcf505bfe98b7929dd21216d06ca8c /core
parenta6a1f4b8336c0d18c0588922da6b786b6408209f (diff)
downloadmpv-d4680aaecdc8711a878d973c74e223d49cdf9da3.tar.bz2
mpv-d4680aaecdc8711a878d973c74e223d49cdf9da3.tar.xz
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}.
Diffstat (limited to 'core')
-rw-r--r--core/command.c9
1 files changed, 6 insertions, 3 deletions
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 },