diff options
-rw-r--r-- | DOCS/man/en/input.rst | 1 | ||||
-rw-r--r-- | core/command.c | 10 | ||||
-rw-r--r-- | core/mp_core.h | 1 | ||||
-rw-r--r-- | core/mplayer.c | 12 |
4 files changed, 18 insertions, 6 deletions
diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst index 6b61578a1a..8a9b4f0e42 100644 --- a/DOCS/man/en/input.rst +++ b/DOCS/man/en/input.rst @@ -278,6 +278,7 @@ angle x current DVD angle metadata metadata key/value pairs metadata/<key> value of metadata entry <key> pause x pause status (bool) +cache network cache fill state (0-100) pts-association-mode x see ``--pts-association-mode`` hr-seek x see ``--hr-seek`` volume x current volume (0-100) diff --git a/core/command.c b/core/command.c index 6baa6f92e5..50fe09c555 100644 --- a/core/command.c +++ b/core/command.c @@ -532,6 +532,15 @@ static int mp_property_pause(m_option_t *prop, int action, void *arg, return M_PROPERTY_NOT_IMPLEMENTED; } +static int mp_property_cache(m_option_t *prop, int action, void *arg, + void *ctx) +{ + MPContext *mpctx = ctx; + int cache = mp_get_cache_percent(mpctx); + if (cache < 0) + return M_PROPERTY_UNAVAILABLE; + return m_property_int_ro(prop, action, arg, cache); +} /// Volume (RW) static int mp_property_volume(m_option_t *prop, int action, void *arg, @@ -1344,6 +1353,7 @@ static const m_option_t mp_properties[] = { 0, 0, 0, NULL }, { "pause", mp_property_pause, CONF_TYPE_FLAG, M_OPT_RANGE, 0, 1, NULL }, + { "cache", mp_property_cache, CONF_TYPE_INT }, M_OPTION_PROPERTY("pts-association-mode"), M_OPTION_PROPERTY("hr-seek"), diff --git a/core/mp_core.h b/core/mp_core.h index 37045aeddb..97aeb0d00e 100644 --- a/core/mp_core.h +++ b/core/mp_core.h @@ -292,6 +292,7 @@ struct track *mp_track_by_tid(struct MPContext *mpctx, enum stream_type type, int tid); bool mp_remove_track(struct MPContext *mpctx, struct track *track); struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction); +int mp_get_cache_percent(struct MPContext *mpctx); // timeline/tl_matroska.c void build_ordered_chapter_timeline(struct MPContext *mpctx); diff --git a/core/mplayer.c b/core/mplayer.c index e873410aa5..67b380bcf7 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -1017,7 +1017,7 @@ void init_vo_spudec(struct MPContext *mpctx) } } -static int get_cache_percent(struct MPContext *mpctx) +int mp_get_cache_percent(struct MPContext *mpctx) { if (mpctx->stream) { int64_t size = -1; @@ -1030,7 +1030,7 @@ static int get_cache_percent(struct MPContext *mpctx) return -1; } -static bool get_cache_idle(struct MPContext *mpctx) +static bool mp_get_cache_idle(struct MPContext *mpctx) { int idle = 0; if (mpctx->stream) @@ -1158,7 +1158,7 @@ static void print_status(struct MPContext *mpctx) saddf(&line, " D: %d", drop_frame_cnt); } - int cache = get_cache_percent(mpctx); + int cache = mp_get_cache_percent(mpctx); if (cache >= 0) saddf(&line, " C: %d%%", cache); @@ -3117,8 +3117,8 @@ static void update_avsync(struct MPContext *mpctx) static void handle_pause_on_low_cache(struct MPContext *mpctx) { struct MPOpts *opts = &mpctx->opts; - int cache = get_cache_percent(mpctx); - bool idle = get_cache_idle(mpctx); + int cache = mp_get_cache_percent(mpctx); + bool idle = mp_get_cache_idle(mpctx); if (mpctx->paused && mpctx->paused_for_cache) { if (cache < 0 || cache >= opts->stream_cache_min_percent || idle) unpause_player(mpctx); @@ -3386,7 +3386,7 @@ static void run_playloop(struct MPContext *mpctx) update_osd_msg(mpctx); // The cache status is part of the status line. Possibly update it. - if (mpctx->paused && get_cache_percent(mpctx) >= 0) + if (mpctx->paused && mp_get_cache_percent(mpctx) >= 0) print_status(mpctx); if (!video_left && (!mpctx->paused || was_restart)) { |