diff options
-rw-r--r-- | core/mplayer.c | 38 | ||||
-rw-r--r-- | video/out/vo.h | 1 | ||||
-rw-r--r-- | video/out/w32_common.c | 3 |
3 files changed, 30 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); diff --git a/video/out/vo.h b/video/out/vo.h index 22e4650bde..452d50d548 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -241,6 +241,7 @@ struct vo { bool want_redraw; // visible frame wrong (window resize), needs refresh bool redrawing; // between redrawing frame and flipping it bool hasframe; // >= 1 frame has been drawn, so redraw is possible + double wakeup_period; // if > 0, this sets the maximum wakeup period for event polling double flip_queue_offset; // queue flip events at most this much in advance diff --git a/video/out/w32_common.c b/video/out/w32_common.c index ab608f5d8d..113ca2dddd 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -666,6 +666,9 @@ int vo_w32_init(struct vo *vo) if (WinID >= 0) EnableWindow(w32->window, 0); + // we don't have proper event handling + vo->wakeup_period = 0.02; + updateScreenProperties(vo); mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", |