summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-13 17:05:06 +0100
committersfan5 <sfan5@live.de>2024-03-16 13:41:24 +0100
commit801306acdf83e9fa5e13198bc3cd46a19d87edbd (patch)
tree8114d8b1ff17673086b40da46ed4691a613f86e4
parent830f6ccd6bcd8bdffc4e2c8d8f1a3e1be25f0a1d (diff)
downloadmpv-801306acdf83e9fa5e13198bc3cd46a19d87edbd.tar.bz2
mpv-801306acdf83e9fa5e13198bc3cd46a19d87edbd.tar.xz
stream: enable caching for sockets, pipes and FIFOs
This is useful e.g. when the caller dup2's a socket into stdin, or passes a socket/pipe as /dev/fd/{fd}, because it is impossible to seek on sockets and pipes.
-rw-r--r--stream/stream_file.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/stream/stream_file.c b/stream/stream_file.c
index 5f06131f18..89e7a2d9f1 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -307,6 +307,7 @@ static int open_f(stream_t *stream, const struct stream_open_args *args)
}
struct stat st;
+ bool is_sock_or_fifo = false;
if (fstat(p->fd, &st) == 0) {
if (S_ISDIR(st.st_mode)) {
stream->is_directory = true;
@@ -320,6 +321,9 @@ static int open_f(stream_t *stream, const struct stream_open_args *args)
fcntl(p->fd, F_SETFL, val);
#endif
} else {
+#ifndef __MINGW32__
+ is_sock_or_fifo = S_ISSOCK(st.st_mode) || S_ISFIFO(st.st_mode);
+#endif
p->use_poll = true;
}
}
@@ -341,7 +345,7 @@ static int open_f(stream_t *stream, const struct stream_open_args *args)
stream->get_size = get_size;
stream->close = s_close;
- if (check_stream_network(p->fd)) {
+ if (is_sock_or_fifo || check_stream_network(p->fd)) {
stream->streaming = true;
#if HAVE_COCOA
if (fcntl(p->fd, F_RDAHEAD, 0) < 0) {