From 9662e3e50922d2cef486a657655bdc5c8786d033 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 16 Dec 2013 20:12:53 +0100 Subject: command: mess with previous commit Nothing actually used the returned length. Since the remaining time can easily become 0 or negative (e.g. incorrectly estimated file duration), the time_remaining function still needs 2 return values, though. --- mpvcore/player/command.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/mpvcore/player/command.c b/mpvcore/player/command.c index 1b8ae9c95b..e36675bf05 100644 --- a/mpvcore/player/command.c +++ b/mpvcore/player/command.c @@ -382,22 +382,22 @@ static int mp_property_time_pos(m_option_t *prop, int action, return property_time(prop, action, arg, get_current_time(mpctx)); } -static double time_remaining(MPContext *mpctx, double *len) +static bool time_remaining(MPContext *mpctx, double *remaining) { - *len = get_time_length(mpctx); + double len = get_time_length(mpctx); double pos = get_current_time(mpctx); double start = get_start_time(mpctx); - return *len - (pos - start); + *remaining = len - (pos - start); + + return !!(int)len; } static int mp_property_remaining(m_option_t *prop, int action, void *arg, MPContext *mpctx) { - double len; - double remaining = time_remaining(mpctx, &len); - - if (!(int)len) + double remaining; + if (!time_remaining(mpctx, &remaining)) return M_PROPERTY_UNAVAILABLE; return property_time(prop, action, arg, remaining); @@ -406,10 +406,8 @@ static int mp_property_remaining(m_option_t *prop, int action, static int mp_property_playtime_remaining(m_option_t *prop, int action, void *arg, MPContext *mpctx) { - double len; - double remaining = time_remaining(mpctx, &len); - - if (!(int)len) + double remaining; + if (!time_remaining(mpctx, &remaining)) return M_PROPERTY_UNAVAILABLE; double speed = mpctx->opts->playback_speed; -- cgit v1.2.3