gpointer tag;
tdm_client *tdm_client;
int tdm_fd;
+ twe_del_source *tdm_del_source;
};
struct _twe_wl_disp_source {
static twe_thread_context *_twe_ctx;
static twe_tdm_source *
_twe_thread_tdm_source_create(void);
+static void
+_twe_thread_tdm_source_destroy(void *source);
+twe_del_source *
+_twe_del_source_init(twe_thread_context *ctx, void *target_source);
+void
+_twe_del_source_fini(twe_del_source *source);
static gpointer
_twe_thread_loop(gpointer data)
TPL_LOG_T("WL_EGL", "tdm_destroy| tdm_source(%p) tdm_client(%p)",
tdm_source, tdm_source->tdm_client);
+ g_source_remove_unix_fd(source, tdm_source->tag);
+
if (tdm_source->tdm_client) {
tdm_client_destroy(tdm_source->tdm_client);
tdm_source->tdm_client = NULL;
}
static void
-_twe_thread_tdm_source_destroy(twe_tdm_source *tdm_source)
+_twe_thread_tdm_source_destroy(void *source)
{
+ twe_tdm_source *tdm_source = (twe_tdm_source *)source;
+
if (!tdm_source || g_source_is_destroyed(&tdm_source->gsource)) {
TPL_ERR("TDM source(%p) already destroyed.", tdm_source);
return;
}
+ g_mutex_lock(&_twe_ctx->thread_mutex);
+
g_source_destroy(&tdm_source->gsource);
g_source_unref(&tdm_source->gsource);
+
+ g_cond_signal(&_twe_ctx->thread_cond);
+ g_mutex_unlock(&_twe_ctx->thread_mutex);
}
twe_thread*
_twe_ctx);
g_cond_wait(&_twe_ctx->thread_cond,
&_twe_ctx->thread_mutex);
+
+ 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_thread_tdm_source_destroy;
+ }
+
g_mutex_unlock(&_twe_ctx->thread_mutex);
_twe_ctx->ref_cnt = 0;
if (thread->ctx->ref_cnt == 0) {
if (_twe_ctx->tdm_source) {
- _twe_thread_tdm_source_destroy(_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;
+
+ g_mutex_lock(&_twe_ctx->thread_mutex);
+
+ _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;
+
+ _twe_del_source_fini(tdm_del_source);
}
g_main_loop_quit(thread->ctx->twe_loop);