diff options
author | wm4 <wm4@nowhere> | 2015-04-09 19:30:26 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-04-09 19:30:26 +0200 |
commit | 8dc7156bc0271965ea1e6768cfc7bbe67cef1876 (patch) | |
tree | 3573cd6130ff7b71bf0c4d7f66e4f9ae53200b75 /video | |
parent | 4e8ee522f4df73a74befc093640fdf60a43053ec (diff) | |
download | mpv-8dc7156bc0271965ea1e6768cfc7bbe67cef1876.tar.bz2 mpv-8dc7156bc0271965ea1e6768cfc7bbe67cef1876.tar.xz |
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.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/vo_opengl_cb.c | 21 |
1 files changed, 21 insertions, 0 deletions
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; |