diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2012-04-03 08:13:12 +0200 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2012-04-26 21:03:10 +0300 |
commit | 86790494d38c4f33f74875e1ab7a9dc1bdae1772 (patch) | |
tree | 8ce20af25b97382c5d0dea00ce0ff206f725d008 /input | |
parent | 9646208cc671721fce2253a3c5d40b1961810a87 (diff) | |
download | mpv-86790494d38c4f33f74875e1ab7a9dc1bdae1772.tar.bz2 mpv-86790494d38c4f33f74875e1ab7a9dc1bdae1772.tar.xz |
OSX, input: implement wakeup in response to Cocoa events
Add code to wake up the select() call in input.c when an OSX event is
available and a Cocoa OpenGL backend is initialized.
Fixes the slow response to input or other events in Cocoa-based VOs
during long select() sleeps (e.g., when mplayer2 is paused) introduced
by commit 7040968.
Diffstat (limited to 'input')
-rw-r--r-- | input/input.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/input/input.c b/input/input.c index e422e9f1a2..191b378deb 100644 --- a/input/input.c +++ b/input/input.c @@ -59,6 +59,10 @@ #include "ar.h" +#ifdef CONFIG_COCOA +#include "osdep/cocoa_events.h" +#endif + #define MP_MAX_KEY_DOWN 32 struct cmd_bind { @@ -1436,7 +1440,7 @@ static void read_events(struct input_ctx *ictx, int time) * every source until it's known to be empty. Instead we use this wrapper * to run select() again. */ -static void read_all_events(struct input_ctx *ictx, int time) +static void read_all_fd_events(struct input_ctx *ictx, int time) { while (1) { read_events(ictx, time); @@ -1446,6 +1450,15 @@ static void read_all_events(struct input_ctx *ictx, int time) } } +static void read_all_events(struct input_ctx *ictx, int time) +{ +#ifdef CONFIG_COCOA + cocoa_events_read_all_events(ictx, time); +#else + read_all_fd_events(ictx, time); +#endif +} + int mp_input_queue_cmd(struct input_ctx *ictx, mp_cmd_t *cmd) { ictx->got_new_events = true; @@ -1743,6 +1756,10 @@ struct input_ctx *mp_input_init(struct input_conf *input_conf) .wakeup_pipe = {-1, -1}, }; +#ifdef CONFIG_COCOA + cocoa_events_init(ictx, read_all_fd_events); +#endif + #ifndef __MINGW32__ long ret = pipe(ictx->wakeup_pipe); for (int i = 0; i < 2 && ret >= 0; i++) { @@ -1848,11 +1865,16 @@ struct input_ctx *mp_input_init(struct input_conf *input_conf) mp_tmsg(MSGT_INPUT, MSGL_ERR, "Can't open %s: %s\n", input_conf->in_file, strerror(errno)); } + return ictx; } void mp_input_uninit(struct input_ctx *ictx) { +#ifdef CONFIG_COCOA + cocoa_events_uninit(); +#endif + if (!ictx) return; |