summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-04-24 22:20:03 +0300
committerUoti Urpala <uau@mplayer2.org>2011-05-01 14:44:05 +0300
commit3e86228fad309b54869bf2a3314756933ba74e43 (patch)
tree568fb7657bec4285fbee106e257964f88c876e53 /input
parent40234b1a3c21cd0ef1087bd5b5e9601dd56c4fce (diff)
downloadmpv-3e86228fad309b54869bf2a3314756933ba74e43.tar.bz2
mpv-3e86228fad309b54869bf2a3314756933ba74e43.tar.xz
input: don't interrupt processing at unbound events
The input code read at most one event per input or command fd. If this event was not bound to any recognized command then no command was returned, and higher-level code could not distinguish this case from there being no pending events left. As a result unbound events would cause extra latency in event processing. Change the input code to continue reading events until it either finds one that maps to a command or hits EOF/error.
Diffstat (limited to 'input')
-rw-r--r--input/input.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/input/input.c b/input/input.c
index aeefec25f1..1dc57960db 100644
--- a/input/input.c
+++ b/input/input.c
@@ -1279,13 +1279,14 @@ static mp_cmd_t *read_events(struct input_ctx *ictx, int time)
continue;
#endif
- int code = key_fds[i].read_func.key(key_fds[i].ctx, key_fds[i].fd);
- if (code >= 0) {
+ int code;
+ while ((code = key_fds[i].read_func.key(key_fds[i].ctx,
+ key_fds[i].fd)) >= 0) {
mp_cmd_t *ret = interpret_key(ictx, code);
if (ret)
return ret;
}
- else if (code == MP_INPUT_ERROR)
+ if (code == MP_INPUT_ERROR)
mp_tmsg(MSGT_INPUT, MSGL_ERR, "Error on key input file descriptor %d\n",
key_fds[i].fd);
else if (code == MP_INPUT_DEAD) {
@@ -1305,14 +1306,14 @@ static mp_cmd_t *read_events(struct input_ctx *ictx, int time)
continue;
#endif
char *cmd;
- int r = read_cmd(&cmd_fds[i], &cmd);
- if (r >= 0) {
+ int r;
+ while ((r = read_cmd(&cmd_fds[i], &cmd)) >= 0) {
mp_cmd_t *ret = mp_input_parse_cmd(cmd);
talloc_free(cmd);
if (ret)
return ret;
}
- else if (r == MP_INPUT_ERROR)
+ if (r == MP_INPUT_ERROR)
mp_tmsg(MSGT_INPUT, MSGL_ERR, "Error on command file descriptor %d\n",
cmd_fds[i].fd);
else if (r == MP_INPUT_DEAD)