command: add cache-idle property

This commit is contained in:
wm4 2014-07-31 04:25:39 +02:00
parent b4f24544bb
commit c1b64cc693
2 changed files with 20 additions and 3 deletions

View File

@ -806,10 +806,14 @@ Property list
Don't use this when playing DVD or Bluray. Don't use this when playing DVD or Bluray.
``cache-free`` (R) ``cache-free`` (R)
Total free cache size in KB. Total free cache size in KB.
``cache-used`` (R) ``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`` ``paused-for-cache``
Returns ``yes`` when playback is paused because of waiting for the cache. Returns ``yes`` when playback is paused because of waiting for the cache.

View File

@ -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); 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, static int mp_property_paused_for_cache(void *ctx, struct m_property *prop,
int action, void *arg) int action, void *arg)
{ {
@ -2663,6 +2675,7 @@ static const struct m_property mp_properties[] = {
{"cache-free", mp_property_cache_free}, {"cache-free", mp_property_cache_free},
{"cache-used", mp_property_cache_used}, {"cache-used", mp_property_cache_used},
{"cache-size", mp_property_cache_size}, {"cache-size", mp_property_cache_size},
{"cache-idle", mp_property_cache_idle},
{"paused-for-cache", mp_property_paused_for_cache}, {"paused-for-cache", mp_property_paused_for_cache},
{"pts-association-mode", mp_property_generic_option}, {"pts-association-mode", mp_property_generic_option},
{"hr-seek", 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"), "samplerate", "channels", "audio"),
E(MPV_EVENT_METADATA_UPDATE, "metadata"), E(MPV_EVENT_METADATA_UPDATE, "metadata"),
E(MPV_EVENT_CHAPTER_CHANGE, "chapter", "chapter-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 #undef E