summaryrefslogtreecommitdiffstats
path: root/player/misc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-03-29 11:29:52 +0200
committerwm4 <wm4@nowhere>2016-03-29 11:29:52 +0200
commit57506b27ed0d567c11bd932cf758318fb3b2079c (patch)
treef9bfbdf9ca316546f6de72d16b837411cb95e423 /player/misc.c
parente1264d397613b0dac86757d6fd3a4a3494e16868 (diff)
downloadmpv-57506b27ed0d567c11bd932cf758318fb3b2079c.tar.bz2
mpv-57506b27ed0d567c11bd932cf758318fb3b2079c.tar.xz
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.
Diffstat (limited to 'player/misc.c')
-rw-r--r--player/misc.c19
1 files changed, 8 insertions, 11 deletions
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)