player: actually let cache readahead after opening demuxer for prefetch

Disabling cache readahead by default until at least 1 track is selected
is mainly for external files and such, where you don't want them to use
up resources until they're actually used.

It doesn't make sense to disable the cache for the demuxer opened for
prefetch. Also, it's fine to let it do that for the main file too (doing
or not doing it is of little consequence). That saves us from having to
distinguish them.
This commit is contained in:
wm4 2017-01-19 08:00:19 +01:00
parent 06c8ec27f6
commit 880bf54d7e
3 changed files with 4 additions and 1 deletions

View File

@ -1305,7 +1305,8 @@ static struct demuxer *open_given_type(struct mpv_global *global,
demux_init_cache(demuxer);
demux_changed(in->d_thread, DEMUX_EVENT_ALL);
demux_update(demuxer);
stream_control(demuxer->stream, STREAM_CTRL_SET_READAHEAD, &(int){false});
stream_control(demuxer->stream, STREAM_CTRL_SET_READAHEAD,
&(int){params ? params->initial_readahead : false});
if (!(params && params->disable_timeline)) {
struct timeline *tl = timeline_load(global, log, demuxer);
if (tl) {

View File

@ -162,6 +162,7 @@ struct demuxer_params {
bool *matroska_was_valid;
struct timeline *timeline;
bool disable_timeline;
bool initial_readahead;
// -- demux_open_url() only
int stream_flags;
bool allow_capture;

View File

@ -798,6 +798,7 @@ static void *open_demux_thread(void *ctx)
.force_format = mpctx->open_format,
.allow_capture = true,
.stream_flags = mpctx->open_url_flags,
.initial_readahead = true,
};
mpctx->open_res_demuxer =
demux_open_url(mpctx->open_url, &p, mpctx->open_cancel, mpctx->global);