diff options
author | wm4 <wm4@mplayer2.org> | 2011-10-28 20:21:59 +0200 |
---|---|---|
committer | wm4 <wm4@mplayer2.org> | 2012-07-28 20:56:53 +0200 |
commit | 2b5fd80253d357deff6b14ca6777fd08d6fef041 (patch) | |
tree | a58ec47e05b39f9ee0160e9367b329cd95bf3027 /m_property.c | |
parent | 16145ff43fd92947cb8fe301ebce46e7be52a9fb (diff) | |
download | mpv-2b5fd80253d357deff6b14ca6777fd08d6fef041.tar.bz2 mpv-2b5fd80253d357deff6b14ca6777fd08d6fef041.tar.xz |
core: change format of time properties to match the OSD time format
Time property values converted to strings via M_PROPERTY_PRINT resulted in
a string different to what the OSD displays (if the OSD level is >= 2).
Change it to match the OSD.
Diffstat (limited to 'm_property.c')
-rw-r--r-- | m_property.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/m_property.c b/m_property.c index bbc11defa0..762ad73b7d 100644 --- a/m_property.c +++ b/m_property.c @@ -381,6 +381,16 @@ int m_property_double_ro(const m_option_t *prop, int action, return M_PROPERTY_NOT_IMPLEMENTED; } +static char *format_time(double time) +{ + int h, m, s = time; + h = s / 3600; + s -= h * 3600; + m = s / 60; + s -= m * 60; + return talloc_asprintf(NULL, "%02d:%02d:%02d", h, m, s); +} + int m_property_time_ro(const m_option_t *prop, int action, void *arg, double var) { @@ -389,17 +399,7 @@ int m_property_time_ro(const m_option_t *prop, int action, if (!arg) return M_PROPERTY_ERROR; else { - int h, m, s = var; - h = s / 3600; - s -= h * 3600; - m = s / 60; - s -= m * 60; - if (h > 0) - *(char **)arg = talloc_asprintf(NULL, "%d:%02d:%02d", h, m, s); - else if (m > 0) - *(char **)arg = talloc_asprintf(NULL, "%d:%02d", m, s); - else - *(char **)arg = talloc_asprintf(NULL, "%d", s); + *(char **)arg = format_time(var); return M_PROPERTY_OK; } } |