summaryrefslogtreecommitdiffstats
path: root/video/out/drm_common.c
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-09-17 22:27:12 -0500
committerDudemanguy <random342@airmail.cc>2023-10-10 19:10:55 +0000
commit5d44cf93df47046c779fc4da68a09812a2ce4004 (patch)
tree07f9fca72a897210f2fb0682773a0cef4efb456f /video/out/drm_common.c
parentba4b408b8bdc2aa0059abaaffe8b16f28aec480b (diff)
downloadmpv-5d44cf93df47046c779fc4da68a09812a2ce4004.tar.bz2
mpv-5d44cf93df47046c779fc4da68a09812a2ce4004.tar.xz
vo: use mp_poll wrapper in wait_events when applicable
On linux, several platforms poll for events over a fd. This has ms accuracy, but mpv's timer is in ns now so lots of precision is lost. We can use an mp_poll wrapper to use ppoll instead which takes a timespec directly with nanosecond precision. On systems without ppoll this falls back to old poll behavior. On wayland, we don't actually use this because ppoll completely messes up the event loop for some unknown reason.
Diffstat (limited to 'video/out/drm_common.c')
-rw-r--r--video/out/drm_common.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/video/out/drm_common.c b/video/out/drm_common.c
index dd53793dbb..f8d68dfa81 100644
--- a/video/out/drm_common.c
+++ b/video/out/drm_common.c
@@ -42,6 +42,7 @@
#include "common/msg.h"
#include "options/m_config.h"
#include "osdep/io.h"
+#include "osdep/poll_wrapper.h"
#include "osdep/timer.h"
#include "misc/ctype.h"
#include "video/out/vo.h"
@@ -283,12 +284,12 @@ static void vt_switcher_destroy(struct vt_switcher *s)
close(vt_switcher_pipe[1]);
}
-static void vt_switcher_poll(struct vt_switcher *s, int timeout_ms)
+static void vt_switcher_poll(struct vt_switcher *s, int timeout_ns)
{
struct pollfd fds[1] = {
{ .events = POLLIN, .fd = vt_switcher_pipe[0] },
};
- poll(fds, 1, timeout_ms);
+ mp_poll(fds, 1, timeout_ns);
if (!fds[0].revents)
return;
@@ -1309,8 +1310,8 @@ void vo_drm_wait_events(struct vo *vo, int64_t until_time_ns)
struct vo_drm_state *drm = vo->drm;
if (drm->vt_switcher_active) {
int64_t wait_ns = until_time_ns - mp_time_ns();
- int timeout_ms = MPCLAMP(wait_ns / 1e6, 1, 10000);
- vt_switcher_poll(&drm->vt_switcher, timeout_ms);
+ int64_t timeout_ns = MPCLAMP(wait_ns, 1e6, 1e10);
+ vt_switcher_poll(&drm->vt_switcher, timeout_ns);
} else {
vo_wait_default(vo, until_time_ns);
}