From 5655038a9510aaf2ae6f5172ba4964c2172d1ee2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 15 Jan 2014 22:24:56 +0100 Subject: [PATCH] command: if playback position is unknown, make percent-pos unavailable Before that, it just returned -1. The print case is inconsistent with that, but I'll leave it for now, because it's consistent with status line / show_progress behavior. --- player/command.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/player/command.c b/player/command.c index 6ee50dea87..9761c33176 100644 --- a/player/command.c +++ b/player/command.c @@ -353,13 +353,18 @@ static int mp_property_percent_pos(m_option_t *prop, int action, return M_PROPERTY_UNAVAILABLE; switch (action) { - case M_PROPERTY_SET: ; + case M_PROPERTY_SET: { double pos = *(double *)arg; queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, 0); return M_PROPERTY_OK; - case M_PROPERTY_GET: - *(double *)arg = get_current_pos_ratio(mpctx, false) * 100.0; + } + case M_PROPERTY_GET: { + double pos = get_current_pos_ratio(mpctx, false) * 100.0; + if (pos < 0) + return M_PROPERTY_UNAVAILABLE; + *(double *)arg = pos; return M_PROPERTY_OK; + } case M_PROPERTY_PRINT: *(char **)arg = talloc_asprintf(NULL, "%d", get_percent_pos(mpctx)); return M_PROPERTY_OK;