summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-04-23 22:43:13 +0300
committerUoti Urpala <uau@mplayer2.org>2012-04-26 21:03:02 +0300
commit9ba3e1ddb25a780f31ad2ed3e2fbb6682c098456 (patch)
tree12c6d7f0e74cb68f8e0771fa23564b12c79c2c65 /mplayer.c
parentab6c760b3b58ec5b95b7d3af4fda941e8532dd70 (diff)
downloadmpv-9ba3e1ddb25a780f31ad2ed3e2fbb6682c098456.tar.bz2
mpv-9ba3e1ddb25a780f31ad2ed3e2fbb6682c098456.tar.xz
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.
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c15
1 files 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 <windows.h>
+// 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 <string.h>
#include <unistd.h>
@@ -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