path: root/mp_fifo.h
diff options
authorUoti Urpala <>2011-07-17 04:47:50 +0300
committerUoti Urpala <>2011-07-17 07:36:09 +0300
commit82b8f89baeafc2b2b39381f2ee14e4a2b2619b4c (patch)
treeb7bd847d8666233ef289224162e1e5a8668b685d /mp_fifo.h
parent1916b95b8d3737ac783eb6351664f9892824e5c5 (diff)
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.
Diffstat (limited to 'mp_fifo.h')
1 files changed, 2 insertions, 2 deletions
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 @@
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