}
static gboolean
+_twe_thread_del_source_dispatch(GSource *source, GSourceFunc cb, gpointer data)
+{
+ twe_del_source *del_source = (twe_del_source *)source;
+ GIOCondition cond;
+
+ if (g_source_is_destroyed(source)) {
+ TPL_ERR("del_source(%p) already destroyed.", source);
+ return G_SOURCE_REMOVE;
+ }
+
+ cond = g_source_query_unix_fd(source, del_source->tag);
+
+ if (cond & G_IO_IN) {
+ ssize_t s;
+ uint64_t u;
+
+ s = read(del_source->event_fd, &u, sizeof(uint64_t));
+ if (s != sizeof(uint64_t))
+ TPL_ERR("Failed to read from event_fd(%d)",
+ del_source->event_fd);
+
+ if (del_source->destroy_target_source_func)
+ del_source->destroy_target_source_func(del_source->target_source);
+ }
+
+ return G_SOURCE_CONTINUE;
+}
+
+static void
+_twe_thread_del_source_finalize(GSource *source)
+{
+ twe_del_source *del_source = (twe_del_source *)source;
+
+ TPL_LOG_T("WL_EGL", "gsource(%p) event_fd(%d)",
+ source, del_source->event_fd);
+
+ g_source_remove_unix_fd(source, del_source->tag);
+
+ close(del_source->event_fd);
+
+ del_source->tag = NULL;
+ del_source->event_fd = -1;
+
+ return;
+}
+
+static GSourceFuncs _twe_del_source_funcs = {
+ .prepare = NULL,
+ .check = NULL,
+ .dispatch = _twe_thread_del_source_dispatch,
+ .finalize = _twe_thread_del_source_finalize,
+};
+
+static void
+_twe_thread_del_source_trigger(twe_del_source *del_source)
+{
+ uint64_t value = 1;
+ int ret;
+
+ if (!del_source || g_source_is_destroyed(&del_source->gsource)) {
+ TPL_ERR("del_source(%p) is already destroyed.", del_source);
+ return;
+ }
+
+ ret = write(del_source->event_fd, &value, sizeof(uint64_t));
+ if (ret == -1) {
+ TPL_ERR("failed to send acquirable event. twe_del_source(%p)",
+ del_source);
+ return;
+ }
+}
+
+twe_del_source *
+_twe_del_source_init(twe_thread_context *ctx, void *target_source)
+{
+ twe_del_source *source = NULL;
+
+ if (!ctx) {
+ TPL_ERR("Invalid parameter. twe_thread_context is NULL");
+ return NULL;
+ }
+
+ if (!target_source) {
+ TPL_ERR("Invalid parameter. target_source is NULL");
+ return NULL;
+ }
+
+ source = (twe_del_source *)g_source_new(&_twe_del_source_funcs,
+ sizeof(twe_del_source));
+ if (!source) {
+ TPL_ERR("[THREAD] Failed to create GSource");
+ return NULL;
+ }
+
+ source->event_fd = eventfd(0, EFD_CLOEXEC);
+ if (source->event_fd < 0) {
+ TPL_ERR("[THREAD] Failed to create eventfd. errno(%d)", errno);
+ g_source_unref(&source->gsource);
+ return NULL;
+ }
+
+ source->tag = g_source_add_unix_fd(&source->gsource,
+ source->event_fd,
+ G_IO_IN);
+ source->target_source = target_source;
+
+ g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop));
+
+ return source;
+}
+
+void
+_twe_del_source_fini(twe_del_source *source)
+{
+ g_source_destroy(&source->gsource);
+ g_source_unref(&source->gsource);
+}
+
+static gboolean
_twe_thread_tdm_source_dispatch(GSource *source, GSourceFunc cb, gpointer data)
{
twe_tdm_source *tdm_source = (twe_tdm_source *)source;
disp_source, disp_source->disp);
}
-static gboolean
-_twe_thread_del_source_dispatch(GSource *source, GSourceFunc cb, gpointer data)
-{
- twe_del_source *del_source = (twe_del_source *)source;
- GIOCondition cond;
-
- if (g_source_is_destroyed(source)) {
- TPL_ERR("del_source(%p) already destroyed.", source);
- return G_SOURCE_REMOVE;
- }
-
- cond = g_source_query_unix_fd(source, del_source->tag);
-
- if (cond & G_IO_IN) {
- ssize_t s;
- uint64_t u;
-
- s = read(del_source->event_fd, &u, sizeof(uint64_t));
- if (s != sizeof(uint64_t))
- TPL_ERR("Failed to read from event_fd(%d)",
- del_source->event_fd);
-
- if (del_source->destroy_target_source_func)
- del_source->destroy_target_source_func(del_source->target_source);
- }
-
- return G_SOURCE_CONTINUE;
-}
-
-static void
-_twe_thread_del_source_finalize(GSource *source)
-{
- twe_del_source *del_source = (twe_del_source *)source;
-
- TPL_LOG_T("WL_EGL", "gsource(%p) event_fd(%d)",
- source, del_source->event_fd);
-
- g_source_remove_unix_fd(source, del_source->tag);
-
- close(del_source->event_fd);
-
- del_source->tag = NULL;
- del_source->event_fd = -1;
-
- return;
-}
-
-static GSourceFuncs _twe_del_source_funcs = {
- .prepare = NULL,
- .check = NULL,
- .dispatch = _twe_thread_del_source_dispatch,
- .finalize = _twe_thread_del_source_finalize,
-};
-
-static void
-_twe_thread_del_source_trigger(twe_del_source *del_source)
-{
- uint64_t value = 1;
- int ret;
-
- if (!del_source || g_source_is_destroyed(&del_source->gsource)) {
- TPL_ERR("del_source(%p) is already destroyed.", del_source);
- return;
- }
-
- ret = write(del_source->event_fd, &value, sizeof(uint64_t));
- if (ret == -1) {
- TPL_ERR("failed to send acquirable event. twe_del_source(%p)",
- del_source);
- return;
- }
-}
-
-twe_del_source *
-_twe_del_source_init(twe_thread_context *ctx, void *target_source)
-{
- twe_del_source *source = NULL;
-
- if (!ctx) {
- TPL_ERR("Invalid parameter. twe_thread_context is NULL");
- return NULL;
- }
-
- if (!target_source) {
- TPL_ERR("Invalid parameter. target_source is NULL");
- return NULL;
- }
-
- source = (twe_del_source *)g_source_new(&_twe_del_source_funcs,
- sizeof(twe_del_source));
- if (!source) {
- TPL_ERR("[THREAD] Failed to create GSource");
- return NULL;
- }
-
- source->event_fd = eventfd(0, EFD_CLOEXEC);
- if (source->event_fd < 0) {
- TPL_ERR("[THREAD] Failed to create eventfd. errno(%d)", errno);
- g_source_unref(&source->gsource);
- return NULL;
- }
-
- source->tag = g_source_add_unix_fd(&source->gsource,
- source->event_fd,
- G_IO_IN);
- source->target_source = target_source;
-
- g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop));
-
- return source;
-}
-
-void
-_twe_del_source_fini(twe_del_source *source)
-{
- g_source_destroy(&source->gsource);
- g_source_unref(&source->gsource);
-}
-
twe_display_h
twe_display_add(twe_thread* thread, struct wl_display *display)
{