From 1c18c268adeea1d0d78b6981933003a4aa80b484 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Fri, 12 May 2017 15:35:51 +0900 Subject: [PATCH] tpl_wayland_egl_thread: Added tpl_object_t to twe_wl_surf_source to use mutex lock. - committed_buffers(tpl_list_t) wrapped in TPL_OBJECT_LOCK/UNLOCK to ensure thread safety of tpl_list_t. Change-Id: Ia54a71bd4f11a3804a72450faca08ca0c8e63ff5 Signed-off-by: joonbum.ko --- src/tpl_wayland_egl_thread.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 882733d..1dd19c6 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -10,6 +10,7 @@ #include #include "tpl_utils.h" +#include "tpl_internal.h" #include "wayland-egl/wayland-egl-priv.h" #include "tpl_wayland_egl_thread.h" #include "tpl_utils.h" @@ -59,6 +60,7 @@ struct _twe_wl_surf_source { int rotation; tpl_bool_t rotation_capability; tpl_bool_t vblank_done; + tpl_object_t obj; /* for mutex lock */ tpl_list_t *committed_buffers; tdm_client_vblank *vblank; tbm_surface_queue_h tbm_queue; @@ -543,8 +545,11 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, TPL_ERR("Failed to tdm_client_vblank_wait. tdm_err(%d)", tdm_err); } - if (surf_source->committed_buffers) + if (surf_source->committed_buffers) { + TPL_OBJECT_LOCK(&surf_source->obj); __tpl_list_push_back(surf_source->committed_buffers, tbm_surface); + TPL_OBJECT_UNLOCK(&surf_source->obj); + } } static void @@ -615,6 +620,7 @@ _twe_thread_wl_surface_finalize(GSource *source) twe_wl_surf_source *surf_source = (twe_wl_surf_source *)source; if (surf_source->committed_buffers) { + TPL_OBJECT_LOCK(&surf_source->obj); while (!__tpl_list_is_empty(surf_source->committed_buffers)) { tbm_surface_h tbm_surface = (tbm_surface_h)__tpl_list_pop_front( @@ -625,8 +631,11 @@ _twe_thread_wl_surface_finalize(GSource *source) __tpl_list_free(surf_source->committed_buffers, NULL); surf_source->committed_buffers = NULL; + TPL_OBJECT_UNLOCK(&surf_source->obj); } + __tpl_object_fini(&surf_source->obj); + g_source_remove_unix_fd(source, surf_source->tag); close(surf_source->event_fd); @@ -800,6 +809,8 @@ twe_surface_add(twe_thread* thread, source->vblank_done = TPL_TRUE; source->committed_buffers = __tpl_list_alloc(); + __tpl_object_init(&source->obj, TPL_OBJECT_SURFACE, NULL); + wl_egl_window->private = (void *)source; wl_egl_window->resize_callback = (void *)__cb_resize_callback; wl_egl_window->rotate_callback = (void *)__cb_rotate_callback; @@ -928,9 +939,11 @@ __cb_buffer_release_callback(void *data, struct wl_proxy *wl_buffer) TPL_ERR("tbm_surface(%p) tsq_err(%d)", tbm_surface, tsq_err); if (surf_source->committed_buffers) { + TPL_OBJECT_LOCK(&surf_source->obj); __tpl_list_remove_data(surf_source->committed_buffers, (void *)tbm_surface, TPL_FIRST, NULL); + TPL_OBJECT_UNLOCK(&surf_source->obj); } TPL_LOG_T("WL_EGL", "[REL] wl_buffer(%p) tbm_surface(%p) bo(%d)", -- 2.7.4