Skip to content

Commit e2180e5

Browse files
N-R-Kkasper93
authored andcommitted
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: #17682
1 parent 7ace42f commit e2180e5

5 files changed

Lines changed: 7 additions & 3 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
make `--autocreate-playlist` only activate for regular files

DOCS/man/options.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4375,8 +4375,8 @@ Demuxer
43754375
This is a string list option. See `List Options`_ for details.
43764376

43774377
``--autocreate-playlist=<no|filter|same>``
4378-
When opening a local file, act as if the parent directory is opened and
4379-
create a playlist automatically.
4378+
When opening a local regular file, act as if the parent directory is opened
4379+
and create a playlist automatically.
43804380

43814381
:no: Load a single file (default).
43824382
:filter: Create a playlist from the parent directory with files matching

demux/demux_playlist.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,8 @@ static int parse_dir(struct pl_parser *p)
538538
struct stream *stream = p->real_stream;
539539
enum autocreate_mode autocreate = AUTO_NONE;
540540
p->pl->playlist_dir = NULL;
541-
if (p->autocreate_playlist && p->real_stream->is_local_fs && !p->real_stream->is_directory) {
541+
if (p->autocreate_playlist && p->real_stream->is_local_fs && p->real_stream->is_regular &&
542+
!p->real_stream->is_directory) {
542543
bstr ext = bstr_get_ext(bstr0(p->real_stream->url));
543544
switch (p->autocreate_playlist) {
544545
case 1: // filter

stream/stream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ typedef struct stream {
163163
bool is_network : 1; // I really don't know what this is for
164164
bool is_local_fs : 1; // from the filesystem
165165
bool is_directory : 1; // directory on the filesystem
166+
bool is_regular : 1; // regular file
166167
bool access_references : 1; // open other streams
167168
bool allow_partial_read : 1; // allows partial read with stream_read_file()
168169
struct mp_log *log;

stream/stream_file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ static int open_f(stream_t *stream, const struct stream_open_args *args)
354354
stream->is_directory = true;
355355
} else if (S_ISREG(st.st_mode)) {
356356
p->regular_file = true;
357+
stream->is_regular = true;
357358
#ifndef _WIN32
358359
// O_NONBLOCK has weird semantics on file locks; remove it.
359360
int val = fcntl(p->fd, F_GETFL) & ~(unsigned)O_NONBLOCK;

0 commit comments

Comments
 (0)