From 31b78ad7fa97d8047b609c1647a273e72612d425 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 17 May 2018 20:58:49 +0200 Subject: misc: move mp_cancel from stream.c to thread_tools.c It seems a bit inappropriate to have dumped this into stream.c, even if it's roughly speaking its main user. At least it made its way somewhat unfortunately to other components not related to the stream or demuxer layer at all. I'm too greedy to give this weird helper its own file, so dump it into thread_tools.c. Probably a somewhat pointless change. --- osdep/subprocess-posix.c | 3 ++- osdep/subprocess-win.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'osdep') diff --git a/osdep/subprocess-posix.c b/osdep/subprocess-posix.c index a5fe43c6d4..ff78eb42f8 100644 --- a/osdep/subprocess-posix.c +++ b/osdep/subprocess-posix.c @@ -26,8 +26,9 @@ #include "osdep/subprocess.h" -#include "osdep/io.h" #include "common/common.h" +#include "misc/thread_tools.h" +#include "osdep/io.h" #include "stream/stream.h" extern char **environ; diff --git a/osdep/subprocess-win.c b/osdep/subprocess-win.c index bbb1f6f7fd..b5a9e1a24d 100644 --- a/osdep/subprocess-win.c +++ b/osdep/subprocess-win.c @@ -27,6 +27,7 @@ #include "common/common.h" #include "stream/stream.h" #include "misc/bstr.h" +#include "misc/thread_tools.h" static void write_arg(bstr *cmdline, char *arg) { -- cgit v1.2.3 From b6214b2644148bf68ae781983ed81f972ebc5137 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 18 May 2018 23:34:23 +0200 Subject: timer: remove an unused helper function It's also dumb. --- osdep/timer.c | 10 ---------- osdep/timer.h | 6 ------ 2 files changed, 16 deletions(-) (limited to 'osdep') diff --git a/osdep/timer.c b/osdep/timer.c index f75aec76f3..c624b66e70 100644 --- a/osdep/timer.c +++ b/osdep/timer.c @@ -59,16 +59,6 @@ double mp_time_sec(void) return mp_time_us() / (double)(1000 * 1000); } -int64_t mp_time_relative_us(int64_t *t) -{ - int64_t r = 0; - int64_t now = mp_time_us(); - if (*t) - r = now - *t; - *t = now; - return r; -} - int64_t mp_add_timeout(int64_t time_us, double timeout_sec) { assert(time_us > 0); // mp_time_us() returns strictly positive values diff --git a/osdep/timer.h b/osdep/timer.h index b4a64c7820..78457d9b9a 100644 --- a/osdep/timer.h +++ b/osdep/timer.h @@ -39,12 +39,6 @@ void mp_sleep_us(int64_t us); #define MP_START_TIME 10000000 -// Return the amount of time that has passed since the last call, in -// microseconds. *t is used to calculate the time that has passed by storing -// the current time in it. If *t is 0, the call will return 0. (So that the -// first call will return 0, instead of the absolute current time.) -int64_t mp_time_relative_us(int64_t *t); - // Add a time in seconds to the given time in microseconds, and return it. // Takes care of possible overflows. Never returns a negative or 0 time. int64_t mp_add_timeout(int64_t time_us, double timeout_sec); -- cgit v1.2.3 From 707b404820a56ca3dfa22fc5f18e68186dbae51d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 20 May 2018 20:47:43 +0200 Subject: osdep: add portable C11-like alignof() macro --- osdep/compiler.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'osdep') diff --git a/osdep/compiler.h b/osdep/compiler.h index d25f0cd1e4..7c9f859f3a 100644 --- a/osdep/compiler.h +++ b/osdep/compiler.h @@ -17,5 +17,10 @@ #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (gnu_printf, a1, a2))) #endif +#if __STDC_VERSION__ >= 201112L +#include +#else +#define alignof(x) (offsetof(struct {char unalign_; x u;}, u)) +#endif #endif -- cgit v1.2.3 From 1112b1ba33e9a5e3c563e081bebe3a12962354ac Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 22 May 2018 20:06:21 +0200 Subject: terminal-unix: stop trying to read when terminal disappears Avoids 100% CPU usage due to terminal code retrying read(). Seems like this was "forgotten" (or there was somehow the assumption poll() would not signal POLLIN anymore). Fixes #5842. --- osdep/terminal-unix.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'osdep') diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c index 1e909522b7..954c13904f 100644 --- a/osdep/terminal-unix.c +++ b/osdep/terminal-unix.c @@ -395,8 +395,10 @@ static void *terminal_thread(void *ptr) polldev(fds, stdin_ok ? 2 : 1, -1); if (fds[0].revents) break; - if (fds[1].revents) - getch2(input_ctx); + if (fds[1].revents) { + if (!getch2(input_ctx)) + break; + } } char c; bool quit = read(death_pipe[0], &c, 1) == 1 && c == 1; -- cgit v1.2.3