mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 12:02:23 +02:00
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.
This commit is contained in:
parent
b636b19058
commit
4121016689
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user