Skip to content

Commit 554684d

Browse files
committed
wayland: switch to separate queue for wp_image_description_v1
f0883cd fixed the issue that `set_color_management` would be called on every frame, however it didn't fix the problem that the first frame would have no image description set. Due to a lack of blocking here, events would end up happening in the following order: -> wl_surface.commit() -> wp_color_management_surface_v1.set_image_description(...) -> wl_surface.commit() -> wp_color_management_surface_v1.set_image_description(...) This would mean setting image description would always lag behind by 1 surface commit. This would effectively result in the first frame never having any image description set. Fix this by blocking until the compositor processes what's in the queue and responds with the ready event so we can set the image description.
1 parent 98847f5 commit 554684d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

video/out/wayland_common.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,6 +2129,7 @@ static void image_description_failed(void *data, struct wp_image_description_v1
21292129
uint32_t cause, const char *msg)
21302130
{
21312131
struct vo_wayland_state *wl = data;
2132+
wl->image_desc_done = true;
21322133
MP_VERBOSE(wl, "Image description failed: %d, %s\n", cause, msg);
21332134
wp_color_management_surface_v1_unset_image_description(wl->color_surface);
21342135
wp_image_description_v1_destroy(image_description);
@@ -2138,6 +2139,7 @@ static void image_description_ready(void *data, struct wp_image_description_v1 *
21382139
uint32_t identity)
21392140
{
21402141
struct vo_wayland_state *wl = data;
2142+
wl->image_desc_done = true;
21412143
wp_color_management_surface_v1_set_image_description(wl->color_surface, image_description, 0);
21422144
MP_TRACE(wl, "Image description set on color surface.\n");
21432145
wp_image_description_v1_destroy(image_description);
@@ -3540,8 +3542,20 @@ static void set_color_management(struct vo_wayland_state *wl)
35403542
wp_image_description_creator_params_v1_set_max_cll(image_creator_params, lrintf(hdr.max_cll));
35413543
wp_image_description_creator_params_v1_set_max_fall(image_creator_params, lrintf(hdr.max_fall));
35423544
}
3545+
35433546
struct wp_image_description_v1 *image_description = wp_image_description_creator_params_v1_create(image_creator_params);
3547+
struct wl_event_queue *cm_queue = wl_display_create_queue(wl->display);
3548+
wl_proxy_set_queue((struct wl_proxy *)image_description, cm_queue);
3549+
wl->image_desc_done = false;
35443550
wp_image_description_v1_add_listener(image_description, &image_description_listener, wl);
3551+
3552+
/* Block here to ensure the compositor is ready to receive the
3553+
* image_description before we do anything else. */
3554+
while (wl->image_desc_done == false)
3555+
if (wl_display_dispatch_queue(wl->display, cm_queue) < 0)
3556+
break;
3557+
3558+
wl_event_queue_destroy(cm_queue);
35453559
#endif
35463560
}
35473561

video/out/wayland_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct vo_wayland_state {
106106
void *icc_file;
107107
uint32_t icc_size;
108108
struct pl_color_space preferred_csp;
109+
bool image_desc_done;
109110

110111
/* color-representation */
111112
struct wp_color_representation_manager_v1 *color_representation_manager;

0 commit comments

Comments
 (0)