tpl_wayland_egl_thread: Moved tdm_del_source to twe context. 55/194255/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Fri, 30 Nov 2018 05:24:46 +0000 (14:24 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Fri, 30 Nov 2018 08:03:07 +0000 (17:03 +0900)
Change-Id: I6309134e87bee43ad93a2035b296e9755e50f795
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c

index 56e28bd..bdb2f01 100644 (file)
@@ -40,6 +40,7 @@ struct _twe_thread_context {
        int ref_cnt;
 
        twe_tdm_source *tdm_source;
+       twe_del_source *tdm_del_source;
 
        GMutex thread_mutex;
        GCond  thread_cond;
@@ -55,7 +56,6 @@ struct _twe_tdm_source {
        gpointer tag;
        tdm_client *tdm_client;
        int     tdm_fd;
-       twe_del_source *tdm_del_source;
 };
 
 struct _twe_wl_disp_source {
@@ -457,6 +457,8 @@ _twe_thread_tdm_source_destroy(void *source)
                return;
        }
 
+       _twe_ctx->tdm_source = NULL;
+
        g_source_remove_unix_fd(&tdm_source->gsource, tdm_source->tag);
        g_source_destroy(&tdm_source->gsource);
        g_source_unref(&tdm_source->gsource);
@@ -503,9 +505,9 @@ twe_thread_create(void)
                if (_twe_ctx->tdm_source) {
                        twe_tdm_source *tdm_source = _twe_ctx->tdm_source;
 
-                       tdm_source->tdm_del_source = _twe_del_source_init(_twe_ctx, tdm_source);
-                       if (tdm_source->tdm_del_source)
-                               tdm_source->tdm_del_source->destroy_target_source_func
+                       _twe_ctx->tdm_del_source = _twe_del_source_init(_twe_ctx, tdm_source);
+                       if (_twe_ctx->tdm_del_source)
+                               _twe_ctx->tdm_del_source->destroy_target_source_func
                                        = _twe_thread_tdm_source_destroy;
                }
 
@@ -527,21 +529,22 @@ twe_thread_destroy(twe_thread* thread)
        thread->ctx->ref_cnt--;
 
        if (thread->ctx->ref_cnt == 0) {
-               if (_twe_ctx->tdm_source) {
-                       twe_del_source *tdm_del_source = _twe_ctx->tdm_source->tdm_del_source;
-                       _twe_ctx->tdm_source->tdm_del_source = NULL;
+               twe_del_source *tdm_del_source = _twe_ctx->tdm_del_source;
 
+               if (_twe_ctx->tdm_source) {
                        g_mutex_lock(&_twe_ctx->thread_mutex);
 
-                       _twe_thread_del_source_trigger(tdm_del_source);
+                       if (tdm_del_source)
+                               _twe_thread_del_source_trigger(tdm_del_source);
                        g_cond_wait(&_twe_ctx->thread_cond, &_twe_ctx->thread_mutex);
 
                        g_mutex_unlock(&_twe_ctx->thread_mutex);
+               }
 
-                       _twe_ctx->tdm_source = NULL;
-
+               if (tdm_del_source)
                        _twe_del_source_fini(tdm_del_source);
-               }
+
+               _twe_ctx->tdm_del_source = NULL;
 
                g_main_loop_quit(thread->ctx->twe_loop);
                g_thread_join(thread->ctx->twe_thread);