x11 and wayland VOs + backends all have logic that skips drawing frames when the mpv isn't visible for efficiency reasons. This is implemented in each individual VO, but it is useful for the core to be aware of this as well. Currently, the display-sync modes on x11 do not try to be efficient and always render anyways because there is no blocking on the graphics API level if you skip rendering a frame (wayland works here by accident). This means mpv would otherwise blaze through frames which is not what anyone wants. We can instead improve this by implementing the blocking mechanism in the core and using that when appropriate. This commit does not implement that yet, but simply switches the draw_frame to a boolean. Receiving false means that the VO is not drawing frames and it should be treated as if the surface was hidden.
Unified · Split
| @@ -407,8 +407,12 @@ struct vo_driver { · 406 unmodified lines | |||
| 407 | * frame is freed by the caller if the callee did not assume ownership | 407 | * frame is freed by the caller if the callee did not assume ownership |
| 408 | * of the frames, but in any case the callee can still modify the | 408 | * of the frames, but in any case the callee can still modify the |
| 409 | * contained data and references. | 409 | * contained data and references. |
| 410 | * | ||
| 411 | * Return false to signal to the core that rendering is being skipped for | ||
| 412 | * this particular frame. vo.c will sleep for the expected duration of that | ||
| 413 | * frame before advancing forward. | ||
| 410 | */ | 414 | */ |
| 411 | void (*draw_frame)(struct vo *vo, struct vo_frame *frame); | 415 | bool (*draw_frame)(struct vo *vo, struct vo_frame *frame); |
| 412 | 416 | ||
| 413 | /* | 417 | /* |
| 414 | * Blit/Flip buffer to the screen. Must be called after each frame! | 418 | * Blit/Flip buffer to the screen. Must be called after each frame! |
| @@ -111,15 +111,18 @@ static int reconfig(struct vo *vo, struct mp_image_params *params) · 110 unmodified lines | |||
| 111 | return resize(vo); | 111 | return resize(vo); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 114 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 115 | { | 115 | { |
| 116 | struct priv *priv = vo->priv; | 116 | struct priv *priv = vo->priv; |
| 117 | struct mp_image *mpi = frame->current; | 117 | struct mp_image *mpi = frame->current; |
| 118 | if (!mpi) | 118 | if (!mpi) |
| 119 | return; | 119 | goto done; |
| 120 | memcpy_pic(priv->dither_buffer, mpi->planes[0], priv->image_width * depth, priv->image_height, | 120 | memcpy_pic(priv->dither_buffer, mpi->planes[0], priv->image_width * depth, priv->image_height, |
| 121 | priv->image_width * depth, mpi->stride[0]); | 121 | priv->image_width * depth, mpi->stride[0]); |
| 122 | caca_dither_bitmap(priv->canvas, 0, 0, priv->screen_w, priv->screen_h, priv->dither, priv->dither_buffer); | 122 | caca_dither_bitmap(priv->canvas, 0, 0, priv->screen_w, priv->screen_h, priv->dither, priv->dither_buffer); |
| 123 | |||
| 124 | done: | ||
| 125 | return VO_TRUE; | ||
| 123 | } | 126 | } |
| 124 | 127 | ||
| 125 | static void flip_page(struct vo *vo) | 128 | static void flip_page(struct vo *vo) |
| @@ -1003,18 +1003,18 @@ static bool get_video_buffer(d3d_priv *priv, struct mp_image *out) · 1002 unmodified lines | |||
| 1003 | return true; | 1003 | return true; |
| 1004 | } | 1004 | } |
| 1005 | 1005 | ||
| 1006 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 1006 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 1007 | { | 1007 | { |
| 1008 | d3d_priv *priv = vo->priv; | 1008 | d3d_priv *priv = vo->priv; |
| 1009 | if (!priv->d3d_device) | 1009 | if (!priv->d3d_device) |
| 1010 | return; | 1010 | goto done; |
| 1011 | 1011 | ||
| 1012 | struct mp_image buffer; | 1012 | struct mp_image buffer; |
| 1013 | if (!get_video_buffer(priv, &buffer)) | 1013 | if (!get_video_buffer(priv, &buffer)) |
| 1014 | return; | 1014 | goto done; |
| 1015 | 1015 | ||
| 1016 | if (!frame->current) | 1016 | if (!frame->current) |
| 1017 | return; | 1017 | goto done; |
| 1018 | 1018 | ||
| 1019 | mp_image_copy(&buffer, frame->current); | 1019 | mp_image_copy(&buffer, frame->current); |
| 1020 | 1020 | ||
| @@ -1024,6 +1024,9 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 3 unmodified lines | |||
| 1024 | priv->osd_pts = frame->current->pts; | 1024 | priv->osd_pts = frame->current->pts; |
| 1025 | 1025 | ||
| 1026 | d3d_draw_frame(priv); | 1026 | d3d_draw_frame(priv); |
| 1027 | |||
| 1028 | done: | ||
| 1029 | return VO_TRUE; | ||
| 1027 | } | 1030 | } |
| 1028 | 1031 | ||
| 1029 | static mp_image_t *get_window_screenshot(d3d_priv *priv) | 1032 | static mp_image_t *get_window_screenshot(d3d_priv *priv) |
| @@ -592,7 +592,7 @@ done: · 591 unmodified lines | |||
| 592 | return draw; | 592 | return draw; |
| 593 | } | 593 | } |
| 594 | 594 | ||
| 595 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 595 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 596 | { | 596 | { |
| 597 | struct priv *p = vo->priv; | 597 | struct priv *p = vo->priv; |
| 598 | struct vo_wayland_state *wl = vo->wl; | 598 | struct vo_wayland_state *wl = vo->wl; |
| @@ -603,7 +603,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 4 unmodified lines | |||
| 603 | if (!vo_wayland_check_visible(vo)) { | 603 | if (!vo_wayland_check_visible(vo)) { |
| 604 | if (frame->current) | 604 | if (frame->current) |
| 605 | talloc_free(frame); | 605 | talloc_free(frame); |
| 606 | return; | 606 | return VO_FALSE; |
| 607 | } | 607 | } |
| 608 | 608 | ||
| 609 | if (p->destroy_buffers) | 609 | if (p->destroy_buffers) |
| @@ -641,6 +641,8 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 31 unmodified lines | |||
| 641 | p->osd_surface_is_mapped = false; | 641 | p->osd_surface_is_mapped = false; |
| 642 | } | 642 | } |
| 643 | } | 643 | } |
| 644 | |||
| 645 | return VO_TRUE; | ||
| 644 | } | 646 | } |
| 645 | 647 | ||
| 646 | static void flip_page(struct vo *vo) | 648 | static void flip_page(struct vo *vo) |
| @@ -300,13 +300,13 @@ static void swapchain_step(struct vo *vo) · 299 unmodified lines | |||
| 300 | } | 300 | } |
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 303 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 304 | { | 304 | { |
| 305 | struct vo_drm_state *drm = vo->drm; | 305 | struct vo_drm_state *drm = vo->drm; |
| 306 | struct priv *p = vo->priv; | 306 | struct priv *p = vo->priv; |
| 307 | 307 | ||
| 308 | if (!drm->active) | 308 | if (!drm->active) |
| 309 | return; | 309 | goto done; |
| 310 | 310 | ||
| 311 | drm->still = frame->still; | 311 | drm->still = frame->still; |
| 312 | 312 | ||
| @@ -319,6 +319,9 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 6 unmodified lines | |||
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | enqueue_frame(vo, fb); | 321 | enqueue_frame(vo, fb); |
| 322 | |||
| 323 | done: | ||
| 324 | return VO_TRUE; | ||
| 322 | } | 325 | } |
| 323 | 326 | ||
| 324 | static void queue_flip(struct vo *vo, struct drm_frame *frame) | 327 | static void queue_flip(struct vo *vo, struct drm_frame *frame) |
| @@ -70,25 +70,27 @@ static void resize(struct vo *vo) · 69 unmodified lines | |||
| 70 | vo->want_redraw = true; | 70 | vo->want_redraw = true; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 73 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 74 | { | 74 | { |
| 75 | struct gpu_priv *p = vo->priv; | 75 | struct gpu_priv *p = vo->priv; |
| 76 | struct ra_swapchain *sw = p->ctx->swapchain; | 76 | struct ra_swapchain *sw = p->ctx->swapchain; |
| 77 | 77 | ||
| 78 | struct ra_fbo fbo; | 78 | struct ra_fbo fbo; |
| 79 | if (!sw->fns->start_frame(sw, &fbo)) | 79 | if (!sw->fns->start_frame(sw, &fbo)) |
| 80 | return; | 80 | return VO_FALSE; |
| 81 | 81 | ||
| 82 | gl_video_render_frame(p->renderer, frame, &fbo, RENDER_FRAME_DEF); | 82 | gl_video_render_frame(p->renderer, frame, &fbo, RENDER_FRAME_DEF); |
| 83 | if (!sw->fns->submit_frame(sw, frame)) { | 83 | if (!sw->fns->submit_frame(sw, frame)) { |
| 84 | MP_ERR(vo, "Failed presenting frame!\n"); | 84 | MP_ERR(vo, "Failed presenting frame!\n"); |
| 85 | return; | 85 | return VO_FALSE; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | struct mp_image_params *params = gl_video_get_target_params_ptr(p->renderer); | 88 | struct mp_image_params *params = gl_video_get_target_params_ptr(p->renderer); |
| 89 | mp_mutex_lock(&vo->params_mutex); | 89 | mp_mutex_lock(&vo->params_mutex); |
| 90 | vo->target_params = params; | 90 | vo->target_params = params; |
| 91 | mp_mutex_unlock(&vo->params_mutex); | 91 | mp_mutex_unlock(&vo->params_mutex); |
| 92 | |||
| 93 | return VO_TRUE; | ||
| 92 | } | 94 | } |
| 93 | 95 | ||
| 94 | static void flip_page(struct vo *vo) | 96 | static void flip_page(struct vo *vo) |
| @@ -904,7 +904,7 @@ static void update_tm_viz(struct pl_color_map_params *params, · 903 unmodified lines | |||
| 904 | static void update_hook_opts_dynamic(struct priv *p, const struct pl_hook *hook, | 904 | static void update_hook_opts_dynamic(struct priv *p, const struct pl_hook *hook, |
| 905 | const struct mp_image *mpi); | 905 | const struct mp_image *mpi); |
| 906 | 906 | ||
| 907 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 907 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 908 | { | 908 | { |
| 909 | struct priv *p = vo->priv; | 909 | struct priv *p = vo->priv; |
| 910 | pl_options pars = p->pars; | 910 | pl_options pars = p->pars; |
| @@ -1029,7 +1029,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 118 unmodified lines | |||
| 1029 | #endif | 1029 | #endif |
| 1030 | pl_queue_update(p->queue, NULL, &qparams); | 1030 | pl_queue_update(p->queue, NULL, &qparams); |
| 1031 | } | 1031 | } |
| 1032 | return; | 1032 | return VO_FALSE; |
| 1033 | } | 1033 | } |
| 1034 | 1034 | ||
| 1035 | bool valid = false; | 1035 | bool valid = false; |
| @@ -1173,6 +1173,7 @@ done: · 137 unmodified lines | |||
| 1173 | 1173 | ||
| 1174 | pl_gpu_flush(gpu); | 1174 | pl_gpu_flush(gpu); |
| 1175 | p->frame_pending = true; | 1175 | p->frame_pending = true; |
| 1176 | return VO_TRUE; | ||
| 1176 | } | 1177 | } |
| 1177 | 1178 | ||
| 1178 | static void flip_page(struct vo *vo) | 1179 | static void flip_page(struct vo *vo) |
| @@ -90,16 +90,19 @@ static int reconfig(struct vo *vo, struct mp_image_params *params) · 89 unmodified lines | |||
| 90 | return 0; | 90 | return 0; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 93 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 94 | { | 94 | { |
| 95 | struct priv *p = vo->priv; | 95 | struct priv *p = vo->priv; |
| 96 | if (!frame->current) | 96 | if (!frame->current) |
| 97 | return; | 97 | goto done; |
| 98 | 98 | ||
| 99 | p->current = frame->current; | 99 | p->current = frame->current; |
| 100 | 100 | ||
| 101 | struct mp_osd_res dim = osd_res_from_image_params(vo->params); | 101 | struct mp_osd_res dim = osd_res_from_image_params(vo->params); |
| 102 | osd_draw_on_image(vo->osd, dim, frame->current->pts, OSD_DRAW_SUB_ONLY, p->current); | 102 | osd_draw_on_image(vo->osd, dim, frame->current->pts, OSD_DRAW_SUB_ONLY, p->current); |
| 103 | |||
| 104 | done: | ||
| 105 | return VO_TRUE; | ||
| 103 | } | 106 | } |
| 104 | 107 | ||
| 105 | static void flip_page(struct vo *vo) | 108 | static void flip_page(struct vo *vo) |
| @@ -239,7 +239,7 @@ static int create_shm(struct vo *vo) · 238 unmodified lines | |||
| 239 | #endif | 239 | #endif |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 242 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 243 | { | 243 | { |
| 244 | struct priv *p = vo->priv; | 244 | struct priv *p = vo->priv; |
| 245 | mp_image_t *mpi = NULL; | 245 | mp_image_t *mpi = NULL; |
| @@ -273,7 +273,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 27 unmodified lines | |||
| 273 | 273 | ||
| 274 | 274 | ||
| 275 | if (p->opts.use_shm && !create_shm(vo)) | 275 | if (p->opts.use_shm && !create_shm(vo)) |
| 276 | return; | 276 | goto done; |
| 277 | 277 | ||
| 278 | memcpy_pic(p->buffer, p->frame->planes[0], p->width * BYTES_PER_PX, | 278 | memcpy_pic(p->buffer, p->frame->planes[0], p->width * BYTES_PER_PX, |
| 279 | p->height, p->width * BYTES_PER_PX, p->frame->stride[0]); | 279 | p->height, p->width * BYTES_PER_PX, p->frame->stride[0]); |
| @@ -282,6 +282,9 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 2 unmodified lines | |||
| 282 | av_base64_encode(p->output, p->output_size, p->buffer, p->buffer_size); | 282 | av_base64_encode(p->output, p->output_size, p->buffer, p->buffer_size); |
| 283 | 283 | ||
| 284 | talloc_free(mpi); | 284 | talloc_free(mpi); |
| 285 | |||
| 286 | done: | ||
| 287 | return VO_TRUE; | ||
| 285 | } | 288 | } |
| 286 | 289 | ||
| 287 | static void flip_page(struct vo *vo) | 290 | static void flip_page(struct vo *vo) |
| @@ -182,7 +182,7 @@ static int query_format(struct vo *vo, int format) · 181 unmodified lines | |||
| 182 | return 0; | 182 | return 0; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | static void draw_frame(struct vo *vo, struct vo_frame *voframe) | 185 | static bool draw_frame(struct vo *vo, struct vo_frame *voframe) |
| 186 | { | 186 | { |
| 187 | struct priv *vc = vo->priv; | 187 | struct priv *vc = vo->priv; |
| 188 | struct encoder_context *enc = vc->enc; | 188 | struct encoder_context *enc = vc->enc; |
| @@ -190,7 +190,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *voframe) · 1 unmodified line | |||
| 190 | AVCodecContext *avc = enc->encoder; | 190 | AVCodecContext *avc = enc->encoder; |
| 191 | 191 | ||
| 192 | if (voframe->redraw || voframe->repeat || voframe->num_frames < 1) | 192 | if (voframe->redraw || voframe->repeat || voframe->num_frames < 1) |
| 193 | return; | 193 | goto done; |
| 194 | 194 | ||
| 195 | struct mp_image *mpi = voframe->frames[0]; | 195 | struct mp_image *mpi = voframe->frames[0]; |
| 196 | 196 | ||
| @@ -198,7 +198,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *voframe) · 1 unmodified line | |||
| 198 | osd_draw_on_image(vo->osd, dim, mpi->pts, OSD_DRAW_SUB_ONLY, mpi); | 198 | osd_draw_on_image(vo->osd, dim, mpi->pts, OSD_DRAW_SUB_ONLY, mpi); |
| 199 | 199 | ||
| 200 | if (vc->shutdown) | 200 | if (vc->shutdown) |
| 201 | return; | 201 | goto done; |
| 202 | 202 | ||
| 203 | // Lock for shared timestamp fields. | 203 | // Lock for shared timestamp fields. |
| 204 | mp_mutex_lock(&ectx->lock); | 204 | mp_mutex_lock(&ectx->lock); |
| @@ -241,6 +241,9 @@ static void draw_frame(struct vo *vo, struct vo_frame *voframe) · 36 unmodified lines | |||
| 241 | frame->quality = avc->global_quality; | 241 | frame->quality = avc->global_quality; |
| 242 | encoder_encode(enc, frame); | 242 | encoder_encode(enc, frame); |
| 243 | av_frame_free(&frame); | 243 | av_frame_free(&frame); |
| 244 | |||
| 245 | done: | ||
| 246 | return VO_TRUE; | ||
| 244 | } | 247 | } |
| 245 | 248 | ||
| 246 | static void flip_page(struct vo *vo) | 249 | static void flip_page(struct vo *vo) |
| @@ -485,7 +485,7 @@ int mpv_render_context_get_info(mpv_render_context *ctx, · 484 unmodified lines | |||
| 485 | return res; | 485 | return res; |
| 486 | } | 486 | } |
| 487 | 487 | ||
| 488 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 488 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 489 | { | 489 | { |
| 490 | struct vo_priv *p = vo->priv; | 490 | struct vo_priv *p = vo->priv; |
| 491 | struct mpv_render_context *ctx = p->ctx; | 491 | struct mpv_render_context *ctx = p->ctx; |
| @@ -498,6 +498,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 6 unmodified lines | |||
| 498 | mp_mutex_unlock(&ctx->lock); | 498 | mp_mutex_unlock(&ctx->lock); |
| 499 | 499 | ||
| 500 | update(ctx); | 500 | update(ctx); |
| 501 | return VO_TRUE; | ||
| 501 | } | 502 | } |
| 502 | 503 | ||
| 503 | static void flip_page(struct vo *vo) | 504 | static void flip_page(struct vo *vo) |
| @@ -76,7 +76,7 @@ static void flip_page(struct vo *vo) · 75 unmodified lines | |||
| 76 | mp_image_unrefp(&p->next_image); | 76 | mp_image_unrefp(&p->next_image); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 79 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 80 | { | 80 | { |
| 81 | struct priv *p = vo->priv; | 81 | struct priv *p = vo->priv; |
| 82 | 82 | ||
| @@ -86,6 +86,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 3 unmodified lines | |||
| 86 | 86 | ||
| 87 | talloc_free(p->next_image); | 87 | talloc_free(p->next_image); |
| 88 | p->next_image = mpi; | 88 | p->next_image = mpi; |
| 89 | return VO_TRUE; | ||
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | static int query_format(struct vo *vo, int format) | 92 | static int query_format(struct vo *vo, int format) |
| @@ -32,8 +32,9 @@ struct priv { · 31 unmodified lines | |||
| 32 | double cfg_fps; | 32 | double cfg_fps; |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 35 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 36 | { | 36 | { |
| 37 | return VO_TRUE; | ||
| 37 | } | 38 | } |
| 38 | 39 | ||
| 39 | static void flip_page(struct vo *vo) | 40 | static void flip_page(struct vo *vo) |
| @@ -879,7 +879,7 @@ static int query_format(struct vo *vo, int format) · 878 unmodified lines | |||
| 879 | return 0; | 879 | return 0; |
| 880 | } | 880 | } |
| 881 | 881 | ||
| 882 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 882 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 883 | { | 883 | { |
| 884 | struct priv *vc = vo->priv; | 884 | struct priv *vc = vo->priv; |
| 885 | 885 | ||
| @@ -894,7 +894,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 8 unmodified lines | |||
| 894 | 894 | ||
| 895 | mp_image_t texmpi; | 895 | mp_image_t texmpi; |
| 896 | if (!lock_texture(vo, &texmpi)) | 896 | if (!lock_texture(vo, &texmpi)) |
| 897 | return; | 897 | goto done; |
| 898 | 898 | ||
| 899 | mp_image_copy(&texmpi, frame->current); | 899 | mp_image_copy(&texmpi, frame->current); |
| 900 | 900 | ||
| @@ -914,6 +914,9 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 13 unmodified lines | |||
| 914 | SDL_RenderCopy(vc->renderer, vc->tex, &src, &dst); | 914 | SDL_RenderCopy(vc->renderer, vc->tex, &src, &dst); |
| 915 | 915 | ||
| 916 | draw_osd(vo); | 916 | draw_osd(vo); |
| 917 | |||
| 918 | done: | ||
| 919 | return VO_TRUE; | ||
| 917 | } | 920 | } |
| 918 | 921 | ||
| 919 | static struct mp_image *get_window_screenshot(struct vo *vo) | 922 | static struct mp_image *get_window_screenshot(struct vo *vo) |
| @@ -378,7 +378,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params) · 377 unmodified lines | |||
| 378 | return ret; | 378 | return ret; |
| 379 | } | 379 | } |
| 380 | 380 | ||
| 381 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 381 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 382 | { | 382 | { |
| 383 | struct priv *priv = vo->priv; | 383 | struct priv *priv = vo->priv; |
| 384 | SIXELSTATUS status; | 384 | SIXELSTATUS status; |
| @@ -391,7 +391,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 6 unmodified lines | |||
| 391 | bool resized = false; | 391 | bool resized = false; |
| 392 | update_canvas_dimensions(vo); | 392 | update_canvas_dimensions(vo); |
| 393 | if (!priv->canvas_ok) | 393 | if (!priv->canvas_ok) |
| 394 | return; | 394 | goto done; |
| 395 | 395 | ||
| 396 | if (prev_rows != priv->num_rows || prev_cols != priv->num_cols || | 396 | if (prev_rows != priv->num_rows || prev_cols != priv->num_cols || |
| 397 | prev_width != vo->dwidth || prev_height != vo->dheight) | 397 | prev_width != vo->dwidth || prev_height != vo->dheight) |
| @@ -409,7 +409,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 11 unmodified lines | |||
| 409 | if (frame->repeat && !frame->redraw && !resized) { | 409 | if (frame->repeat && !frame->redraw && !resized) { |
| 410 | // Frame is repeated, and no need to update OSD either | 410 | // Frame is repeated, and no need to update OSD either |
| 411 | priv->skip_frame_draw = true; | 411 | priv->skip_frame_draw = true; |
| 412 | return; | 412 | goto done; |
| 413 | } else { | 413 | } else { |
| 414 | // Either frame is new, or OSD has to be redrawn | 414 | // Either frame is new, or OSD has to be redrawn |
| 415 | priv->skip_frame_draw = false; | 415 | priv->skip_frame_draw = false; |
| @@ -457,6 +457,9 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 41 unmodified lines | |||
| 457 | 457 | ||
| 458 | if (mpi) | 458 | if (mpi) |
| 459 | talloc_free(mpi); | 459 | talloc_free(mpi); |
| 460 | |||
| 461 | done: | ||
| 462 | return VO_TRUE; | ||
| 460 | } | 463 | } |
| 461 | 464 | ||
| 462 | static void flip_page(struct vo *vo) | 465 | static void flip_page(struct vo *vo) |
| @@ -253,14 +253,17 @@ static int reconfig(struct vo *vo, struct mp_image_params *params) · 252 unmodified lines | |||
| 253 | return 0; | 253 | return 0; |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 256 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 257 | { | 257 | { |
| 258 | struct priv *p = vo->priv; | 258 | struct priv *p = vo->priv; |
| 259 | struct mp_image *src = frame->current; | 259 | struct mp_image *src = frame->current; |
| 260 | if (!src) | 260 | if (!src) |
| 261 | return; | 261 | goto done; |
| 262 | // XXX: pan, crop etc. | 262 | // XXX: pan, crop etc. |
| 263 | mp_sws_scale(p->sws, p->frame, src); | 263 | mp_sws_scale(p->sws, p->frame, src); |
| 264 | |||
| 265 | done: | ||
| 266 | return VO_TRUE; | ||
| 264 | } | 267 | } |
| 265 | 268 | ||
| 266 | static void flip_page(struct vo *vo) | 269 | static void flip_page(struct vo *vo) |
| @@ -555,7 +555,7 @@ static void get_vsync(struct vo *vo, struct vo_vsync_info *info) · 554 unmodified lines | |||
| 555 | present_sync_get_info(x11->present, info); | 555 | present_sync_get_info(x11->present, info); |
| 556 | } | 556 | } |
| 557 | 557 | ||
| 558 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 558 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 559 | { | 559 | { |
| 560 | struct priv *p = vo->priv; | 560 | struct priv *p = vo->priv; |
| 561 | struct mp_image *mpi = frame->current; | 561 | struct mp_image *mpi = frame->current; |
| @@ -564,7 +564,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 2 unmodified lines | |||
| 564 | struct mp_image *dst = p->swdec_surfaces[p->output_surface]; | 564 | struct mp_image *dst = p->swdec_surfaces[p->output_surface]; |
| 565 | if (!dst || va_surface_upload(p, dst, mpi) < 0) { | 565 | if (!dst || va_surface_upload(p, dst, mpi) < 0) { |
| 566 | MP_WARN(vo, "Could not upload surface.\n"); | 566 | MP_WARN(vo, "Could not upload surface.\n"); |
| 567 | return; | 567 | goto done; |
| 568 | } | 568 | } |
| 569 | mp_image_copy_attributes(dst, mpi); | 569 | mp_image_copy_attributes(dst, mpi); |
| 570 | mpi = dst; | 570 | mpi = dst; |
| @@ -573,6 +573,9 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 2 unmodified lines | |||
| 573 | p->output_surfaces[p->output_surface] = mpi; | 573 | p->output_surfaces[p->output_surface] = mpi; |
| 574 | 574 | ||
| 575 | draw_osd(vo); | 575 | draw_osd(vo); |
| 576 | |||
| 577 | done: | ||
| 578 | return VO_TRUE; | ||
| 576 | } | 579 | } |
| 577 | 580 | ||
| 578 | static void free_subpicture(struct priv *p, struct vaapi_osd_image *img) | 581 | static void free_subpicture(struct priv *p, struct vaapi_osd_image *img) |
| @@ -870,7 +870,7 @@ drop: · 869 unmodified lines | |||
| 870 | vo_increment_drop_count(vo, 1); | 870 | vo_increment_drop_count(vo, 1); |
| 871 | } | 871 | } |
| 872 | 872 | ||
| 873 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 873 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 874 | { | 874 | { |
| 875 | struct vdpctx *vc = vo->priv; | 875 | struct vdpctx *vc = vo->priv; |
| 876 | 876 | ||
| @@ -893,6 +893,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 16 unmodified lines | |||
| 893 | video_to_output_surface(vo, vc->current_image); | 893 | video_to_output_surface(vo, vc->current_image); |
| 894 | draw_osd(vo); | 894 | draw_osd(vo); |
| 895 | } | 895 | } |
| 896 | return VO_TRUE; | ||
| 896 | } | 897 | } |
| 897 | 898 | ||
| 898 | // warning: the size and pixel format of surface must match that of the | 899 | // warning: the size and pixel format of surface must match that of the |
| @@ -239,7 +239,7 @@ static int control(struct vo *vo, uint32_t request, void *data) · 238 unmodified lines | |||
| 239 | return ret; | 239 | return ret; |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 242 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 243 | { | 243 | { |
| 244 | struct priv *p = vo->priv; | 244 | struct priv *p = vo->priv; |
| 245 | struct vo_wayland_state *wl = vo->wl; | 245 | struct vo_wayland_state *wl = vo->wl; |
| @@ -248,7 +248,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 2 unmodified lines | |||
| 248 | 248 | ||
| 249 | bool render = vo_wayland_check_visible(vo); | 249 | bool render = vo_wayland_check_visible(vo); |
| 250 | if (!render) | 250 | if (!render) |
| 251 | return; | 251 | return VO_FALSE; |
| 252 | 252 | ||
| 253 | buf = p->free_buffers; | 253 | buf = p->free_buffers; |
| 254 | if (buf) { | 254 | if (buf) { |
| @@ -257,7 +257,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 2 unmodified lines | |||
| 257 | buf = buffer_create(vo, vo->dwidth, vo->dheight); | 257 | buf = buffer_create(vo, vo->dwidth, vo->dheight); |
| 258 | if (!buf) { | 258 | if (!buf) { |
| 259 | wl_surface_attach(wl->surface, NULL, 0, 0); | 259 | wl_surface_attach(wl->surface, NULL, 0, 0); |
| 260 | return; | 260 | goto done; |
| 261 | } | 261 | } |
| 262 | } | 262 | } |
| 263 | if (src) { | 263 | if (src) { |
| @@ -289,6 +289,9 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 25 unmodified lines | |||
| 289 | osd_draw_on_image(vo->osd, p->osd, 0, 0, &buf->mpi); | 289 | osd_draw_on_image(vo->osd, p->osd, 0, 0, &buf->mpi); |
| 290 | } | 290 | } |
| 291 | wl_surface_attach(wl->surface, buf->buffer, 0, 0); | 291 | wl_surface_attach(wl->surface, buf->buffer, 0, 0); |
| 292 | |||
| 293 | done: | ||
| 294 | return VO_TRUE; | ||
| 292 | } | 295 | } |
| 293 | 296 | ||
| 294 | static void flip_page(struct vo *vo) | 297 | static void flip_page(struct vo *vo) |
| @@ -327,14 +327,14 @@ static void get_vsync(struct vo *vo, struct vo_vsync_info *info) · 326 unmodified lines | |||
| 327 | present_sync_get_info(x11->present, info); | 327 | present_sync_get_info(x11->present, info); |
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 330 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 331 | { | 331 | { |
| 332 | struct priv *p = vo->priv; | 332 | struct priv *p = vo->priv; |
| 333 | 333 | ||
| 334 | wait_for_completion(vo, 1); | 334 | wait_for_completion(vo, 1); |
| 335 | bool render = vo_x11_check_visible(vo); | 335 | bool render = vo_x11_check_visible(vo); |
| 336 | if (!render) | 336 | if (!render) |
| 337 | return; | 337 | return VO_FALSE; |
| 338 | 338 | ||
| 339 | struct mp_image *img = &p->mp_ximages[p->current_buf]; | 339 | struct mp_image *img = &p->mp_ximages[p->current_buf]; |
| 340 | 340 | ||
| @@ -359,6 +359,8 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 18 unmodified lines | |||
| 359 | 359 | ||
| 360 | if (frame->current != p->original_image) | 360 | if (frame->current != p->original_image) |
| 361 | p->original_image = frame->current; | 361 | p->original_image = frame->current; |
| 362 | |||
| 363 | return VO_TRUE; | ||
| 362 | } | 364 | } |
| 363 | 365 | ||
| 364 | static int query_format(struct vo *vo, int format) | 366 | static int query_format(struct vo *vo, int format) |
| @@ -708,14 +708,14 @@ static void get_vsync(struct vo *vo, struct vo_vsync_info *info) · 707 unmodified lines | |||
| 708 | present_sync_get_info(x11->present, info); | 708 | present_sync_get_info(x11->present, info); |
| 709 | } | 709 | } |
| 710 | 710 | ||
| 711 | static void draw_frame(struct vo *vo, struct vo_frame *frame) | 711 | static bool draw_frame(struct vo *vo, struct vo_frame *frame) |
| 712 | { | 712 | { |
| 713 | struct xvctx *ctx = vo->priv; | 713 | struct xvctx *ctx = vo->priv; |
| 714 | 714 | ||
| 715 | wait_for_completion(vo, ctx->num_buffers - 1); | 715 | wait_for_completion(vo, ctx->num_buffers - 1); |
| 716 | bool render = vo_x11_check_visible(vo); | 716 | bool render = vo_x11_check_visible(vo); |
| 717 | if (!render) | 717 | if (!render) |
| 718 | return; | 718 | return VO_FALSE; |
| 719 | 719 | ||
| 720 | struct mp_image xv_buffer = get_xv_buffer(vo, ctx->current_buf); | 720 | struct mp_image xv_buffer = get_xv_buffer(vo, ctx->current_buf); |
| 721 | if (frame->current) { | 721 | if (frame->current) { |
| @@ -729,6 +729,8 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) · 7 unmodified lines | |||
| 729 | 729 | ||
| 730 | if (frame->current != ctx->original_image) | 730 | if (frame->current != ctx->original_image) |
| 731 | ctx->original_image = frame->current; | 731 | ctx->original_image = frame->current; |
| 732 | |||
| 733 | return VO_TRUE; | ||
| 732 | } | 734 | } |
| 733 | 735 | ||
| 734 | static int query_format(struct vo *vo, int format) | 736 | static int query_format(struct vo *vo, int format) |