command: change "cache-speed" OSD formatting

Also change the property to an int, since using double is questionable
and pointless.
This commit is contained in:
wm4 2016-03-22 22:29:15 +01:00
parent fd3ae6c561
commit ba4569cf70
2 changed files with 11 additions and 6 deletions

View File

@ -1197,8 +1197,8 @@ Property list
``cache-speed`` (R)
Current I/O read speed between the cache and the lower layer (like network).
This is a float (using ``MPV_FORMAT_DOUBLE`` in the client API) and gives
the value bytes per seconds over a 1 second window.
This gives the number bytes per seconds over a 1 second window (using
the type ``MPV_FORMAT_INT64`` for the client API).
``cache-idle`` (R)
Returns ``yes`` if the cache is idle, which means the cache is filled as

View File

@ -1437,12 +1437,17 @@ static int mp_property_cache_speed(void *ctx, struct m_property *prop,
if (!mpctx->demuxer)
return M_PROPERTY_UNAVAILABLE;
double speed = -1;
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_SPEED, &speed);
if (speed < 0)
double f_speed = -1;
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_SPEED, &f_speed);
if (f_speed < 0)
return M_PROPERTY_UNAVAILABLE;
int64_t speed = llrint(f_speed);
return m_property_double_ro(action, arg, speed);
if (action == M_PROPERTY_PRINT) {
*(char **)arg = talloc_strdup_append(format_file_size(speed), "/s");
return M_PROPERTY_OK;
}
return m_property_int64_ro(action, arg, speed);
}
static int mp_property_cache_idle(void *ctx, struct m_property *prop,