summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-31 04:25:39 +0200
committerwm4 <wm4@nowhere>2014-07-31 04:25:39 +0200
commitc1b64cc6937327ab12fcd128bcc6b64d43572c8a (patch)
tree69b156c472440073e35701878fafa32c45f92367
parentb4f24544bbfdd2bec765db08f5d745fadeb4d111 (diff)
downloadmpv-c1b64cc6937327ab12fcd128bcc6b64d43572c8a.tar.bz2
mpv-c1b64cc6937327ab12fcd128bcc6b64d43572c8a.tar.xz
command: add cache-idle property
-rw-r--r--DOCS/man/input.rst8
-rw-r--r--player/command.c15
2 files changed, 20 insertions, 3 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index cc92eaf843..749f615b81 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -806,10 +806,14 @@ Property list
Don't use this when playing DVD or Bluray.
``cache-free`` (R)
- Total free cache size in KB.
+ Total free cache size in KB.
``cache-used`` (R)
- Total used cache size in KB.
+ Total used cache size in KB.
+
+``cache-idle`` (R)
+ Returns ``yes`` if the cache is idle, which means the cache is filled as
+ much as possible, and is currently not reading more data.
``paused-for-cache``
Returns ``yes`` when playback is paused because of waiting for the cache.
diff --git a/player/command.c b/player/command.c
index 27fcadcb29..bd6445e5c7 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1181,6 +1181,18 @@ 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_idle(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ int idle = -1;
+ if (mpctx->demuxer)
+ demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_IDLE, &idle);
+ if (idle < 0)
+ return M_PROPERTY_UNAVAILABLE;
+ return m_property_flag_ro(action, arg, !!idle);
+}
+
static int mp_property_paused_for_cache(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -2663,6 +2675,7 @@ static const struct m_property mp_properties[] = {
{"cache-free", mp_property_cache_free},
{"cache-used", mp_property_cache_used},
{"cache-size", mp_property_cache_size},
+ {"cache-idle", mp_property_cache_idle},
{"paused-for-cache", mp_property_paused_for_cache},
{"pts-association-mode", mp_property_generic_option},
{"hr-seek", mp_property_generic_option},
@@ -2792,7 +2805,7 @@ static const char *const *const mp_event_property_change[] = {
"samplerate", "channels", "audio"),
E(MPV_EVENT_METADATA_UPDATE, "metadata"),
E(MPV_EVENT_CHAPTER_CHANGE, "chapter", "chapter-metadata"),
- E(MP_EVENT_CACHE_UPDATE, "cache", "cache-free", "cache-used"),
+ E(MP_EVENT_CACHE_UPDATE, "cache", "cache-free", "cache-used", "cache-idle"),
};
#undef E