From 9ba3e1ddb25a780f31ad2ed3e2fbb6682c098456 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 23 Apr 2012 22:43:13 +0300 Subject: [PATCH] win32: core: wake up more often to poll for input MSWindows does not have properly working support for detecting events on file descriptors. As a result the current mplayer2 code does not support waking up when new input events occur. Make the central playloop wake up more often to poll for events; otherwise response would be a lot laggier than on better operating systems during pause or other cases where the process would not otherwise wake up. --- mplayer.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mplayer.c b/mplayer.c index aecbce8275..2ca8518335 100644 --- a/mplayer.c +++ b/mplayer.c @@ -31,6 +31,16 @@ #if defined(__MINGW32__) || defined(__CYGWIN__) #include +// No proper file descriptor event handling; keep waking up to poll input +#define WAKEUP_PERIOD 0.02 +#else +/* Even if we can immediately wake up in response to most input events, + * there are some timers which are not registered to the event loop + * and need to be checked periodically (like automatic mouse cursor hiding). + * OSD content updates behave similarly. Also some uncommon input devices + * may not have proper FD event support. + */ +#define WAKEUP_PERIOD 0.5 #endif #include #include @@ -3421,7 +3431,7 @@ static void run_playloop(struct MPContext *mpctx) bool audio_left = false, video_left = false; double endpts = end_at.type == END_AT_TIME ? end_at.pos : MP_NOPTS_VALUE; bool end_is_chapter = false; - double sleeptime = 0.5; + double sleeptime = WAKEUP_PERIOD; bool was_restart = mpctx->restart_playback; if (mpctx->timeline) { @@ -4255,7 +4265,8 @@ play_next_file: uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_VO); play_tree_t *entry = NULL; mp_cmd_t *cmd; - while (!(cmd = mp_input_get_cmd(mpctx->input, 500, false))); + while (!(cmd = mp_input_get_cmd(mpctx->input, WAKEUP_PERIOD * 1000, + false))); switch (cmd->id) { case MP_CMD_LOADFILE: // prepare a tree entry with the new filename