diff options
Diffstat (limited to 'core/mplayer.c')
-rw-r--r-- | core/mplayer.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/core/mplayer.c b/core/mplayer.c index cc1749fb6b..e60c7e173c 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -1038,6 +1038,19 @@ void init_vo_spudec(struct MPContext *mpctx) } } +static int get_cache_percent(struct MPContext *mpctx) +{ + if (mpctx->stream) { + int64_t size = -1; + int64_t fill = -1; + stream_control(mpctx->stream, STREAM_CTRL_GET_CACHE_SIZE, &size); + stream_control(mpctx->stream, STREAM_CTRL_GET_CACHE_FILL, &fill); + if (size > 0 && fill >= 0) + return fill / (size / 100); + } + return -1; +} + /** * \brief append a formatted string * \param buf buffer to print into @@ -1181,11 +1194,9 @@ static void print_status(struct MPContext *mpctx) saddf(line, width, " D: %d", drop_frame_cnt); } -#ifdef CONFIG_STREAM_CACHE - // cache stats - if (mpctx->stream->cached) - saddf(line, width, " C: %d%%", cache_fill_status(mpctx->stream)); -#endif + int cache = get_cache_percent(mpctx); + if (cache >= 0) + saddf(line, width, " C: %d%%", cache); // end write_status_line(mpctx, line); @@ -3299,11 +3310,9 @@ static void run_playloop(struct MPContext *mpctx) update_osd_msg(mpctx); -#ifdef CONFIG_STREAM_CACHE // The cache status is part of the status line. Possibly update it. - if (mpctx->paused && mpctx->stream && mpctx->stream->cached) + if (mpctx->paused && get_cache_percent(mpctx) >= 0) print_status(mpctx); -#endif if (!video_left && (!mpctx->paused || was_restart)) { double a_pos = 0; |