From 8dc7156bc0271965ea1e6768cfc7bbe67cef1876 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 9 Apr 2015 19:30:26 +0200 Subject: vo_opengl_cb: add a function to report vsync time And also let vo.c know of it. Currently, this does not help much, but will facilitate future improvements. --- video/out/vo_opengl_cb.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'video/out/vo_opengl_cb.c') diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c index 551a650d15..a7f7657889 100644 --- a/video/out/vo_opengl_cb.c +++ b/video/out/vo_opengl_cb.c @@ -19,6 +19,7 @@ #include "vo.h" #include "video/mp_image.h" #include "sub/osd.h" +#include "osdep/timer.h" #include "common/global.h" #include "player/client.h" @@ -76,6 +77,7 @@ struct mpv_opengl_cb_context { struct m_config *new_opts_cfg; bool eq_changed; struct mp_csp_equalizer eq; + int64_t recent_flip; // --- All of these can only be accessed from the thread where the host // application's OpenGL context is current - i.e. only while the @@ -342,6 +344,15 @@ int mpv_opengl_cb_render(struct mpv_opengl_cb_context *ctx, int fbo, int vp[4]) return left; } +int mpv_opengl_cb_report_flip(mpv_opengl_cb_context *ctx, int64_t time) +{ + pthread_mutex_lock(&ctx->lock); + ctx->recent_flip = time > 0 ? time : mp_time_us(); + pthread_mutex_unlock(&ctx->lock); + + return 0; +} + static void draw_image(struct vo *vo, mp_image_t *mpi) { struct vo_priv *p = vo->priv; @@ -486,6 +497,16 @@ static int control(struct vo *vo, uint32_t request, void *data) *arg = p->ctx ? &p->ctx->hwdec_info : NULL; return true; } + case VOCTRL_GET_RECENT_FLIP_TIME: { + int r = VO_FALSE; + pthread_mutex_lock(&p->ctx->lock); + if (p->ctx->recent_flip) { + *(int64_t *)data = p->ctx->recent_flip; + r = VO_TRUE; + } + pthread_mutex_unlock(&p->ctx->lock); + return r; + } } return VO_NOTIMPL; -- cgit v1.2.3