g_mutex_lock(&new_thread->thread_mutex);
- new_thread->destroy_sig_source =
- tpl_gsource_create(new_thread, new_thread, -1,
- &thread_destroy_funcs, SOURCE_TYPE_FINALIZER);
new_thread->loop = loop;
+ TPL_DEBUG("loop(%p)", loop);
new_thread->init_func = init_func;
new_thread->func_data = func_data;
new_thread->thread = g_thread_new(thread_name,
_tpl_gthread_init, new_thread);
g_cond_wait(&new_thread->thread_cond,
&new_thread->thread_mutex);
+
+ new_thread->destroy_sig_source =
+ tpl_gsource_create(new_thread, new_thread, -1,
+ &thread_destroy_funcs, SOURCE_TYPE_FINALIZER);
g_mutex_unlock(&new_thread->thread_mutex);
return new_thread;
ret = gsource->gsource_funcs->dispatch(gsource, message);
if (gsource->type == SOURCE_TYPE_FINALIZER) {
- tpl_gsource *del_source = (tpl_gsource *)data;
+ tpl_gsource *del_source = (tpl_gsource *)gsource->data;
if (!g_source_is_destroyed(&del_source->gsource)) {
- g_mutex_lock(&del_source->thread->thread_mutex);
+ tpl_gthread *thread = del_source->thread;
+ g_mutex_lock(&thread->thread_mutex);
g_source_remove_unix_fd(&del_source->gsource, del_source->tag);
g_source_destroy(&del_source->gsource);
g_source_unref(&del_source->gsource);
- g_cond_signal(&del_source->thread->thread_cond);
- g_mutex_unlock(&del_source->thread->thread_mutex);
+ g_cond_signal(&thread->thread_cond);
+ g_mutex_unlock(&thread->thread_mutex);
}
}
} else {
g_source_attach(&new_gsource->gsource,
g_main_loop_get_context(thread->loop));
+ TPL_DEBUG("[GSOURCE_CREATE] tpl_gsource(%p) thread(%p) data(%p) fd(%d) type(%d)",
+ new_gsource, thread, data, new_gsource->fd, type);
+
return new_gsource;
}
return;
}
+ TPL_DEBUG("[GSOURCE_DESTROY] tpl_gsource(%p) type(%d)",
+ source, source->type);
+
if (destroy_in_thread) {
+ tpl_gthread *thread = source->thread;
if (source->type == SOURCE_TYPE_NORMAL) {
- g_mutex_lock(&source->thread->thread_mutex);
+ g_mutex_lock(&thread->thread_mutex);
tpl_gsource_send_message(source->finalizer, 1);
- g_cond_wait(&source->thread->thread_cond, &source->thread->thread_mutex);
- g_mutex_unlock(&source->thread->thread_mutex);
+ g_cond_wait(&thread->thread_cond, &thread->thread_mutex);
+ g_mutex_unlock(&thread->thread_mutex);
}
} else {
if (source->type == SOURCE_TYPE_NORMAL &&
tdm_client *tdm_client;
tpl_gsource *tdm_source;
+ int tdm_display_fd;
tpl_bool_t use_wait_vblank;
tpl_bool_t use_explicit_sync;
if (wl_egl_display->tdm_client) {
tdm_client_destroy(wl_egl_display->tdm_client);
wl_egl_display->tdm_client = NULL;
+ wl_egl_display->tdm_display_fd = -1;
}
wl_egl_display->tdm_initialized = TPL_FALSE;
tpl_result_t
_thread_tdm_init(tpl_wl_egl_display_t *wl_egl_display)
{
- tpl_gsource *tdm_source = NULL;
tdm_client *tdm_client = NULL;
int tdm_display_fd = -1;
tdm_error tdm_err = TDM_ERROR_NONE;
- if (!wl_egl_display->thread) {
- TPL_ERR("thread should be created before init tdm_client.");
- return TPL_ERROR_INVALID_OPERATION;
- }
-
tdm_client = tdm_client_create(&tdm_err);
if (!tdm_client || tdm_err != TDM_ERROR_NONE) {
TPL_ERR("TDM_ERROR:%d Failed to create tdm_client\n", tdm_err);
return TPL_ERROR_INVALID_OPERATION;
}
- tdm_source = tpl_gsource_create(wl_egl_display->thread,
- (void *)wl_egl_display, tdm_display_fd,
- &tdm_funcs, SOURCE_TYPE_NORMAL);
- if (!tdm_source) {
- TPL_ERR("Failed to create tdm_gsource\n");
- tdm_client_destroy(tdm_client);
- return TPL_ERROR_INVALID_OPERATION;
- }
-
- wl_egl_display->tdm_client = tdm_client;
- wl_egl_display->tdm_source = tdm_source;
-
+ wl_egl_display->tdm_display_fd = tdm_display_fd;
+ wl_egl_display->tdm_client = tdm_client;
+ wl_egl_display->tdm_source = NULL;
wl_egl_display->tdm_initialized = TPL_TRUE;
- TPL_LOG_T("WL_EGL", "TPL_WAIT_VBLANK:DEFAULT_ENABLED");
- TPL_LOG_T("WL_EGL", "wl_egl_display(%p) tdm_source(%p) tdm_client(%p)",
- wl_egl_display, tdm_source, tdm_client);
+ TPL_INFO("[TDM_CLIENT_INIT]",
+ "wl_egl_display(%p) tdm_client(%p) tdm_display_fd(%d)",
+ wl_egl_display, tdm_client, tdm_display_fd);
return TPL_ERROR_NONE;
}
wl_egl_display->wl_initialized = TPL_TRUE;
+ TPL_INFO("[WAYLAND_INIT]",
+ "wl_egl_display(%p) wl_display(%p) event_queue(%p)",
+ wl_egl_display, wl_egl_display->wl_display, wl_egl_display->ev_queue);
+ TPL_INFO("[WAYLAND_INIT]",
+ "tizen_surface_shm(%p) wp_presentation(%p) explicit_sync(%p)",
+ wl_egl_display->tss, wl_egl_display->presentation,
+ wl_egl_display->explicit_sync);
+
fini:
if (display_wrapper)
wl_proxy_wrapper_destroy(display_wrapper);
goto free_display;
}
+ wl_egl_display->tdm_source = tpl_gsource_create(wl_egl_display->thread,
+ (void *)wl_egl_display,
+ wl_egl_display->tdm_display_fd,
+ &tdm_funcs, SOURCE_TYPE_NORMAL);
+ if (!wl_egl_display->tdm_source) {
+ TPL_ERR("Failed to create tdm_gsource\n");
+ goto free_display;
+ }
+
TPL_LOG_T("WL_EGL",
"[INIT DISPLAY] wl_egl_display(%p) tpl_gthread(%p) wl_display(%p)",
wl_egl_display,
free_display:
if (wl_egl_display->thread) {
- tpl_gsource_destroy(wl_egl_display->tdm_source, TPL_TRUE);
+ if (wl_egl_display->tdm_source)
+ tpl_gsource_destroy(wl_egl_display->tdm_source, TPL_TRUE);
+ if (wl_egl_display->disp_source)
+ tpl_gsource_destroy(wl_egl_display->disp_source, TPL_TRUE);
+
tpl_gthread_destroy(wl_egl_display->thread, _thread_fini);
}
wl_egl_display->thread,
wl_egl_display->wl_display);
- if (wl_egl_display->disp_source) {
- tpl_gsource_destroy(wl_egl_display->disp_source, TPL_TRUE);
- wl_egl_display->disp_source = NULL;
- }
-
if (wl_egl_display->tdm_source && wl_egl_display->tdm_initialized) {
tpl_gsource_destroy(wl_egl_display->tdm_source, TPL_TRUE);
wl_egl_display->tdm_source = NULL;
}
+ if (wl_egl_display->disp_source) {
+ tpl_gsource_destroy(wl_egl_display->disp_source, TPL_TRUE);
+ wl_egl_display->disp_source = NULL;
+ }
+
if (wl_egl_display->thread) {
tpl_gthread_destroy(wl_egl_display->thread, NULL);
wl_egl_display->thread = NULL;