From cd94edf94854e86599fff9aea7c9c7442999dbbb Mon Sep 17 00:00:00 2001 From: Olivier Crete Date: Mon, 27 Apr 2015 14:09:27 -0400 Subject: [PATCH] wayland: Use a private queue and free registry proxy Using the global queue is not thread safe and the proxy was leaked --- va/wayland/va_wayland_drm.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/va/wayland/va_wayland_drm.c b/va/wayland/va_wayland_drm.c index d292316..c1acf05 100644 --- a/va/wayland/va_wayland_drm.c +++ b/va/wayland/va_wayland_drm.c @@ -43,6 +43,7 @@ typedef struct va_wayland_drm_context { struct va_wayland_context base; void *handle; + struct wl_event_queue *queue; struct wl_drm *drm; struct wl_registry *registry; void *drm_interface; @@ -126,6 +127,17 @@ va_wayland_drm_destroy(VADisplayContextP pDisplayContext) wl_drm_destroy(wl_drm_ctx->drm); wl_drm_ctx->drm = NULL; } + + if (wl_drm_ctx->registry) { + wl_registry_destroy (wl_drm_ctx->registry); + wl_drm_ctx->registry = NULL; + } + + if (wl_drm_ctx->queue) { + wl_event_queue_destroy (wl_drm_ctx->queue); + wl_drm_ctx->queue = NULL; + } + wl_drm_ctx->is_authenticated = 0; if (wl_drm_ctx->handle) { @@ -200,9 +212,12 @@ va_wayland_drm_create(VADisplayContextP pDisplayContext) if (!wl_drm_ctx->drm_interface) return false; + wl_drm_ctx->queue = wl_display_create_queue (ctx->native_dpy); + wl_drm_ctx->registry = wl_display_get_registry(ctx->native_dpy); + wl_proxy_set_queue ((struct wl_proxy *)wl_drm_ctx->registry, wl_drm_ctx->queue); wl_registry_add_listener(wl_drm_ctx->registry, ®istry_listener, wl_drm_ctx); - wl_display_roundtrip(ctx->native_dpy); + wl_display_roundtrip_queue(ctx->native_dpy, wl_drm_ctx->queue); /* registry_handle_global should have been called by the * wl_display_roundtrip above @@ -212,11 +227,11 @@ va_wayland_drm_create(VADisplayContextP pDisplayContext) return false; wl_drm_add_listener(wl_drm_ctx->drm, &drm_listener, pDisplayContext); - wl_display_roundtrip(ctx->native_dpy); + wl_display_roundtrip_queue(ctx->native_dpy, wl_drm_ctx->queue); if (drm_state->fd < 0) return false; - wl_display_roundtrip(ctx->native_dpy); + wl_display_roundtrip_queue(ctx->native_dpy, wl_drm_ctx->queue); if (!wl_drm_ctx->is_authenticated) return false; return true; -- 1.9.1