From 56eb2b71b8787364238cf80bfb953aba14d55dbf Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 10 Dec 2014 17:00:18 +0100 Subject: vo: fix some nonsense Commit d38bc531 is incorrect: the 50ms queue-ahead value and the flip queue offset have different functions. The latter is about calling flip_page in advance, so the change attempted to show video frames 50ms in advance on all VOs. The change was for vo_opengl_cb, but that can be handled differently. --- video/out/vo.c | 5 ++--- video/out/vo.h | 2 -- video/out/vo_opengl_cb.c | 10 ++++++---- video/out/vo_vdpau.c | 2 -- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/video/out/vo.c b/video/out/vo.c index 710f2f28ce..f6dda92532 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -230,7 +230,6 @@ static struct vo *vo_create(struct mpv_global *global, talloc_steal(vo, log); *vo->in = (struct vo_internal) { .dispatch = mp_dispatch_create(vo), - .flip_queue_offset = VO_DEFAULT_FLIP_QUEUE_OFFSET, }; mp_make_wakeup_pipe(vo->in->wakeup_pipe); mp_dispatch_set_wakeup_fn(vo->in->dispatch, dispatch_wakeup_cb, vo); @@ -484,8 +483,8 @@ bool vo_is_ready_for_frame(struct vo *vo, int64_t next_pts) if (r) { // Don't show the frame too early - it would basically freeze the // display by disallowing OSD redrawing or VO interaction. - // Actually render the frame at earliest 50ms before target time - // (flip_queue_offset is usually VO_DEFAULT_FLIP_QUEUE_OFFSET, 50ms). + // Actually render the frame at earliest 50ms before target time. + next_pts -= (uint64_t)(0.050 * 1e6); next_pts -= in->flip_queue_offset; int64_t now = mp_time_us(); if (next_pts > now) diff --git a/video/out/vo.h b/video/out/vo.h index 8b47d04cfe..fa35f65d13 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -160,8 +160,6 @@ struct voctrl_screenshot_args { // VO does framedrop itself (vo_vdpau). Untimed/encoding VOs never drop. #define VO_CAP_FRAMEDROP 2 -#define VO_DEFAULT_FLIP_QUEUE_OFFSET ((uint64_t)(0.050 * 1e6)) - struct vo; struct osd_state; struct mp_image; diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c index 44ad9e5484..97c50ba489 100644 --- a/video/out/vo_opengl_cb.c +++ b/video/out/vo_opengl_cb.c @@ -53,6 +53,7 @@ struct mpv_opengl_cb_context { // --- Protected by lock mpv_opengl_cb_update_fn update_cb; void *update_cb_ctx; + struct mp_image *waiting_frame; struct mp_image *next_frame; struct mp_image_params img_params; bool reconfigured; @@ -228,7 +229,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) struct vo_priv *p = vo->priv; if (p->ctx) { pthread_mutex_lock(&p->ctx->lock); - mp_image_setrefp(&p->ctx->next_frame, mpi); + mp_image_setrefp(&p->ctx->waiting_frame, mpi); pthread_mutex_unlock(&p->ctx->lock); } talloc_free(mpi); @@ -239,6 +240,9 @@ static void flip_page(struct vo *vo) struct vo_priv *p = vo->priv; if (p->ctx) { pthread_mutex_lock(&p->ctx->lock); + mp_image_unrefp(&p->ctx->next_frame); + p->ctx->next_frame = p->ctx->waiting_frame; + p->ctx->waiting_frame = NULL; if (p->ctx->update_cb) p->ctx->update_cb(p->ctx->update_cb_ctx); pthread_mutex_unlock(&p->ctx->lock); @@ -331,6 +335,7 @@ static void uninit(struct vo *vo) if (p->ctx) { pthread_mutex_lock(&p->ctx->lock); mp_image_unrefp(&p->ctx->next_frame); + mp_image_unrefp(&p->ctx->waiting_frame); p->ctx->img_params = (struct mp_image_params){0}; p->ctx->reconfigured = true; p->ctx->active = NULL; @@ -342,9 +347,6 @@ static int preinit(struct vo *vo) { struct vo_priv *p = vo->priv; p->vo = vo; - // Currently, there's no video timing in the API, and it's questionable - // how API users would make use of it too. - vo_set_flip_queue_offset(vo, 0); return 0; } diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index c1b63345f1..e1795e321f 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -261,8 +261,6 @@ static void resize(struct vo *vo) vc->flip_offset_us = vo->opts->fullscreen ? 1000LL * vc->flip_offset_fs : 1000LL * vc->flip_offset_window; - vc->flip_offset_us += VO_DEFAULT_FLIP_QUEUE_OFFSET; - vo_set_flip_queue_offset(vo, vc->flip_offset_us); if (vc->output_surface_width < vo->dwidth -- cgit v1.2.3