From 94bfe833559e5426d2c8b51db321f2b1dd28bd0e Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 20 Sep 2019 17:01:35 +0200 Subject: demux: propagate streaming flag through demux_timeline Before this commit, EDL or CUE files did not properly enable the cache if they were on "slow" media (stream->streaming==true). This happened because the stream is unset for demux_timeline, so the streaming flag could not be queried anymore. Fix this by adding this flag to struct demuxer, and propagate it exactly like the is_network flag. is_network is not used for checking the cache options anymore, and its main function seems to be something else. Normal http streams set the streaming flag already. This should fix #6958. --- demux/demux.c | 7 +++++-- demux/demux.h | 1 + demux/demux_timeline.c | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/demux/demux.c b/demux/demux.c index 4cefd1e0dc..2b1f7d5625 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -2385,8 +2385,7 @@ static void update_opts(struct demux_internal *in) in->max_bytes_bw = opts->max_bytes_bw; int seekable = opts->seekable_cache; - bool is_streaming = in->d_thread->is_network || - (in->d_thread->stream && in->d_thread->stream->streaming); + bool is_streaming = in->d_thread->is_streaming; bool use_cache = is_streaming; if (opts->enable_cache >= 0) use_cache = opts->enable_cache == 1; @@ -2882,6 +2881,7 @@ static void demux_copy(struct demuxer *dst, struct demuxer *src) dst->start_time = src->start_time; dst->duration = src->duration; dst->is_network = src->is_network; + dst->is_streaming = src->is_streaming; dst->priv = src->priv; dst->metadata = mp_tags_dup(dst, src->metadata); } @@ -3132,6 +3132,7 @@ bool demux_is_network_cached(demuxer_t *demuxer) struct parent_stream_info { bool seekable; bool is_network; + bool is_streaming; struct mp_cancel *cancel; char *filename; }; @@ -3162,6 +3163,7 @@ static struct demuxer *open_given_type(struct mpv_global *global, .glog = log, .filename = talloc_strdup(demuxer, sinfo->filename), .is_network = sinfo->is_network, + .is_streaming = sinfo->is_streaming, .access_references = opts->access_references, .events = DEMUX_EVENT_ALL, .duration = -1, @@ -3290,6 +3292,7 @@ static struct demuxer *demux_open(struct stream *stream, struct parent_stream_info sinfo = { .seekable = stream->seekable, .is_network = stream->is_network, + .is_streaming = stream->streaming, .cancel = cancel, .filename = talloc_strdup(NULL, stream->url), }; diff --git a/demux/demux.h b/demux/demux.h index ebebd0853f..6ffd5587ec 100644 --- a/demux/demux.h +++ b/demux/demux.h @@ -193,6 +193,7 @@ typedef struct demuxer { // Typical examples: text subtitles, playlists bool fully_read; bool is_network; // opened directly from a network stream + bool is_streaming; // implies a "slow" input, such as network or FUSE bool access_references; // allow opening other files/URLs // Bitmask of DEMUX_EVENT_* diff --git a/demux/demux_timeline.c b/demux/demux_timeline.c index 8237a69a0f..b18ae70faa 100644 --- a/demux/demux_timeline.c +++ b/demux/demux_timeline.c @@ -591,8 +591,10 @@ static bool add_tl(struct demuxer *demuxer, struct timeline_par *tl) // demux_timeline already does caching, doing it for the sub-demuxers // would be pointless and wasteful. - if (part->source) + if (part->source) { demuxer->is_network |= part->source->is_network; + demuxer->is_streaming |= part->source->is_streaming; + } struct segment *seg = talloc_ptrtype(src, seg); *seg = (struct segment){ @@ -611,6 +613,7 @@ static bool add_tl(struct demuxer *demuxer, struct timeline_par *tl) } demuxer->is_network |= tl->track_layout->is_network; + demuxer->is_streaming |= tl->track_layout->is_streaming; return true; } -- cgit v1.2.3