summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-09-20 18:13:16 +0200
committerwm4 <wm4@nowhere>2019-09-20 18:13:16 +0200
commitc1f1a0845e03885eebe6379b91829a57a14be3c0 (patch)
tree417fdfe6c17b6231c4f2d933213bb0285becbaea
parent94bfe833559e5426d2c8b51db321f2b1dd28bd0e (diff)
downloadmpv-c1f1a0845e03885eebe6379b91829a57a14be3c0.tar.bz2
mpv-c1f1a0845e03885eebe6379b91829a57a14be3c0.tar.xz
loadfile: restore playlist prefetching
With the stream cache gone, this function had almost no use anymore (other than opening the stream). Improve this by triggering demuxer cache readahead. This enables all streams. At this point we can't know yet what streams the user's options would select (at least not without great additional effort). Generally this is what you want, and the stream cache would have read the same amount of data. In addition, this will work much better for files that e.g. need to seek to the end when opening (typically mp4, and mkv files produced by newer mkvmerge versions). Remove the deselection call from add_stream_track(). This should be fine, as streams normally start out as deselected anyway. In the prefetch case, some code in play_current_file() actually deselects it. Streams that appear during demuxing are disabled by default, so this doesn't break this logic either. Fixes: #6753
-rw-r--r--player/loadfile.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index ec84e8a003..a72e34565a 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -422,8 +422,6 @@ static struct track *add_stream_track(struct MPContext *mpctx,
};
MP_TARRAY_APPEND(mpctx, mpctx->tracks, mpctx->num_tracks, track);
- demuxer_select_track(track->demuxer, stream, MP_NOPTS_VALUE, false);
-
mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL);
return track;
@@ -974,11 +972,20 @@ static void *open_demux_thread(void *ctx)
.stream_record = true,
.is_top_level = true,
};
- mpctx->open_res_demuxer =
+ struct demuxer *demux =
demux_open_url(mpctx->open_url, &p, mpctx->open_cancel, mpctx->global);
+ mpctx->open_res_demuxer = demux;
- if (mpctx->open_res_demuxer) {
+ if (demux) {
MP_VERBOSE(mpctx, "Opening done: %s\n", mpctx->open_url);
+
+ int num_streams = demux_get_num_stream(demux);
+ for (int n = 0; n < num_streams; n++) {
+ struct sh_stream *sh = demux_get_stream(demux, n);
+ demuxer_select_track(demux, sh, MP_NOPTS_VALUE, true);
+ }
+
+ demux_start_prefetch(demux);
} else {
MP_VERBOSE(mpctx, "Opening failed or was aborted: %s\n", mpctx->open_url);