From 5f1ff78516bb5aaf6c38a5df55959e1165c059ee Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 20 Mar 2016 19:48:55 +0100 Subject: command: add cache-speed property Should reflect I/O speed. This could go into the terminal status line. But I'm not sure how to put it there, since it already uses too much space, so it's not there yet. --- player/command.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'player/command.c') diff --git a/player/command.c b/player/command.c index 068ab7cf5e..9d8528571a 100644 --- a/player/command.c +++ b/player/command.c @@ -1430,6 +1430,21 @@ static int mp_property_cache_free(void *ctx, struct m_property *prop, return property_int_kb_size((size - size_used) / 1024, action, arg); } +static int mp_property_cache_speed(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + if (!mpctx->demuxer) + return M_PROPERTY_UNAVAILABLE; + + double speed = -1; + demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_SPEED, &speed); + if (speed < 0) + return M_PROPERTY_UNAVAILABLE; + + return m_property_double_ro(action, arg, speed); +} + static int mp_property_cache_idle(void *ctx, struct m_property *prop, int action, void *arg) { @@ -3606,6 +3621,7 @@ static const struct m_property mp_properties[] = { {"cache-used", mp_property_cache_used}, {"cache-size", mp_property_cache_size}, {"cache-idle", mp_property_cache_idle}, + {"cache-speed", mp_property_cache_speed}, {"demuxer-cache-duration", mp_property_demuxer_cache_duration}, {"demuxer-cache-time", mp_property_demuxer_cache_time}, {"demuxer-cache-idle", mp_property_demuxer_cache_idle}, @@ -3820,7 +3836,7 @@ static const char *const *const mp_event_property_change[] = { E(MPV_EVENT_CHAPTER_CHANGE, "chapter", "chapter-metadata"), E(MP_EVENT_CACHE_UPDATE, "cache", "cache-free", "cache-used", "cache-idle", "demuxer-cache-duration", "demuxer-cache-idle", "paused-for-cache", - "demuxer-cache-time", "cache-buffering-state"), + "demuxer-cache-time", "cache-buffering-state", "cache-speed"), E(MP_EVENT_WIN_RESIZE, "window-scale", "osd-width", "osd-height", "osd-par"), E(MP_EVENT_WIN_STATE, "window-minimized", "display-names", "display-fps", "fullscreen"), }; -- cgit v1.2.3