From e7d3e63a3f97b17f20780914b90132b3a1f72909 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Thu, 11 Nov 2010 16:36:09 +0100 Subject: [PATCH] options: move -cache-min and cache-seek-min to option struct --- cfg-common.h | 4 ++-- defaultopts.c | 2 ++ libmpdemux/demuxer.c | 7 ++----- mplayer.c | 6 ++---- options.h | 2 ++ 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cfg-common.h b/cfg-common.h index b9baf8fa3a..03218a3c58 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -389,8 +389,8 @@ const m_option_t common_opts[] = { #ifdef CONFIG_STREAM_CACHE {"cache", &stream_cache_size, CONF_TYPE_INT, CONF_RANGE, 32, 1048576, NULL}, {"nocache", &stream_cache_size, CONF_TYPE_FLAG, 0, 1, 0, NULL}, - {"cache-min", &stream_cache_min_percent, CONF_TYPE_FLOAT, CONF_RANGE, 0, 99, NULL}, - {"cache-seek-min", &stream_cache_seek_min_percent, CONF_TYPE_FLOAT, CONF_RANGE, 0, 99, NULL}, + OPT_FLOATRANGE("cache-min", stream_cache_min_percent, 0, 0, 99), + OPT_FLOATRANGE("cache-seek-min", stream_cache_seek_min_percent, 0, 0, 99), #else {"cache", "MPlayer was compiled without cache2 support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, #endif /* CONFIG_STREAM_CACHE */ diff --git a/defaultopts.c b/defaultopts.c index 0fc79e4df4..cac97c04dd 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -22,6 +22,8 @@ void set_default_mplayer_options(struct MPOpts *opts) .stream_dump_name = "stream.dump", .loop_times = -1, .ordered_chapters = 1, + .stream_cache_min_percent = 20.0, + .stream_cache_seek_min_percent = 50.0, .chapterrange = {-1, -1}, .edition_id = -1, .user_correct_pts = -1, diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index 553da281b0..4d8e64e7c8 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -1068,9 +1068,6 @@ static struct demuxer *demux_open_stream(struct MPOpts *opts, return demuxer; } -extern float stream_cache_min_percent; -extern float stream_cache_seek_min_percent; - demuxer_t *demux_open(struct MPOpts *opts, stream_t *vs, int file_format, int audio_id, int video_id, int dvdsub_id, char *filename) @@ -1117,9 +1114,9 @@ demuxer_t *demux_open(struct MPOpts *opts, stream_t *vs, int file_format, if (!stream_enable_cache (as, opts->audio_stream_cache * 1024, opts->audio_stream_cache * 1024 * - (stream_cache_min_percent / 100.0), + (opts->stream_cache_min_percent / 100.0), opts->audio_stream_cache * 1024 * - (stream_cache_seek_min_percent / 100.0))) { + (opts->stream_cache_seek_min_percent / 100.0))) { free_stream(as); mp_msg(MSGT_DEMUXER, MSGL_ERR, "Can't enable audio stream cache\n"); diff --git a/mplayer.c b/mplayer.c index 1c6bf14226..f74bb24830 100644 --- a/mplayer.c +++ b/mplayer.c @@ -314,10 +314,6 @@ int file_filter=1; // cache2: int stream_cache_size=-1; -#ifdef CONFIG_STREAM_CACHE -float stream_cache_min_percent=20.0; -float stream_cache_seek_min_percent=50.0; -#endif // dump: int stream_dump_type=0; @@ -3757,6 +3753,8 @@ if(mpctx->stream->type==STREAMTYPE_DVDNAV){ goto_enable_cache: if(stream_cache_size>0){ int res; + float stream_cache_min_percent = opts->stream_cache_min_percent; + float stream_cache_seek_min_percent = opts->stream_cache_seek_min_percent; current_module="enable_cache"; res = stream_enable_cache(mpctx->stream,stream_cache_size*1024, stream_cache_size*1024*(stream_cache_min_percent / 100.0), diff --git a/options.h b/options.h index b503175b17..5a403149d7 100644 --- a/options.h +++ b/options.h @@ -33,6 +33,8 @@ typedef struct MPOpts { int capture_dump; int loop_times; int ordered_chapters; + float stream_cache_min_percent; + float stream_cache_seek_min_percent; int chapterrange[2]; int edition_id; int correct_pts; -- 2.11.4.GIT