From 175cd3cb570525fd4ed8f6ec66e3a66a461cc896 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 10 Jul 2013 15:03:54 +0200 Subject: options: add --cache-default option Add this option, which lets users set the cache size without forcing it even when playing from the local filesystem. Also document the default value explicitly. The Matroska linked segments case is slightly simplified: they can never come from network (mostly because it'd be insane, and we can't even list files from network sources), so the cache will never be enabled automatically. --- core/mplayer.c | 2 ++ core/options.c | 3 +++ core/options.h | 1 + core/timeline/tl_matroska.c | 4 ++-- 4 files changed, 8 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/mplayer.c b/core/mplayer.c index 79626fdc80..1341a51a1a 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -3896,6 +3896,7 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename, if (!stream) goto err_out; stream_enable_cache_percent(&stream, stream_cache, + opts->stream_cache_def_size, opts->stream_cache_min_percent, opts->stream_cache_seek_min_percent); // deal with broken demuxers: preselect streams @@ -4210,6 +4211,7 @@ static void play_current_file(struct MPContext *mpctx) // CACHE2: initial prefill: 20% later: 5% (should be set by -cacheopts) int res = stream_enable_cache_percent(&mpctx->stream, opts->stream_cache_size, + opts->stream_cache_def_size, opts->stream_cache_min_percent, opts->stream_cache_seek_min_percent); if (res == 0) diff --git a/core/options.c b/core/options.c index b00f79c003..68d4c2ce52 100644 --- a/core/options.c +++ b/core/options.c @@ -331,6 +331,9 @@ const m_option_t mp_opts[] = { ({"no", 0}, {"auto", -1}), OPTDEF_INT(-1)), + OPT_CHOICE_OR_INT("cache-default", stream_cache_def_size, 0, 32, 0x7fffffff, + ({"no", 0}), + OPTDEF_INT(320)), OPT_FLOATRANGE("cache-min", stream_cache_min_percent, 0, 0, 99), OPT_FLOATRANGE("cache-seek-min", stream_cache_seek_min_percent, 0, 0, 99), OPT_CHOICE_OR_INT("cache-pause", stream_cache_pause, 0, diff --git a/core/options.h b/core/options.h index 1eb111e33e..28932693ed 100644 --- a/core/options.h +++ b/core/options.h @@ -92,6 +92,7 @@ typedef struct MPOpts { int load_config; int use_filedir_conf; int stream_cache_size; + int stream_cache_def_size; float stream_cache_min_percent; float stream_cache_seek_min_percent; int stream_cache_pause; diff --git a/core/timeline/tl_matroska.c b/core/timeline/tl_matroska.c index 11fcc67583..098c02fd9f 100644 --- a/core/timeline/tl_matroska.c +++ b/core/timeline/tl_matroska.c @@ -126,8 +126,7 @@ static int enable_cache(struct MPContext *mpctx, struct stream **stream, { struct MPOpts *opts = &mpctx->opts; - if (!(opts->stream_cache_size > 0 || - opts->stream_cache_size < 0 && (*stream)->cache_size)) + if (opts->stream_cache_size <= 0) return 0; char *filename = talloc_strdup(NULL, (*demuxer)->filename); @@ -143,6 +142,7 @@ static int enable_cache(struct MPContext *mpctx, struct stream **stream, stream_enable_cache_percent(stream, opts->stream_cache_size, + opts->stream_cache_def_size, opts->stream_cache_min_percent, opts->stream_cache_seek_min_percent); -- cgit v1.2.3