summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/out/push.c6
-rw-r--r--input/ipc-unix.c3
-rw-r--r--osdep/io.c8
-rw-r--r--osdep/io.h1
-rw-r--r--video/out/x11_common.c6
5 files changed, 14 insertions, 10 deletions
diff --git a/audio/out/push.c b/audio/out/push.c
index ac87c62a96..bf5dde46b5 100644
--- a/audio/out/push.c
+++ b/audio/out/push.c
@@ -497,10 +497,8 @@ int ao_wait_poll(struct ao *ao, struct pollfd *fds, int num_fds,
bool wakeup = false;
if (p_fds[num_fds].revents & POLLIN) {
wakeup = true;
- // flush the wakeup pipe contents - might "drown" some wakeups, but
- // that's ok for our use-case
- char buf[100];
- (void)read(p->wakeup_pipe[0], buf, sizeof(buf));
+ // might "drown" some wakeups, but that's ok for our use-case
+ mp_flush_wakeup_pipe(p->wakeup_pipe[0]);
}
return (r >= 0 || r == -EINTR) ? wakeup : -1;
}
diff --git a/input/ipc-unix.c b/input/ipc-unix.c
index 12d7018c9e..0f4b7132e4 100644
--- a/input/ipc-unix.c
+++ b/input/ipc-unix.c
@@ -133,8 +133,7 @@ static void *client_thread(void *p)
}
if (fds[0].revents & POLLIN) {
- char discard[100];
- (void)read(pipe_fd, discard, sizeof(discard));
+ mp_flush_wakeup_pipe(pipe_fd);
while (1) {
mpv_event *event = mpv_wait_event(arg->client, 0);
diff --git a/osdep/io.c b/osdep/io.c
index 5952f21980..26889189cf 100644
--- a/osdep/io.c
+++ b/osdep/io.c
@@ -85,6 +85,14 @@ int mp_make_wakeup_pipe(int pipes[2])
}
#endif
+void mp_flush_wakeup_pipe(int pipe_end)
+{
+#ifndef __MINGW32__
+ char buf[100];
+ (void)read(pipe_end, buf, sizeof(buf));
+#endif
+}
+
#ifdef _WIN32
#include <windows.h>
diff --git a/osdep/io.h b/osdep/io.h
index 541e36aeea..333ed4f808 100644
--- a/osdep/io.h
+++ b/osdep/io.h
@@ -47,6 +47,7 @@
bool mp_set_cloexec(int fd);
int mp_make_cloexec_pipe(int pipes[2]);
int mp_make_wakeup_pipe(int pipes[2]);
+void mp_flush_wakeup_pipe(int pipe_end);
#ifdef _WIN32
#include <wchar.h>
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index ee19e1be73..a9d6a2a632 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -1934,10 +1934,8 @@ void vo_x11_wait_events(struct vo *vo, int64_t until_time_us)
poll(fds, 2, timeout_ms);
- if (fds[1].revents & POLLIN) {
- char buf[100];
- (void)read(x11->wakeup_pipe[0], buf, sizeof(buf)); // flush
- }
+ if (fds[1].revents & POLLIN)
+ mp_flush_wakeup_pipe(x11->wakeup_pipe[0]);
}
static void xscreensaver_heartbeat(struct vo_x11_state *x11)