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).
This commit is contained in:
wm4 2014-09-29 17:55:40 +02:00
parent b0cb2977ed
commit 6b9aee20bd
1 changed files with 5 additions and 0 deletions

View File

@ -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) {