From 3e86228fad309b54869bf2a3314756933ba74e43 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sun, 24 Apr 2011 22:20:03 +0300 Subject: 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. --- input/input.c | 13 +++++++------ 1 file 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) -- cgit v1.2.3