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.
This commit is contained in:
wm4 2014-01-15 22:24:56 +01:00
parent 80c11eba66
commit 5655038a95
1 changed files with 8 additions and 3 deletions

View File

@ -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;