diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2012-08-19 15:31:38 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-09-18 21:07:30 +0200 |
commit | 70e7d63ba011a326f5e03137b8fb45df222c43af (patch) | |
tree | 7537f596d739f09837f43cf7078cd46bda265527 /mplayer.c | |
parent | 1959ba006ce1a4591f3dcd5093901993e3fdda5f (diff) | |
download | mpv-70e7d63ba011a326f5e03137b8fb45df222c43af.tar.bz2 mpv-70e7d63ba011a326f5e03137b8fb45df222c43af.tar.xz |
core, timeline: cache external ordered chapter files too
Previously, Matroska source files other than the initially opened one
were always accessed without caching. Enable cache for extra files
too. A separate cache process/thread is started for each file, which
is less than optimal but probably better than no caching if the user
explicitly enabled cache. This commit only implements caching for
Matroska ordered chapters (not for EDL timeline).
To build the timeline we need to demux the files in the current
directory to look for segments with matching uuid. This first demux is
done with no cache since we don't need to read a lot of the stream. If
the file is recognized as one of the needed sources it's reopened with
cache enabled.
Also move the stream_cache_size global variable to the options struct.
Conflicts:
cfg-mplayer.h
mplayer.c
stream/stream.h
timeline/tl_matroska.c
Diffstat (limited to 'mplayer.c')
-rw-r--r-- | mplayer.c | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -221,9 +221,6 @@ int vobsub_id = -1; static char *spudec_ifo = NULL; int forced_subs_only = 0; -// cache2: -int stream_cache_size = -1; - // A-V sync: static float default_max_pts_correction = -1; float audio_delay = 0; @@ -1252,7 +1249,7 @@ static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame) #ifdef CONFIG_STREAM_CACHE // cache stats - if (stream_cache_size > 0) + if (opts->stream_cache_size > 0) saddf(line, width, " C: %d%%", cache_fill_status(mpctx->stream)); #endif @@ -3286,7 +3283,7 @@ static void run_playloop(struct MPContext *mpctx) #ifdef CONFIG_STREAM_CACHE // The cache status is part of the status line. Possibly update it. - if (mpctx->paused && stream_cache_size > 0) + if (mpctx->paused && opts->stream_cache_size > 0) print_status(mpctx, MP_NOPTS_VALUE, false); #endif @@ -3804,13 +3801,11 @@ static void play_current_file(struct MPContext *mpctx) // CACHE2: initial prefill: 20% later: 5% (should be set by -cacheopts) 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; - res = stream_enable_cache(mpctx->stream, stream_cache_size * 1024ull, - stream_cache_size * 1024ull * (stream_cache_min_percent / 100.0), - stream_cache_size * 1024ull * (stream_cache_seek_min_percent / 100.0)); + if (opts->stream_cache_size > 0) { + int res = stream_enable_cache_percent(mpctx->stream, + opts->stream_cache_size, + opts->stream_cache_min_percent, + opts->stream_cache_seek_min_percent); if (res == 0) if (libmpdemux_was_interrupted(mpctx)) goto terminate_playback; |