mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 09:32:40 +00:00
5d44cf93df
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.
13 lines
374 B
C
13 lines
374 B
C
#pragma once
|
|
|
|
#include <poll.h>
|
|
#include <stdint.h>
|
|
|
|
// Behaves like poll(3) but works for device files on macOS.
|
|
// Only supports POLLIN and POLLOUT.
|
|
int polldev(struct pollfd fds[], nfds_t nfds, int timeout);
|
|
|
|
// Generic polling wrapper. It will try and use higher resolution
|
|
// polling (ppoll) if available.
|
|
int mp_poll(struct pollfd *fds, int nfds, int64_t timeout_ns);
|