Load voice-control-elm library in the thread 65/197365/3
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 11 Jan 2019 00:41:01 +0000 (09:41 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 11 Jan 2019 02:10:34 +0000 (11:10 +0900)
- Uses g_thread_new() function to create a new thread for loading
voice-control-elm.

Change-Id: I10821e4b915992e73bba3d211fdf5b523fb4ef19
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/efl_base/appcore_efl_base.c

index 6095676..5280f96 100644 (file)
@@ -34,6 +34,7 @@ static void *__vc_elm_handle;
 static int (*__vc_elm_initialize)(void);
 static int (*__vc_elm_deinitialize)(void);
 static int (*__vc_elm_set_auto_register_mode)(int, int);
+static GThread *__vc_elm_thread;
 
 static void __unload_vc_elm(void)
 {
@@ -50,8 +51,12 @@ static void __unload_vc_elm(void)
 
 static int __load_vc_elm(void)
 {
-       if (__vc_elm_handle)
+       _DBG("Load voice-control-elm");
+
+       if (__vc_elm_handle) {
+               _DBG("Already exists");
                return 0;
+       }
 
        if (access(PATH_LIB_VC_ELM, F_OK) != 0) {
                _ERR("Failed to access %s", PATH_LIB_VC_ELM);
@@ -114,11 +119,6 @@ static void __vc_vtauto_changed_cb(keynode_t *key, void *data)
 static void __vc_elm_init(void)
 {
        int vt_automode = 0;
-       int r;
-
-       r = __load_vc_elm();
-       if (r < 0)
-               return;
 
        vconf_notify_key_changed(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE,
                        __vc_vtauto_changed_cb, NULL);
@@ -144,12 +144,31 @@ static void __vc_elm_finish(void)
 
 static gboolean __init_vc_elm(gpointer data)
 {
+       _DBG("Initialize vc-elm");
+       /* Postpone initialization to improve app launching performance */
        /* VC voice touch setting */
        __vc_elm_init();
 
        return G_SOURCE_REMOVE;
 }
 
+static gpointer __vc_elm_loader(gpointer data)
+{
+       int r = 0;
+       int retry_count = 3;
+
+       do {
+               r = __load_vc_elm();
+               if (r == 0) {
+                       g_idle_add(__init_vc_elm, NULL);
+                       break;
+               }
+       } while (retry_count--);
+       LOGW("[vc-elm-loader] Result: %d", r);
+
+       return GINT_TO_POINTER(r);
+}
+
 static void __efl_app_init(int argc, char **argv, void *data)
 {
        int hint;
@@ -173,13 +192,19 @@ static void __efl_app_init(int argc, char **argv, void *data)
                }
        }
 
-       /* Postpone initialization to improve app launching performance */
-       g_idle_add(__init_vc_elm, NULL);
+       __vc_elm_thread = g_thread_new("vc-elm-loader", __vc_elm_loader, NULL);
 }
 
 static void __efl_app_finish(void)
 {
+       gpointer r;
+
        __vc_elm_finish();
+       if (__vc_elm_thread) {
+               r = g_thread_join(__vc_elm_thread);
+               __vc_elm_thread = NULL;
+               _DBG("vc-elm-loader. result(%d)", GPOINTER_TO_INT(r));
+       }
 
        elm_shutdown();