From 57506b27ed0d567c11bd932cf758318fb3b2079c Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 29 Mar 2016 11:29:52 +0200 Subject: cache: use a single STREAM_CTRL for various cache info Instead of having a separate for each, which also requires separate additional caching in the demuxer. (The demuxer adds an indirection, since STREAM_CTRLs are not thread-safe.) Since this includes the cache speed, this should fix #3003. --- player/misc.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'player/misc.c') diff --git a/player/misc.c b/player/misc.c index d68ad1db3e..f14f5a43e3 100644 --- a/player/misc.c +++ b/player/misc.c @@ -95,23 +95,20 @@ double get_play_end_pts(struct MPContext *mpctx) float mp_get_cache_percent(struct MPContext *mpctx) { - if (mpctx->demuxer) { - int64_t size = -1; - int64_t fill = -1; - demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_SIZE, &size); - demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_FILL, &fill); - if (size > 0 && fill >= 0) - return fill / (size / 100.0); - } + struct stream_cache_info info = {0}; + if (mpctx->demuxer) + demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_INFO, &info); + if (info.size > 0 && info.fill >= 0) + return info.fill / (info.size / 100.0); return -1; } bool mp_get_cache_idle(struct MPContext *mpctx) { - int idle = 0; + struct stream_cache_info info = {0}; if (mpctx->demuxer) - demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_IDLE, &idle); - return idle; + demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_INFO, &info); + return info.idle; } void update_vo_playback_state(struct MPContext *mpctx) -- cgit v1.2.3