From d84a7c51125a296e840842c8c1fa9103825b2c93 Mon Sep 17 00:00:00 2001 From: llyyr Date: Thu, 22 Aug 2024 22:53:10 +0530 Subject: [PATCH] stream: don't mark stdin as a filesystem file Also rename the field to appropriately reflect what it is supposed to be used for. The only other use of this was to search for ordered chapter sources, and that makes no sense for mkv files from stdin. This also fixes autocreate-playlist loading in the current directory when the input file is stdin. --- demux/demux_mkv_timeline.c | 2 +- demux/demux_playlist.c | 2 +- stream/stream.h | 2 +- stream/stream_file.c | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/demux/demux_mkv_timeline.c b/demux/demux_mkv_timeline.c index 0190213b4e..d1ebe78a4b 100644 --- a/demux/demux_mkv_timeline.c +++ b/demux/demux_mkv_timeline.c @@ -259,7 +259,7 @@ static void find_ordered_chapter_sources(struct tl_ctx *ctx) MP_TARRAY_APPEND(tmp, filenames, num_filenames, pl->entries[n]->filename); } - } else if (!ctx->demuxer->stream->is_local_file) { + } else if (!ctx->demuxer->stream->is_local_fs) { MP_WARN(ctx, "Playback source is not a " "normal disk file. Will not search for related files.\n"); } else { diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c index ba98560d42..46bac914cb 100644 --- a/demux/demux_playlist.c +++ b/demux/demux_playlist.c @@ -515,7 +515,7 @@ static int parse_dir(struct pl_parser *p) struct stream *stream = p->real_stream; enum autocreate_mode autocreate = AUTO_NONE; p->pl->playlist_dir = NULL; - if (p->autocreate_playlist && p->real_stream->is_local_file && !p->real_stream->is_directory) { + if (p->autocreate_playlist && p->real_stream->is_local_fs && !p->real_stream->is_directory) { bstr ext = bstr_get_ext(bstr0(p->real_stream->url)); switch (p->autocreate_playlist) { case 1: // filter diff --git a/stream/stream.h b/stream/stream.h index 866affe1fe..2447df0344 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -152,7 +152,7 @@ typedef struct stream { bool seekable : 1; // presence of general byte seeking support bool fast_skip : 1; // consider stream fast enough to fw-seek by skipping bool is_network : 1; // I really don't know what this is for - bool is_local_file : 1; // from the filesystem + bool is_local_fs : 1; // from the filesystem bool is_directory : 1; // directory on the filesystem bool access_references : 1; // open other streams struct mp_log *log; diff --git a/stream/stream_file.c b/stream/stream_file.c index ff53d35546..7d3274dddd 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -280,7 +280,7 @@ static int open_f(stream_t *stream, const struct stream_open_args *args) .fd = -1, }; stream->priv = p; - stream->is_local_file = true; + stream->is_local_fs = true; bool strict_fs = args->flags & STREAM_LOCAL_FS_ONLY; bool write = stream->mode == STREAM_WRITE; @@ -297,6 +297,7 @@ static int open_f(stream_t *stream, const struct stream_open_args *args) bool is_fdclose = strncmp(url, "fdclose://", 10) == 0; if (strncmp(url, "fd://", 5) == 0 || is_fdclose) { + stream->is_local_fs = false; char *begin = strstr(stream->url, "://") + 3, *end = NULL; p->fd = strtol(begin, &end, 0); if (!end || end == begin || end[0] || p->fd < 0) { @@ -312,6 +313,7 @@ static int open_f(stream_t *stream, const struct stream_open_args *args) if (is_fdclose) p->close = true; } else if (!strict_fs && !strcmp(filename, "-")) { + stream->is_local_fs = false; if (!write) { MP_INFO(stream, "Reading from stdin...\n"); p->fd = 0;