From 885ea2ded2e1cd75ed33554e9911abe3914258dd Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Tue, 25 Apr 2017 16:31:56 +0900 Subject: [PATCH] tpl_wayland_egl_thread: Applied new logs for thread test. Change-Id: I49ac182b9c3ee52d296a10a95d3a5eaaa23e1f3f Signed-off-by: joonbum.ko --- src/tpl_wayland_egl_thread.c | 78 ++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 6e67fb5..22b6b8a 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -15,36 +15,14 @@ #ifdef WORKER_TEST_ONLY #include #include "wayland-egl/wayland-egl-priv.h" -#define FONT_DEFAULT "\033[0m" /* for reset to default color */ -#define FONT_RED "\033[31m" /* for error logs */ -#define FONT_GREEN "\033[32m" /* for frontend API logs */ -#define FONT_MAGENTA "\033[35m" /* for debug logs */ - -#define tpl_log_d(t, f, x...) \ - fprintf(stderr, FONT_MAGENTA t FONT_DEFAULT "[(tid:%li)(%s)] " f "\n",\ - syscall(SYS_gettid), __func__, ##x) -#define tpl_log_t(t, f, x...) \ - fprintf(stderr, FONT_GREEN t FONT_DEFAULT "[(tid:%li)(%s)] " f "\n", \ - syscall(SYS_gettid), __func__, ##x) -#define tpl_log_e(t, f, x...) \ - fprintf(stderr, FONT_RED t "[(tid:%li)(%s)] " f FONT_DEFAULT "\n", \ - syscall(SYS_gettid), __func__, ##x) - -#define TPL_ERR(f, x...) tpl_log_e("[TPL_ERROR]", f, ##x) -#define TPL_DEBUG(f, x...) \ - ((int)getpid() == (int)syscall(SYS_gettid)) ? tpl_log_d("[MAIN]", f, ##x) : tpl_log_t("[THREAD]", f, ##x) +#include "tpl.h" +#include "tpl_utils.h" + typedef struct _twe_thread twe_thread; typedef struct _twe_thread_context twe_thread_context; typedef void* twe_display_h; typedef void* twe_surface_h; -typedef enum { - TPL_ERROR_NONE = 0, /* Successfull */ - TPL_ERROR_INVALID_PARAMETER, /* Invalid parmeter */ - TPL_ERROR_INVALID_OPERATION, /* Invalid operation */ - TPL_ERROR_OUT_OF_MEMORY /* Out of memory */ -} tpl_result_t; - #else #include "wayland-egl/wayland-egl-priv.h" #include "tpl_wayland_egl_thread.h" @@ -111,7 +89,7 @@ _twe_thread_tdm_source_dispatch(gpointer user_data) twe_thread_context* context = user_data; tdm_error tdm_err; - TPL_DEBUG("tdm_dispatch| tdm_client(%p)", context->tdm_client); + TPL_LOG_T("WL_EGL", "tdm_dispatch| tdm_client(%p)", context->tdm_client); tdm_err = tdm_client_handle_events(context->tdm_client); if (tdm_err) { TPL_ERR("TDM_ERROR:%d context:%p, tdm_cleint:%p\n", tdm_err, context, context->tdm_client); @@ -126,7 +104,7 @@ _twe_thread_tdm_source_destroy(gpointer user_data) { twe_thread_context* context = user_data; - TPL_DEBUG("tdm_destroy| tdm_gsource(%p) tdm_client(%p)", + TPL_LOG_T("WL_EGL", "tdm_destroy| tdm_gsource(%p) tdm_client(%p)", context->tdm_gsource, context->tdm_client); g_source_destroy(context->tdm_gsource); g_source_unref(context->tdm_gsource); @@ -172,7 +150,7 @@ twe_thread_create(void) _twe_ctx, _twe_thread_tdm_source_destroy); g_source_attach(_twe_ctx->tdm_gsource, g_main_loop_get_context(_twe_ctx->twe_loop)); - TPL_DEBUG("tdm g_source(%p) attached to twe_loop(%p)", + TPL_LOG_T("WL_EGL", "tdm g_source(%p) attached to twe_loop(%p)", _twe_ctx->tdm_gsource, _twe_ctx->twe_loop); } } @@ -181,7 +159,7 @@ twe_thread_create(void) thread->ctx = _twe_ctx; _twe_ctx->ref_cnt++; - TPL_DEBUG("_twe_ctx(%p) twe_thread(%p)", _twe_ctx, thread); + TPL_LOG_T("WL_EGL", "_twe_ctx(%p) twe_thread(%p)", _twe_ctx, thread); return thread; } @@ -203,7 +181,7 @@ twe_thread_destroy(twe_thread* thread) thread->ctx = NULL; } - TPL_DEBUG("twe_thread(%p)", thread); + TPL_LOG_T("WL_EGL", "twe_thread(%p)", thread); thread->ctx = NULL; free(thread); @@ -214,7 +192,8 @@ _twe_thread_wl_disp_prepare(GSource *source, gint *time) { twe_wl_disp_source *wl_source = (twe_wl_disp_source *)source; - TPL_DEBUG("prepare| gsource(%p) wl_display(%p)", source, wl_source->disp); + TPL_LOG_T("WL_EGL", "prepare| gsource(%p) wl_display(%p)", + source, wl_source->disp); while (wl_display_prepare_read_queue(wl_source->disp, wl_source->ev_queue) != 0) { wl_display_dispatch_queue_pending(wl_source->disp, wl_source->ev_queue); } @@ -231,12 +210,12 @@ _twe_thread_wl_disp_check(GSource *source) twe_wl_disp_source *wl_source = (twe_wl_disp_source *)source; if (wl_source->gfd.revents) { - TPL_DEBUG("read_events| gsource(%p) wl_display(%p)", + TPL_LOG_T("WL_EGL", "read_events| gsource(%p) wl_display(%p)", source, wl_source->disp); wl_display_read_events(wl_source->disp); return TRUE; } else { - TPL_DEBUG("cancel_read| gsource(%p) wl_display(%p)", + TPL_LOG_T("WL_EGL", "cancel_read| gsource(%p) wl_display(%p)", source, wl_source->disp); wl_display_cancel_read(wl_source->disp); } @@ -250,7 +229,7 @@ _twe_thread_wl_disp_dispatch(GSource *source, GSourceFunc cb, gpointer date) twe_wl_disp_source *wl_source = (twe_wl_disp_source *)source; if (wl_source->gfd.revents & G_IO_IN) { - TPL_DEBUG("dispatch| gsource(%p) wl_display(%p)", + TPL_LOG_T("WL_EGL", "dispatch| gsource(%p) wl_display(%p)", source, wl_source->disp); wl_display_dispatch_queue_pending(wl_source->disp, wl_source->ev_queue); } @@ -268,7 +247,7 @@ _twe_thread_wl_disp_finalize(GSource *source) wl_display_dispatch_queue_pending(wl_source->disp, wl_source->ev_queue); wl_event_queue_destroy(wl_source->ev_queue); - TPL_DEBUG("finalize| wl_event_queue(%p)", + TPL_LOG_T("WL_EGL", "finalize| wl_event_queue(%p)", wl_source->ev_queue); return; } @@ -302,7 +281,7 @@ _twe_display_init_wl_tbm_client(struct wl_display *display, wl_proxy_set_queue(wl_tbm, ev_queue); - TPL_DEBUG("wl_tbm_client init| wl_tbm_client(%p)", wl_tbm_client); + TPL_LOG_T("WL_EGL", "wl_tbm_client init| wl_tbm_client(%p)", wl_tbm_client); return wl_tbm_client; } @@ -316,7 +295,7 @@ _twe_display_fini_wl_tbm_client(struct wayland_tbm_client *wl_tbm_client) wl_proxy_set_queue(wl_tbm, NULL); } - TPL_DEBUG("wl_tbm_client deinit| wl_tbm_client(%p)", wl_tbm_client); + TPL_LOG_T("WL_EGL", "wl_tbm_client deinit| wl_tbm_client(%p)", wl_tbm_client); wayland_tbm_client_deinit(wl_tbm_client); } @@ -356,7 +335,7 @@ twe_display_add(twe_thread* thread, struct wl_display *display) g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop)); g_source_unref(&source->gsource); - TPL_DEBUG("add| gsource(%p) ev_queue(%p) wl_display(%p)", + TPL_LOG_T("WL_EGL", "add| gsource(%p) ev_queue(%p) wl_display(%p)", source, source->ev_queue, display); return (twe_display_h)source; @@ -385,7 +364,8 @@ twe_display_del(twe_display_h twe_display) g_source_destroy(&source->gsource); g_source_unref(&source->gsource); - TPL_DEBUG("del| twe_display(%p) wl_display(%p)", source, source->disp); + TPL_LOG_T("WL_EGL", "del| twe_display(%p) wl_display(%p)", + source, source->disp); return TPL_ERROR_NONE; } @@ -402,7 +382,7 @@ _twe_thread_wl_surface_dispatch(GSource *source, GSourceFunc cb, gpointer date) ssize_t s; uint64_t u; - TPL_DEBUG("finalize| gsource(%p) read event_fd(%d)", + TPL_LOG_T("WL_EGL", "finalize| gsource(%p) read event_fd(%d)", wl_surf_source, wl_surf_source->event_fd); s = read(wl_surf_source->event_fd, &u, sizeof(uint64_t)); if (s != sizeof(uint64_t)) @@ -420,7 +400,7 @@ _twe_thread_wl_surface_finalize(GSource *source) g_source_remove_unix_fd(source, wl_surf_source->tag); - TPL_DEBUG("gsource(%p) event_fd(%d)", + TPL_LOG_T("WL_EGL", "gsource(%p) event_fd(%d)", source, wl_surf_source->event_fd); close(wl_surf_source->event_fd); @@ -468,7 +448,12 @@ tbm_surface_queue_h twe_surface_get_tbm_queue(twe_surface_h twe_surface) { twe_wl_surf_source *source = (twe_wl_surf_source *)twe_surface; - if (!source || !source->tbm_surface_queue) { + if (!source) { + TPL_ERR("Invalid parameters. twe_surface(%p)", source); + return NULL; + } + + if (!source->tbm_surface_queue) { TPL_ERR("Invalid parameters. twe_surface(%p) tbm_surface_queue(%p)", source, source->tbm_surface_queue); return NULL; @@ -533,7 +518,8 @@ twe_surface_add(twe_thread* thread, g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop)); g_source_unref(&source->gsource); - TPL_DEBUG("gsource(%p) wl_egl_window(%p) wl_surface(%p) event_fd(%d)", + TPL_LOG_T("WL_EGL", + "gsource(%p) wl_egl_window(%p) wl_surface(%p) event_fd(%d)", source, wl_egl_window, surface, source->event_fd); return (twe_surface_h)source; @@ -561,7 +547,7 @@ twe_surface_del(twe_surface_h twe_surface) return TPL_ERROR_INVALID_PARAMETER; } - TPL_DEBUG("twe_surface(%p) wl_egl_window(%p) wl_surface(%p)", + TPL_LOG_T("WL_EGL", "twe_surface(%p) wl_egl_window(%p) wl_surface(%p)", surf_source, surf_source->wl_egl_window, surf_source->surf); if (surf_source->tbm_surface_queue) { @@ -572,7 +558,7 @@ twe_surface_del(twe_surface_h twe_surface) /* TODO : surf_source will be removed from surfaces list in disp_source */ surf_source->wl_egl_window = NULL; - surf_source->surface = NULL; + surf_source->surf = NULL; g_source_destroy(&surf_source->gsource); g_source_unref(&surf_source->gsource); @@ -587,7 +573,7 @@ static void reg_global(void *data, const char *interface, uint32_t version) { - TPL_DEBUG("reg_global: %s_v_%d\n", interface, version); + TPL_LOG_T("WL_EGL", "reg_global: %s_v_%d\n", interface, version); } -- 2.7.4