summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-29 17:55:40 +0200
committerwm4 <wm4@nowhere>2014-09-29 18:06:44 +0200
commit6b9aee20bd02b572faac95ffab82214076a6fa7f (patch)
treef7adb3253ef875aa577f13221ab12987cbfbd275 /stream
parentb0cb2977edfa0f2f06912bab1c1603c4fbecb71a (diff)
downloadmpv-6b9aee20bd02b572faac95ffab82214076a6fa7f.tar.bz2
mpv-6b9aee20bd02b572faac95ffab82214076a6fa7f.tar.xz
cache_file: refuse to cache unseekable streams
This makes no sense to use with DVD/BD/DVB and some others, and these streams happen to be unseekable. Also, other kinds of unseekable streams (like reading from pipe) should work, but will exhibit sketchy behavior if they need to seek. So just disable it, and leave these problems to the memory cache (cache.c).
Diffstat (limited to 'stream')
-rw-r--r--stream/cache_file.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/stream/cache_file.c b/stream/cache_file.c
index 7ecc0f9858..94b3f4bda2 100644
--- a/stream/cache_file.c
+++ b/stream/cache_file.c
@@ -127,6 +127,11 @@ int stream_file_cache_init(stream_t *cache, stream_t *stream,
if (!opts->file || !opts->file[0] || opts->file_max < 1)
return 0;
+ if (!stream->seekable) {
+ MP_ERR(cache, "can't cache unseekable stream\n");
+ return -1;
+ }
+
bool use_anon_file = strcmp(opts->file, "TMP") == 0;
FILE *file = use_anon_file ? tmpfile() : fopen(opts->file, "wb+");
if (!file) {