summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-07-17 04:47:50 +0300
committerUoti Urpala <uau@mplayer2.org>2011-07-17 07:36:09 +0300
commit82b8f89baeafc2b2b39381f2ee14e4a2b2619b4c (patch)
treeb7bd847d8666233ef289224162e1e5a8668b685d /mplayer.c
parent1916b95b8d3737ac783eb6351664f9892824e5c5 (diff)
downloadmpv-82b8f89baeafc2b2b39381f2ee14e4a2b2619b4c.tar.bz2
mpv-82b8f89baeafc2b2b39381f2ee14e4a2b2619b4c.tar.xz
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 'mplayer.c')
-rw-r--r--mplayer.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/mplayer.c b/mplayer.c
index c8216fae90..c10cb61223 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -3732,7 +3732,7 @@ static void run_playloop(struct MPContext *mpctx)
static int read_keys(void *ctx, int fd)
{
getch2(ctx);
- return mplayer_get_key(ctx, 0);
+ return MP_INPUT_NOTHING;
}
static bool attachment_is_font(struct demux_attachment *att)
@@ -3887,7 +3887,6 @@ int i;
}
}
}
- mpctx->key_fifo = mp_fifo_create(opts);
print_version("MPlayer2");
@@ -4079,7 +4078,7 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
// Init input system
current_module = "init_input";
mpctx->input = mp_input_init(&opts->input);
- mp_input_add_key_fd(mpctx->input, -1,0,mplayer_get_key,NULL, mpctx->key_fifo);
+ mpctx->key_fifo = mp_fifo_create(mpctx->input, opts);
if(slave_mode) {
#if USE_FD0_CMD_SELECT
int flags = fcntl(0, F_GETFL);