From 4121016689668921538317449c0ea9063fc086fc Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 26 Aug 2016 12:31:09 +0200 Subject: player: don't directly access demuxer->stream Cleaner and makes it easier to change the underlying stream. mp_property_stream_capture() still directly accesses it directly via demux_run_on_thread(). This is evil, but still somewhat sane and is not getting into the way here. Not sure if I got all field accesses. --- demux/demux.c | 2 ++ demux/demux.h | 1 + player/command.c | 6 ++---- player/loadfile.c | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/demux/demux.c b/demux/demux.c index 69e66990ff..cfea29b978 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -1031,6 +1031,7 @@ static void demux_copy(struct demuxer *dst, struct demuxer *src) dst->ts_resets_possible = src->ts_resets_possible; dst->fully_read = src->fully_read; dst->start_time = src->start_time; + dst->is_network = src->is_network; dst->priv = src->priv; } @@ -1172,6 +1173,7 @@ static struct demuxer *open_given_type(struct mpv_global *global, .log = mp_log_new(demuxer, log, desc->name), .glog = log, .filename = talloc_strdup(demuxer, stream->url), + .is_network = stream->is_network, .events = DEMUX_EVENT_ALL, }; demuxer->seekable = stream->seekable; diff --git a/demux/demux.h b/demux/demux.h index 07803d2838..c7d1b8ee1d 100644 --- a/demux/demux.h +++ b/demux/demux.h @@ -183,6 +183,7 @@ typedef struct demuxer { // packets is not slow either (unlike e.g. libavdevice pseudo-demuxers). // Typical examples: text subtitles, playlists bool fully_read; + bool is_network; // opened directly from a network stream // Bitmask of DEMUX_EVENT_* int events; diff --git a/player/command.c b/player/command.c index e9a051db8c..f4c10d48b9 100644 --- a/player/command.c +++ b/player/command.c @@ -429,11 +429,9 @@ static int mp_property_stream_path(void *ctx, struct m_property *prop, int action, void *arg) { MPContext *mpctx = ctx; - // demuxer->stream as well as stream->url are immutable -> ok to access - struct stream *stream = mpctx->demuxer ? mpctx->demuxer->stream : NULL; - if (!stream || !stream->url) + if (!mpctx->demuxer || !mpctx->demuxer->filename) return M_PROPERTY_UNAVAILABLE; - return m_property_strdup_ro(action, arg, stream->url); + return m_property_strdup_ro(action, arg, mpctx->demuxer->filename); } struct change_stream_capture_args { diff --git a/player/loadfile.c b/player/loadfile.c index c41ff4367a..b42b8f14e3 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -634,7 +634,7 @@ void autoload_external_files(struct MPContext *mpctx) char *lang = list[i].lang; for (int n = 0; n < mpctx->num_tracks; n++) { struct track *t = mpctx->tracks[n]; - if (t->demuxer && strcmp(t->demuxer->stream->url, filename) == 0) + if (t->demuxer && strcmp(t->demuxer->filename, filename) == 0) goto skip; } if (list[i].type == STREAM_SUB && !sc[STREAM_VIDEO] && !sc[STREAM_AUDIO]) @@ -1029,7 +1029,7 @@ reopen_file: int entry_stream_flags = 0; if (!pl->disable_safety) { entry_stream_flags = STREAM_SAFE_ONLY; - if (mpctx->demuxer->stream->is_network) + if (mpctx->demuxer->is_network) entry_stream_flags |= STREAM_NETWORK_ONLY; } for (struct playlist_entry *e = pl->first; e; e = e->next) -- cgit v1.2.3