return -1;
}
-#define LOOP_RUNNING_WAIT_TIME_MS 200
+#define LOOP_RUNNING_WAIT_TIME_MS 2500
int focus_init_context(int index)
{
int ret = MM_ERROR_NONE;
focus_context = g_main_context_new();
g_focus_sound_handle[index].focus_loop = g_main_loop_new(focus_context, FALSE);
- g_main_context_unref(focus_context);
+ g_main_context_unref(focus_context); /* FYI, this context resource will be released when calling g_main_loop_unref() */
if (g_focus_sound_handle[index].focus_loop == NULL) {
debug_error("could not create mainloop..");
goto ERROR;
ERROR:
if (g_focus_sound_handle[index].focus_loop) {
+ if (g_focus_sound_handle[index].focus_cb_thread) {
+ g_main_loop_quit(g_focus_sound_handle[index].focus_loop);
+ g_thread_join(g_focus_sound_handle[index].focus_cb_thread);
+ debug_warning("after thread join, thread[%p], mainloop[%p] for index(%d)",
+ g_focus_sound_handle[index].focus_cb_thread, g_focus_sound_handle[index].focus_loop, index);
+ g_focus_sound_handle[index].focus_cb_thread = NULL;
+ }
g_main_loop_unref(g_focus_sound_handle[index].focus_loop);
g_focus_sound_handle[index].focus_loop = NULL;
}