summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-12-01 23:28:58 +0100
committerwm4 <wm4@nowhere>2012-12-03 21:08:51 +0100
commit6294c785490be5fc31d29758ca592510fd161371 (patch)
treea03c9135534f28cf7e9a62abcde87c65eb54eeaa /core
parent2d58234c86e59298de52fec12d1eb59086d68763 (diff)
downloadmpv-6294c785490be5fc31d29758ca592510fd161371.tar.bz2
mpv-6294c785490be5fc31d29758ca592510fd161371.tar.xz
cache: simplify further
This commit is separate from the previous one to separate our own changes from changes merged from mplayer2 (as far as that was possible). Make it easier for stream implementations to request being cached. Set a default cache size in stream.c, and remove them from various stream implementations. Only MS streaming support sets a meaningful cache size. Make querying cache size saner. This reduces the amount of #ifdefs needed.
Diffstat (limited to 'core')
-rw-r--r--core/mplayer.c25
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;