From e2180e581e483e75c11670f4b3890e1f33be85f2 Mon Sep 17 00:00:00 2001 From: NRK Date: Thu, 2 Apr 2026 01:33:37 +0000 Subject: [PATCH] demux_playlist: only autocreate on regular file trying to autocreate playlist when the file is a fifo breaks playback. the bug report is a special case of `/dev/fd/*` but even for named fifos, opening and closing them can cause the other end to stop writing. Closes: https://github.com/mpv-player/mpv/issues/17682 --- DOCS/interface-changes/autocreate-playlist.txt | 1 + DOCS/man/options.rst | 4 ++-- demux/demux_playlist.c | 3 ++- stream/stream.h | 1 + stream/stream_file.c | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 DOCS/interface-changes/autocreate-playlist.txt diff --git a/DOCS/interface-changes/autocreate-playlist.txt b/DOCS/interface-changes/autocreate-playlist.txt new file mode 100644 index 0000000000..febf52fc6b --- /dev/null +++ b/DOCS/interface-changes/autocreate-playlist.txt @@ -0,0 +1 @@ +make `--autocreate-playlist` only activate for regular files diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index b7286b777b..d221aa4ccb 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -4375,8 +4375,8 @@ Demuxer This is a string list option. See `List Options`_ for details. ``--autocreate-playlist=`` - When opening a local file, act as if the parent directory is opened and - create a playlist automatically. + When opening a local regular file, act as if the parent directory is opened + and create a playlist automatically. :no: Load a single file (default). :filter: Create a playlist from the parent directory with files matching diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c index 62866e366b..8e0639e5eb 100644 --- a/demux/demux_playlist.c +++ b/demux/demux_playlist.c @@ -538,7 +538,8 @@ 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_fs && !p->real_stream->is_directory) { + if (p->autocreate_playlist && p->real_stream->is_local_fs && p->real_stream->is_regular && + !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 fd8b6e2523..98b5dff355 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -163,6 +163,7 @@ typedef struct stream { bool is_network : 1; // I really don't know what this is for bool is_local_fs : 1; // from the filesystem bool is_directory : 1; // directory on the filesystem + bool is_regular : 1; // regular file bool access_references : 1; // open other streams bool allow_partial_read : 1; // allows partial read with stream_read_file() struct mp_log *log; diff --git a/stream/stream_file.c b/stream/stream_file.c index d06da98901..c7540a8a5f 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -354,6 +354,7 @@ static int open_f(stream_t *stream, const struct stream_open_args *args) stream->is_directory = true; } else if (S_ISREG(st.st_mode)) { p->regular_file = true; + stream->is_regular = true; #ifndef _WIN32 // O_NONBLOCK has weird semantics on file locks; remove it. int val = fcntl(p->fd, F_GETFL) & ~(unsigned)O_NONBLOCK;