Support multi session for voice input mode 73/97073/3
authorsungwook79.park <sungwook79.park@samsung.com>
Fri, 11 Nov 2016 06:07:54 +0000 (15:07 +0900)
committersungwook park <sungwook79.park@samsung.com>
Fri, 11 Nov 2016 07:35:44 +0000 (23:35 -0800)
Change-Id: I7f512c110e07b527df5b1d095544ced8b34ff318
Signed-off-by: sungwook79.park <sungwook79.park@samsung.com>
src/ise-stt-mode.cpp

index 5e43b02..fd91c00 100644 (file)
@@ -120,7 +120,9 @@ static Eina_Bool hide_guide_text(void *data)
 
     voicedata->guide_text_timer = NULL;
     elm_object_part_text_set(voicedata->layout_main, "elm.text", "");
-    set_guide_text(voicedata, SK_TAP_TO_PAUSE, true);
+
+    if(voicedata->sttmanager->GetCurrent() == STT_STATE_RECORDING || voicedata->sttmanager->GetCurrent() == STT_STATE_PROCESSING)
+        set_guide_text(voicedata, SK_TAP_TO_PAUSE, true);
 
     return ECORE_CALLBACK_CANCEL;
 }
@@ -156,7 +158,39 @@ static void on_mic_button_press_cb(void *data, Evas_Object *obj, void *event_inf
     VoiceData *voicedata = (VoiceData *)data;
     if (!voicedata) return;
 
-    edje_object_signal_emit(_EDJ(voicedata->layout_main), "mouse,clicked,1", "background");
+    if (voicedata->sttmanager != NULL &&
+        (voicedata->sttmanager->GetCurrent() == STT_STATE_RECORDING
+        || voicedata->sttmanager->GetCurrent() == STT_STATE_PROCESSING)) {
+        try {
+            voicedata->state = STT_STATE_VAL_INIT;
+            voicedata->sttmanager->Stop();
+        }
+        catch (is::stt::SttException &e) {
+        }
+
+        if (voicedata->effector)
+            voicedata->effector->Stop(true);
+
+        if (NULL != voicedata->start_timer) {
+            ecore_timer_del(voicedata->start_timer);
+            voicedata->start_timer = NULL;
+        }
+        if (NULL != voicedata->guide_text_timer) {
+            ecore_timer_del(voicedata->guide_text_timer);
+            voicedata->guide_text_timer = NULL;
+        }
+        if (NULL != voicedata->init_timer) {
+            ecore_timer_del(voicedata->init_timer);
+            voicedata->init_timer = NULL;
+        }
+        if (NULL != voicedata->refresh_timer) {
+            ecore_timer_del(voicedata->refresh_timer);
+            voicedata->refresh_timer = NULL;
+        }
+        set_guide_text(voicedata, SK_SPEAK_NOW, true);
+    } else {
+        edje_object_signal_emit(_EDJ(voicedata->layout_main), "mouse,clicked,1", "background");
+    }
 }
 
 static Eina_Bool _mic_button_enable_cb(void *data)
@@ -281,7 +315,7 @@ void set_animation_state(VoiceData *voicedata)
         set_guide_text(voicedata, SK_SPEAK_NOW, true);
 
         if (voicedata->effector)
-            voicedata->effector->Start();
+            voicedata->effector->Stop(true);
 
     } else if (voicedata->state == STT_STATE_VAL_PROCESSING) {
         set_guide_text(voicedata, "");
@@ -358,6 +392,8 @@ void on_initial_anim_press_cb(void *data, Evas_Object *obj, const char *emission
 {
     LOGD("on_initial_anim_press_cb");
     VoiceData *vd = (VoiceData *)data;
+    if (vd == NULL)
+        return;
 
     int tempVal = vd->sttmanager->GetCurrent();
     if (tempVal == STT_STATE_CREATED) {
@@ -417,6 +453,8 @@ void on_initial_anim_press_cb(void *data, Evas_Object *obj, const char *emission
             }
             catch (is::stt::SttException &e) {
             }
+            if (vd->effector)
+                vd->effector->Stop(true);
 
             break;