From 6b9aee20bd02b572faac95ffab82214076a6fa7f Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 29 Sep 2014 17:55:40 +0200 Subject: 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). --- stream/cache_file.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'stream') 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) { -- cgit v1.2.3