summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-03-12 23:51:41 +0100
committerwm4 <wm4@nowhere>2015-03-12 23:51:41 +0100
commit9b77666783d80fe0c3f6276e07ed97a6706f277f (patch)
treeb8c64ee97596dc92c5c6b28fb294e05a3d6be388
parent1eeeab2e1490d99b41d3585b4082f8bd404a4da6 (diff)
downloadmpv-9b77666783d80fe0c3f6276e07ed97a6706f277f.tar.bz2
mpv-9b77666783d80fe0c3f6276e07ed97a6706f277f.tar.xz
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.
-rw-r--r--DOCS/man/options.rst6
-rw-r--r--options/options.c3
-rw-r--r--stream/stream.c2
3 files changed, 8 insertions, 3 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 534a2b47c4..c1c85ffe75 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -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
diff --git a/options/options.c b/options/options.c
index 737d2e5814..cc3a211923 100644
--- a/options/options.c
+++ b/options/options.c
@@ -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),
diff --git a/stream/stream.c b/stream/stream.c
index 825d7a1292..105d56e439 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -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;