diff options
author | wm4 <wm4@nowhere> | 2014-05-29 23:56:56 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-05-30 02:16:20 +0200 |
commit | ec18df84661189b11e426eefd999348b9e60c16a (patch) | |
tree | 8190ad73e1d66632ea4f64b7c7fa96512352fb06 /input/input.c | |
parent | 5929dc458f46f75648af1ee7a293e899e67d8e66 (diff) | |
download | mpv-ec18df84661189b11e426eefd999348b9e60c16a.tar.bz2 mpv-ec18df84661189b11e426eefd999348b9e60c16a.tar.xz |
input: separate wakeup pipe creation into a separate function
Error handling is slightly reduced: we assume that setting a pipe
to non-blocking can never fail.
Diffstat (limited to 'input/input.c')
-rw-r--r-- | input/input.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/input/input.c b/input/input.c index 299657f335..44360e05ec 100644 --- a/input/input.c +++ b/input/input.c @@ -1492,20 +1492,9 @@ struct input_ctx *mp_input_init(struct mpv_global *global) } #ifndef __MINGW32__ - int ret = pipe(ictx->wakeup_pipe); - if (ret == 0) { - for (int i = 0; i < 2 && ret >= 0; i++) { - mp_set_cloexec(ictx->wakeup_pipe[i]); - ret = fcntl(ictx->wakeup_pipe[i], F_GETFL); - if (ret < 0) - break; - ret = fcntl(ictx->wakeup_pipe[i], F_SETFL, ret | O_NONBLOCK); - if (ret < 0) - break; - } - } + int ret = mp_make_wakeup_pipe(ictx->wakeup_pipe); if (ret < 0) - MP_ERR(ictx, "Failed to initialize wakeup pipe: %s\n", strerror(errno)); + MP_ERR(ictx, "Failed to initialize wakeup pipe: %s\n", strerror(-ret)); else mp_input_add_fd(ictx, ictx->wakeup_pipe[0], true, NULL, read_wakeup, NULL, NULL); |