options: introduce --cache=yes choice

I think this is what I alwass missed ever since I found the MPlayer
cache options: a way to enable the cache on local files with the default
settings, whatever they are.
This commit is contained in:
wm4 2015-03-12 23:51:41 +01:00
parent 1eeeab2e14
commit 9b77666783
3 changed files with 8 additions and 3 deletions

View File

@ -3060,11 +3060,13 @@ TV
Cache
-----
``--cache=<kBytes|no|auto>``
``--cache=<kBytes|yes|no|auto>``
Set the size of the cache in kilobytes, disable it with ``no``, or
automatically enable it if needed with ``auto`` (default: ``auto``).
With ``auto``, the cache will usually be enabled for network streams,
using the size set by ``--cache-default``.
using the size set by ``--cache-default``. With ``yes``, the cache will
always be enabled with the size set by ``--cache-default`` (unless the
stream can not be cached, or ``--cache-default`` disables caching).
May be useful when playing files from slow media, but can also have
negative effects, especially with file formats that require a lot of

View File

@ -141,7 +141,8 @@ const m_option_t mp_opts[] = {
OPT_CHOICE_OR_INT("cache", stream_cache.size, 0, 32, 0x7fffffff,
({"no", 0},
{"auto", -1})),
{"auto", -1},
{"yes", -2})),
OPT_CHOICE_OR_INT("cache-default", stream_cache.def_size, 0, 32, 0x7fffffff,
({"no", 0})),
OPT_INTRANGE("cache-initial", stream_cache.initial, 0, 0, 0x7fffffff),

View File

@ -752,6 +752,8 @@ static struct mp_cache_opts check_cache_opts(stream_t *stream,
struct mp_cache_opts use_opts = *opts;
if (use_opts.size == -1)
use_opts.size = stream->streaming ? use_opts.def_size : 0;
if (use_opts.size == -2)
use_opts.size = use_opts.def_size;
if (stream->mode != STREAM_READ || !stream->allow_caching || use_opts.size < 1)
use_opts.size = 0;