static gpointer _focus_thread_func(gpointer data)
{
- debug_log(">>> thread func..ID of this thread(%u)\n", (unsigned int)pthread_self());
- g_main_loop_run(g_focus_loop);
- debug_log("<<< quit thread func..\n");
+ unsigned int thread_id = (unsigned int)pthread_self();
+ debug_warning(">>> thread func..ID of this thread(%u), mainloop(%p)", thread_id, g_focus_loop);
+ if (g_focus_loop)
+ g_main_loop_run(g_focus_loop);
+
+ debug_warning("<<< quit thread func..(%u), mainloop(%p)", thread_id, g_focus_loop);
return NULL;
}
GMainContext* focus_context = g_main_context_new ();
g_focus_loop = g_main_loop_new (focus_context, FALSE);
g_main_context_unref(focus_context);
- g_focus_thread = g_thread_new("focus-callback-thread", _focus_thread_func, NULL);
+ if (g_focus_loop == NULL) {
+ debug_error("could not create mainloop..");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto cleanup;
+ }
+
+ g_focus_thread = g_thread_new("focus-cb-thread", _focus_thread_func, NULL);
if (g_focus_thread == NULL) {
- debug_error ("could not create thread..");
+ debug_error("could not create thread..");
g_main_loop_unref(g_focus_loop);
- g_focus_sound_handle[index].is_used = false;
ret = MM_ERROR_SOUND_INTERNAL;
goto cleanup;
}
+ } else {
+ debug_warning("focus thread(%p) with mainloop(%p) exists, skip thread creation",
+ g_focus_thread, g_focus_loop);
}
} else {
debug_error("[Client] Error occurred : 0x%x \n",ret);
- g_focus_sound_handle[index].is_used = false;
goto cleanup;
}
_focus_init_callback(index, false);
cleanup:
+
+ if (ret) {
+ g_focus_sound_handle[index].is_used = false;
+ }
+
MMSOUND_LEAVE_CRITICAL_SECTION(&g_index_mutex);
debug_fleave();
GMainContext* focus_context = g_main_context_new ();
g_focus_loop = g_main_loop_new (focus_context, FALSE);
g_main_context_unref(focus_context);
- g_focus_thread = g_thread_new("focus-callback-thread", _focus_thread_func, NULL);
+ if (g_focus_loop == NULL) {
+ debug_error("could not create mainloop..");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto cleanup;
+ }
+
+ g_focus_thread = g_thread_new("focus-cb-thread", _focus_thread_func, NULL);
if (g_focus_thread == NULL) {
debug_error ("could not create thread..");
g_main_loop_unref(g_focus_loop);
ret = MM_ERROR_SOUND_INTERNAL;
goto cleanup;
}
+ } else {
+ debug_warning("focus thread(%p) with mainloop(%p) exists, skip thread creation",
+ g_focus_thread, g_focus_loop);
}
} else {
debug_error("[Client] Error occurred : 0x%x",ret);