From 82b8f89baeafc2b2b39381f2ee14e4a2b2619b4c Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sun, 17 Jul 2011 04:47:50 +0300 Subject: input: rework event reading and command queuing Rework much of the logic related to reading from event sources and queuing commands. The two biggest architecture changes are: - The code buffering keycodes in mp_fifo.c is gone. Instead key input is now immediately fed to input.c and interpreted as commands, and then the commands are buffered instead. - mp_input_get_cmd() now always tries to read every available event from every event source and convert them to (buffered) commands. Before it would only process new events until one new command became available. Some relevant behavior changes: - Before commands could be lost when stream code called mp_input_check_interrupt() which read commands (to see if they were of types that triggered aborts during slow IO tasks) and then threw them away. This was especially an issue if cache was enabled and slow to read. Fixed - now it's possible to check whether there are queued commands which will abort playback of the current file without throwing other commands away. - mp_input_check_interrupt() now prints a message if it returns true. This is especially useful because the failures caused by aborted stream reads can trigger error messages from other code that was doing the read; the new message makes it more obvious what the cause of the subsequent error messages is. - It's now possible to again avoid making stdin non-blocking (which caused some issues) without reintroducing extra latency. The change will be done in a subsequent commit. - Event sources that do not support select() should now have somewhat lower latency in certain situations as they will be checked both before and after select()/sleep in input reading; before the sleep always happened first even if such sources already had queued input. Before the key fifo was also handled in this manner (first key triggered select, but if multiple were read then rest could be delayed; however in most cases this didn't add latency in practice as after central code started doing command handling it queried for further commands with a max sleep time of 0). - Key fifo limiting is more accurate now: it now counts actual commands intead of keycodes, and all queued keys are read immediately from input devices so they can be counted correctly. - Since keypresses are now interpreted immediately, commands which change keybindings will no longer affect following keypresses that have already been read before the command is executed. This should not be an issue in practice with current keybinding behavior. --- mp_fifo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mp_fifo.h') diff --git a/mp_fifo.h b/mp_fifo.h index 125b67eb2c..01c1fb0c37 100644 --- a/mp_fifo.h +++ b/mp_fifo.h @@ -20,11 +20,11 @@ #define MPLAYER_MP_FIFO_H struct mp_fifo; -int mplayer_get_key(void *ctx, int fd); void mplayer_put_key(struct mp_fifo *fifo, int code); // Can be freed with talloc_free() +struct input_ctx; struct MPOpts; -struct mp_fifo *mp_fifo_create(struct MPOpts *opts); +struct mp_fifo *mp_fifo_create(struct input_ctx *input, struct MPOpts *opts); #ifdef IS_OLD_VO -- cgit v1.2.3