From b7c050ba63dc9f6940a65798211e4d6742b27b31 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Tue, 16 Jan 2018 15:36:58 +0900 Subject: [PATCH] tpl_wayland_egl_thread: Changed to use GMutex instead of tpl_object of the disp_source. Change-Id: Ieec00366d2084cfb9b77ed518bac7c3fb8c7d1b2 Signed-off-by: joonbum.ko --- src/tpl_wayland_egl_thread.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 6c4f1ef..1a69167 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -75,7 +75,7 @@ struct _twe_wl_disp_source { tpl_bool_t prepared; twe_del_source *disp_del_source; twe_thread *thread; - tpl_object_t obj; + GMutex wl_event_mutex; /* TODO : surface list */ }; @@ -634,7 +634,7 @@ _twe_thread_wl_disp_dispatch(GSource *source, GSourceFunc cb, gpointer data) return G_SOURCE_REMOVE; } - TPL_OBJECT_LOCK(&disp_source->obj); + g_mutex_lock(&disp_source->wl_event_mutex); if (disp_source->gfd.revents & G_IO_IN) { if (wl_display_dispatch_queue_pending(disp_source->disp, disp_source->ev_queue) == -1) { @@ -643,7 +643,7 @@ _twe_thread_wl_disp_dispatch(GSource *source, GSourceFunc cb, gpointer data) } wl_display_flush(disp_source->disp); - TPL_OBJECT_UNLOCK(&disp_source->obj); + g_mutex_unlock(&disp_source->wl_event_mutex); return G_SOURCE_CONTINUE; } @@ -651,11 +651,7 @@ _twe_thread_wl_disp_dispatch(GSource *source, GSourceFunc cb, gpointer data) static void _twe_thread_wl_disp_finalize(GSource *source) { - twe_wl_disp_source *disp_source = (twe_wl_disp_source *)source; - - TPL_LOG_T(BACKEND, "finalize| disp_source(%p)", disp_source); - - __tpl_object_fini(&disp_source->obj); + TPL_LOG_T(BACKEND, "finalize| disp_source(%p)", source); return; } @@ -917,7 +913,7 @@ _twe_thread_wl_disp_source_destroy(void *source) } g_mutex_lock(&_twe_ctx->thread_mutex); - TPL_OBJECT_LOCK(&disp_source->obj); + g_mutex_lock(&disp_source->wl_event_mutex); /* If disp_source is in prepared state, cancel it */ if (disp_source->prepared) { @@ -931,11 +927,13 @@ _twe_thread_wl_disp_source_destroy(void *source) } wl_event_queue_destroy(disp_source->ev_queue); - TPL_OBJECT_UNLOCK(&disp_source->obj); + g_mutex_unlock(&disp_source->wl_event_mutex); TPL_LOG_T(BACKEND, "[DEL] twe_display(%p) wl_display(%p)", disp_source, disp_source->disp); + g_mutex_clear(&disp_source->wl_event_mutex); + g_source_remove_poll(&disp_source->gsource, &disp_source->gfd); g_source_destroy(&disp_source->gsource); g_source_unref(&disp_source->gsource); @@ -981,7 +979,7 @@ twe_display_add(twe_thread* thread, source->gfd.fd = wl_display_get_fd(display); source->gfd.events = G_IO_IN | G_IO_ERR; source->gfd.revents = 0; - __tpl_object_init(&source->obj, TPL_OBJECT_DISPLAY, NULL); + g_mutex_init(&source->wl_event_mutex); if (backend == TPL_BACKEND_WAYLAND_VULKAN_WSI || backend == TPL_BACKEND_WAYLAND_VULKAN_WSI_THREAD) { @@ -1062,7 +1060,9 @@ twe_display_lock(twe_display_h display) return TPL_ERROR_INVALID_PARAMETER; } - return TPL_OBJECT_LOCK(&disp_source->obj); + g_mutex_lock(&disp_source->wl_event_mutex); + + return TPL_ERROR_NONE; } void @@ -1074,7 +1074,7 @@ twe_display_unlock(twe_display_h display) return; } - TPL_OBJECT_UNLOCK(&disp_source->obj); + g_mutex_unlock(&disp_source->wl_event_mutex); } tpl_result_t @@ -2240,7 +2240,7 @@ _twe_thread_wl_surf_source_destroy(void *source) g_mutex_lock(&_twe_ctx->thread_mutex); - TPL_OBJECT_LOCK(&disp_source->obj); + g_mutex_lock(&disp_source->wl_event_mutex); if (surf_source->in_use_buffers) { __tpl_list_free(surf_source->in_use_buffers, @@ -2298,7 +2298,7 @@ _twe_thread_wl_surf_source_destroy(void *source) surf_source->surf = NULL; } - TPL_OBJECT_UNLOCK(&disp_source->obj); + g_mutex_unlock(&disp_source->wl_event_mutex); g_cond_clear(&surf_source->free_queue_cond); g_mutex_clear(&surf_source->free_queue_mutex); -- 2.7.4