From 9821737d0611d3e1a4a3ede40bd796f49a6e3445 Mon Sep 17 00:00:00 2001 From: rslovers Date: Wed, 7 Jun 2017 13:58:12 +0000 Subject: [PATCH] vo_drm: fallback to vo_wait_default if VT switcher is not available When the drm video output is used under VT with a terminal multiplexer like screen, the VT_SETMODE ioctl call will fail since the controlling terminal is a pseudoterminal instead of a real one, thus the VT switcher will be unavailable. The problem is, the wait_events function inside vo_drm.c will test for this, and will do nothing if the switcher is not active. Normally, this would not be noticed, however, when you pause a video, or if you're playing multiple image files, mpv will suddenly start busy waiting on a single core. I confirmed this by building mpv with gprof support, in a few seconds, wait_events got called about 90 million times. So I added a fallback, when the VT switcher is not availble, just use the vo_wait_default function. I tested it and it's working well so far. --- video/out/vo_drm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/video/out/vo_drm.c b/video/out/vo_drm.c index 3436e0fc5c..2fdd840588 100644 --- a/video/out/vo_drm.c +++ b/video/out/vo_drm.c @@ -250,6 +250,8 @@ static void wait_events(struct vo *vo, int64_t until_time_us) int64_t wait_us = until_time_us - mp_time_us(); int timeout_ms = MPCLAMP((wait_us + 500) / 1000, 0, 10000); vt_switcher_poll(&p->vt_switcher, timeout_ms); + } else { + vo_wait_default(vo, until_time_us); } }