GMainLoop *twe_loop;
twe_tdm_source *tdm_source;
+
+ GMutex thread_mutex;
+ GCond thread_cond;
};
struct _twe_thread {
_twe_thread_loop(gpointer data)
{
twe_thread_context *ctx = data;
- char *env = getenv("TPL_WAIT_VBLANK");
+ char *env = NULL;
+
+ g_mutex_lock(&ctx->thread_mutex);
+
+ env = getenv("TPL_WAIT_VBLANK");
if (env == NULL || atoi(env)) {
twe_tdm_source *tdm_source = _twe_thread_tdm_source_create();
}
}
+ g_cond_signal(&ctx->thread_cond);
+ g_mutex_unlock(&ctx->thread_mutex);
+
g_main_loop_run(ctx->twe_loop);
return ctx;
_twe_ctx->twe_loop = g_main_loop_new(context, FALSE);
g_main_context_unref(context);
+ g_mutex_init(&_twe_ctx->thread_mutex);
+ g_cond_init(&_twe_ctx->thread_cond);
+
+ g_mutex_lock(&_twe_ctx->thread_mutex);
_twe_ctx->twe_thread = g_thread_new("twe_thread", _twe_thread_loop,
_twe_ctx);
+ g_cond_wait(&_twe_ctx->thread_cond,
+ &_twe_ctx->thread_mutex);
+ g_mutex_unlock(&_twe_ctx->thread_mutex);
+
_twe_ctx->ref_cnt = 0;
}
g_thread_join(thread->ctx->twe_thread);
g_main_loop_unref(thread->ctx->twe_loop);
+ g_mutex_clear(&thread->ctx->thread_mutex);
+ g_cond_clear(&thread->ctx->thread_cond);
+
free(_twe_ctx);
_twe_ctx = NULL;
}