summaryrefslogtreecommitdiff
path: root/va/wayland
diff options
context:
space:
mode:
authorPhilipp Kerling <pkerling@casix.org>2017-08-16 12:37:27 +0200
committerXiang, Haihao <haihao.xiang@intel.com>2017-08-17 11:06:29 +0800
commit9ca99eb84cdb6ea638af567f6074c53fa51a416c (patch)
treeb3fa142d0459da7fbbf0a40a34a611458f7f3d12 /va/wayland
parent62affbb44b771931a8895fc7428df23afb888750 (diff)
downloadlibva-9ca99eb84cdb6ea638af567f6074c53fa51a416c.tar.gz
wayland: Add wl_drm listener immediately upon bind
Events on wl_drm could get lost if the listener is bound only after the roundtrip is complete. While it is correct that to get all wl_drm events at most two roundtrips are required, in fact one roundtrip may be enough if another thread flushes and reads from the connection in parallel to the initial libva wl_registry roundtrip. It is thus too late to call wl_drm_add_listener after the roundtrip. Fixes: #101
Diffstat (limited to 'va/wayland')
-rw-r--r--va/wayland/va_wayland_drm.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/va/wayland/va_wayland_drm.c b/va/wayland/va_wayland_drm.c
index 552f243..d8c4ec9 100644
--- a/va/wayland/va_wayland_drm.c
+++ b/va/wayland/va_wayland_drm.c
@@ -154,7 +154,8 @@ registry_handle_global(
uint32_t version
)
{
- struct va_wayland_drm_context *wl_drm_ctx = data;
+ VADisplayContextP const pDisplayContext = data;
+ struct va_wayland_drm_context * const wl_drm_ctx = pDisplayContext->opaque;
if (strcmp(interface, "wl_drm") == 0) {
/* bind to at most version 2, but also support version 1 if
@@ -164,6 +165,13 @@ registry_handle_global(
wl_drm_ctx->drm =
wl_registry_bind(wl_drm_ctx->registry, name, &wl_drm_interface,
(version < 2) ? version : 2);
+
+ if (wl_drm_ctx->drm
+ && wl_drm_add_listener(wl_drm_ctx->drm, &drm_listener, pDisplayContext) != 0) {
+ va_wayland_error("could not add listener to wl_drm");
+ wl_drm_destroy(wl_drm_ctx->drm);
+ wl_drm_ctx->drm = NULL;
+ }
}
}
@@ -259,7 +267,7 @@ va_wayland_drm_create(VADisplayContextP pDisplayContext)
va_wayland_error("could not create wl_registry");
goto end;
}
- if (wl_registry_add_listener(wl_drm_ctx->registry, &registry_listener, wl_drm_ctx) != 0) {
+ if (wl_registry_add_listener(wl_drm_ctx->registry, &registry_listener, pDisplayContext) != 0) {
va_wayland_error("could not add listener to wl_registry");
goto end;
}
@@ -273,11 +281,6 @@ va_wayland_drm_create(VADisplayContextP pDisplayContext)
/* Do not print an error, the compositor might just not support wl_drm */
if (!wl_drm_ctx->drm)
goto end;
-
- if (wl_drm_add_listener(wl_drm_ctx->drm, &drm_listener, pDisplayContext) != 0) {
- va_wayland_error("could not add listener to wl_drm");
- goto end;
- }
if (!wayland_roundtrip_queue(ctx->native_dpy, wl_drm_ctx->queue))
goto end;
if (drm_state->fd < 0) {