summaryrefslogtreecommitdiffstats
path: root/video/out/vo.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-07-20 20:42:30 +0200
committerwm4 <wm4@nowhere>2016-07-20 20:42:30 +0200
commitbd9c0a10e577e7f839aabc27af6e186a9ba0cdaa (patch)
tree30ef3d3bbffa7e0e7693aed2619e26c2001269a3 /video/out/vo.c
parente11a20a8122b370b66235284dd4f67ce1f1bbc0b (diff)
downloadmpv-bd9c0a10e577e7f839aabc27af6e186a9ba0cdaa.tar.bz2
mpv-bd9c0a10e577e7f839aabc27af6e186a9ba0cdaa.tar.xz
vo_opengl: allow backends to provide callbacks for custom event loops
Until now, this has been either handled over vo.event_fd (which should go away), or by putting event handling on a separate thread. The backends which do the latter do it for a reason and won't need this, but X11 and Wayland will, in order to get rid of event_fd.
Diffstat (limited to 'video/out/vo.c')
-rw-r--r--video/out/vo.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/video/out/vo.c b/video/out/vo.c
index 07476ad7c3..97df1c1445 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -610,27 +610,39 @@ static void wait_event_fd(struct vo *vo, int64_t until_time){}
static void wakeup_event_fd(struct vo *vo){}
#endif
+// VOs which have no special requirements on UI event loops etc. can set the
+// vo_driver.wait_events callback to this (and leave vo_driver.wakeup unset).
+// This function must not be used or called for other purposes.
+void vo_wait_default(struct vo *vo, int64_t until_time)
+{
+ struct vo_internal *in = vo->in;
+
+ pthread_mutex_lock(&in->lock);
+ if (!in->need_wakeup) {
+ struct timespec ts = mp_time_us_to_timespec(until_time);
+ pthread_cond_timedwait(&in->wakeup, &in->lock, &ts);
+ }
+ pthread_mutex_unlock(&in->lock);
+}
+
// Called unlocked.
static void wait_vo(struct vo *vo, int64_t until_time)
{
struct vo_internal *in = vo->in;
if (vo->event_fd >= 0) {
+ // old/deprecated code path
wait_event_fd(vo, until_time);
pthread_mutex_lock(&in->lock);
in->need_wakeup = false;
pthread_mutex_unlock(&in->lock);
- } else if (vo->driver->wait_events) {
- vo->driver->wait_events(vo, until_time);
- pthread_mutex_lock(&in->lock);
- in->need_wakeup = false;
- pthread_mutex_unlock(&in->lock);
} else {
- pthread_mutex_lock(&in->lock);
- if (!in->need_wakeup) {
- struct timespec ts = mp_time_us_to_timespec(until_time);
- pthread_cond_timedwait(&in->wakeup, &in->lock, &ts);
+ if (vo->driver->wait_events) {
+ vo->driver->wait_events(vo, until_time);
+ } else {
+ vo_wait_default(vo, until_time);
}
+ pthread_mutex_lock(&in->lock);
in->need_wakeup = false;
pthread_mutex_unlock(&in->lock);
}