summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRudolf Polzer <divverent@xonotic.org>2012-12-19 12:58:52 +0100
committerRudolf Polzer <divverent@xonotic.org>2012-12-19 12:58:52 +0100
commit7d0a20954f4ad642901a65fcb39ab601032ddcea (patch)
tree5699e70be76ec3f5ba2cc49faed378a3034601a7 /core
parent51c98619c8d039b4cf459910a3a934637cb69e05 (diff)
downloadmpv-7d0a20954f4ad642901a65fcb39ab601032ddcea.tar.bz2
mpv-7d0a20954f4ad642901a65fcb39ab601032ddcea.tar.xz
core: make WAKEUP_PERIOD overridable by the vo
This is better than having just the operating system type decide the wakeup period, as e.g. when compiling for Win32/cygwin, a wakeup period of 0.5 would work perfectly fine. Instead, the default wakeup period is now only decided by availability of a working select() system call (which is the case on cygwin but not mingw and MSVC) AND a vo that can provide an event file descriptor or a similar hack (vo_corevideo). vos that cannot do either need polling for event handling and now can set the wakeup period to 0.02 in the vo code.
Diffstat (limited to 'core')
-rw-r--r--core/mplayer.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index c57062517d..39991727c3 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -36,17 +36,8 @@
#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
+#define WAKEUP_PERIOD 0.5
#include <string.h>
#include <unistd.h>
@@ -3140,6 +3131,28 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx)
}
}
+static double get_wakeup_period(struct MPContext *mpctx)
+{
+ /* 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.
+ */
+ double sleeptime = WAKEUP_PERIOD;
+
+#ifndef HAVE_POSIX_SELECT
+ // No proper file descriptor event handling; keep waking up to poll input
+ sleeptime = FFMIN(sleeptime, 0.02);
+#endif
+
+ if (mpctx->video_out)
+ if (mpctx->video_out->wakeup_period > 0)
+ sleeptime = FFMIN(sleeptime, mpctx->video_out->wakeup_period);
+
+ return sleeptime;
+}
+
static void run_playloop(struct MPContext *mpctx)
{
struct MPOpts *opts = &mpctx->opts;
@@ -3147,7 +3160,7 @@ static void run_playloop(struct MPContext *mpctx)
bool audio_left = false, video_left = false;
double endpts = get_play_end_pts(mpctx);
bool end_is_chapter = false;
- double sleeptime = WAKEUP_PERIOD;
+ double sleeptime = get_wakeup_period(mpctx);
bool was_restart = mpctx->restart_playback;
#ifdef CONFIG_ENCODING
@@ -3808,7 +3821,8 @@ static void idle_loop(struct MPContext *mpctx)
{
uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_VO);
mp_cmd_t *cmd;
- while (!(cmd = mp_input_get_cmd(mpctx->input, WAKEUP_PERIOD * 1000,
+ while (!(cmd = mp_input_get_cmd(mpctx->input,
+ get_wakeup_period(mpctx) * 1000,
false)));
run_command(mpctx, cmd);
mp_cmd_free(cmd);