summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-03-20 19:48:55 +0100
committerwm4 <wm4@nowhere>2016-03-20 19:51:22 +0100
commit5f1ff78516bb5aaf6c38a5df55959e1165c059ee (patch)
tree129f6bbb1984c2533a207e0dcf3275eb02892575 /player
parentb9c48ca8f33e63549f51edb08bd50cc6cc8badbb (diff)
downloadmpv-5f1ff78516bb5aaf6c38a5df55959e1165c059ee.tar.bz2
mpv-5f1ff78516bb5aaf6c38a5df55959e1165c059ee.tar.xz
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.
Diffstat (limited to 'player')
-rw-r--r--player/command.c18
1 files changed, 17 insertions, 1 deletions
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"),
};