mirror of
https://github.com/mpv-player/mpv
synced 2024-12-18 12:55:16 +00:00
vo_libmpv: adjust redraw handling to new API semantics
In MPV_RENDER_PARAM_ADVANCED_CONTROL mode, a simple update callback does not necessarily make the API user redraw. So handle it differently. For one, setting vo->want_redraw already uses the "normal" redraw path, which will call draw_frame() and set next_frame. Then there are redraws trigered by mpv_render_context_set_parameter(), which are on the render thread, and would require a separate mechanism. I decided this is not really a good idea, since it's not even clear that setting an arbitrary parameter should redraw. Also this could trigger an unbounded number of redraws. The user can trigger redraws manually if really needed, depending on the parameter that's being set. If we really wanted vo_libmpv to do this, we could add a new flag like need_redraw, which would be 4 lines of code or so.
This commit is contained in:
parent
44f00a1f58
commit
36565c099d
@ -427,15 +427,7 @@ uint64_t mpv_render_context_update(mpv_render_context *ctx)
|
||||
int mpv_render_context_set_parameter(mpv_render_context *ctx,
|
||||
mpv_render_param param)
|
||||
{
|
||||
int err = ctx->renderer->fns->set_parameter(ctx->renderer, param);
|
||||
if (err >= 0) {
|
||||
// Might need to redraw.
|
||||
pthread_mutex_lock(&ctx->lock);
|
||||
if (ctx->vo)
|
||||
update(ctx);
|
||||
pthread_mutex_unlock(&ctx->lock);
|
||||
}
|
||||
return err;
|
||||
return ctx->renderer->fns->set_parameter(ctx->renderer, param);
|
||||
}
|
||||
|
||||
static void draw_frame(struct vo *vo, struct vo_frame *frame)
|
||||
@ -530,7 +522,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
forget_frames(ctx, false);
|
||||
ctx->need_reset = true;
|
||||
pthread_mutex_unlock(&ctx->lock);
|
||||
update(ctx);
|
||||
vo->want_redraw = true;
|
||||
return VO_TRUE;
|
||||
case VOCTRL_PAUSE:
|
||||
vo->want_redraw = true;
|
||||
@ -542,13 +534,13 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||
pthread_mutex_lock(&ctx->lock);
|
||||
ctx->need_resize = true;
|
||||
pthread_mutex_unlock(&ctx->lock);
|
||||
update(ctx);
|
||||
vo->want_redraw = true;
|
||||
return VO_TRUE;
|
||||
case VOCTRL_UPDATE_RENDER_OPTS:
|
||||
pthread_mutex_lock(&ctx->lock);
|
||||
ctx->need_update_external = true;
|
||||
pthread_mutex_unlock(&ctx->lock);
|
||||
update(ctx);
|
||||
vo->want_redraw = true;
|
||||
return VO_TRUE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user