summaryrefslogtreecommitdiffstats
path: root/input/input.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-14 16:21:04 +0200
committerwm4 <wm4@nowhere>2014-09-14 16:24:01 +0200
commite0b4daf3ad240ecf70af73c13b6ca9b1062a507f (patch)
treee52d79650aa69c0288dd5d9c896ab943c692f88f /input/input.c
parentb44571ababeb368e94df6665c1d370d817a51135 (diff)
downloadmpv-e0b4daf3ad240ecf70af73c13b6ca9b1062a507f.tar.bz2
mpv-e0b4daf3ad240ecf70af73c13b6ca9b1062a507f.tar.xz
input: use libwaio for pipe input on Windows
Use libwaio to read from pipes (stdin or named pipes) on Windows. This liberates us from nasty issues, such as pipes (as created by most programs) not being possible to read in a non-blocking or event-driven way. Although it would be possible to do that in a somewhat sane way on Vista+, it's still not easy, and on XP it's especially hard. libwaio handles these things for us. Move pipe.c to pipe-unix.c, and remove Windows specific things. Also adjust the input.c code to make this work cleanly.
Diffstat (limited to 'input/input.c')
-rw-r--r--input/input.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/input/input.c b/input/input.c
index 02589e1941..ea0a4c375a 100644
--- a/input/input.c
+++ b/input/input.c
@@ -1273,8 +1273,13 @@ struct input_ctx *mp_input_init(struct mpv_global *global)
ictx->win_drag = global->opts->allow_win_drag;
- if (input_conf->in_file && input_conf->in_file[0])
- mp_input_add_pipe(ictx, input_conf->in_file);
+ if (input_conf->in_file && input_conf->in_file[0]) {
+#if !defined(__MINGW32__) || HAVE_WAIO
+ mp_input_pipe_add(ictx, input_conf->in_file);
+#else
+ MP_ERR(ictx, "Pipes not available.\n");
+#endif
+ }
return ictx;
}
@@ -1399,10 +1404,12 @@ void mp_input_src_kill(struct mp_input_src *src)
MP_TARRAY_REMOVE_AT(ictx->sources, ictx->num_sources, n);
input_unlock(ictx);
write(src->in->wakeup[1], &(char){0}, 1);
- if (src->close)
- src->close(src);
+ if (src->cancel)
+ src->cancel(src);
if (src->in->thread_running)
pthread_join(src->in->thread, NULL);
+ if (src->uninit)
+ src->uninit(src);
talloc_free(src);
return;
}