Request speech data immediately when waked-up client connects
authorJi-hoon Lee <dalton.lee@samsung.com>
Tue, 23 Oct 2018 04:21:16 +0000 (13:21 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 23 Oct 2018 07:21:20 +0000 (16:21 +0900)
Change-Id: I287287b5d73fce81d2a5956b514869d16a7938d6

src/multi_assistant_dbus.c
src/multi_assistant_dbus_server.c
src/multi_assistant_dbus_server.h
src/multi_assistant_service.c

index 780f611..b020b7a 100644 (file)
@@ -527,9 +527,6 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                } else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_DEINITIALIZE)) {
                        ma_service_dbus_deinitialize(g_conn_listener, msg);
 
-               } else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_REQUEST_SPEECH_DATA)) {
-                       ma_service_dbus_request_speech_data(g_conn_listener, msg);
-
                } else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_GET_RECORDING_AUDIO_FORMAT)) {
                        ma_service_dbus_get_audio_format(g_conn_listener, msg);
 
index e2eb69c..46425b0 100644 (file)
@@ -145,56 +145,6 @@ int ma_service_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg)
        return 0;
 }
 
-int ma_service_dbus_request_speech_data(DBusConnection* conn, DBusMessage* msg)
-{
-       DBusError err;
-       dbus_error_init(&err);
-
-       int pid = -1;
-       int ret;
-
-       dbus_message_get_args(msg, &err,
-               DBUS_TYPE_INT32, &pid,
-               DBUS_TYPE_INVALID);
-
-       MAS_LOGD("[DEBUG] MAS REQUEST SPEECH DATA");
-
-       if (dbus_error_is_set(&err)) {
-               MAS_LOGE("[IN ERROR] mas request speech data : Get arguments error (%s)", err.message);
-               dbus_error_free(&err);
-               ret = -1; //MAS_ERROR_OPERATION_FAILED;
-       } else {
-               MAS_LOGD("[IN] mas request speech data");
-               ret = mas_client_request_speech_data(pid);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               /* Append result and voice */
-               dbus_message_append_args(reply,
-                       DBUS_TYPE_INT32, &ret,
-                       DBUS_TYPE_INVALID);
-               if (0 == ret) {
-                       MAS_LOGD("[OUT] mas request speech data : result(%d)", ret);
-               } else {
-                       MAS_LOGE("[OUT ERROR] mas request speech data : result(%d)", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       MAS_LOGE("[OUT ERROR] mas request speech data : Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               MAS_LOGE("[OUT ERROR] request speech data : Fail to create reply message!!");
-       }
-
-       return 0;
-}
-
 int ma_service_dbus_get_audio_format(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
index 87347b9..1b75d8a 100644 (file)
@@ -29,8 +29,6 @@ int ma_service_dbus_initialize(DBusConnection* conn, DBusMessage* msg);
 
 int ma_service_dbus_deinitialize(DBusConnection* conn, DBusMessage* msg);
 
-int ma_service_dbus_request_speech_data(DBusConnection* conn, DBusMessage* msg);
-
 int ma_service_dbus_get_audio_format(DBusConnection* conn, DBusMessage* msg);
 
 int ma_service_dbus_send_asr_result(DBusConnection* conn, DBusMessage* msg);
index 16011cc..62e3a9a 100644 (file)
@@ -54,7 +54,7 @@ typedef struct {
 } ma_client_s;
 
 static int g_current_maclient_info = 0;
-static const char *g_launching_maclient_appid = NULL;
+static const char *g_wakeup_maclient_appid = NULL;
 
 /* client list */
 static GSList* g_client_list = NULL;
@@ -150,29 +150,6 @@ ma_client_s* ma_client_find_by_pid(int pid)
        return NULL;
 }
 
-Eina_Bool __request_speech_data_timer(void *data)
-{
-       MAS_LOGD("[ENTER]");
-
-       int pid = (int)(data);
-       char appid[MAX_APPID_LEN] = {'\0',};
-       if (AUL_R_OK == aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
-               appid[MAX_APPID_LEN - 1] = '\0';
-               if (g_launching_maclient_appid && strncmp(g_launching_maclient_appid, appid, MAX_APPID_LEN) == 0) {
-                       g_launching_maclient_appid = NULL;
-                       mas_client_request_speech_data(pid);
-               } else {
-                       MAS_LOGE("[ERROR] g_launching_maclient_appid and appid differ : %s %s",
-                               (g_launching_maclient_appid ? g_launching_maclient_appid : "NULL"), appid);
-               }
-       } else {
-               MAS_LOGE("[ERROR] failed retrieving appid from pid %d", pid);
-       }
-
-       MAS_LOGD("END");
-       return EINA_FALSE;
-}
-
 int mas_client_initialize(int pid)
 {
        MAS_LOGD("[Enter] pid(%d)", pid);
@@ -212,10 +189,13 @@ int mas_client_initialize(int pid)
                if (current_maclient_appid && 0 == strncmp(current_maclient_appid, appid, MAX_APPID_LEN)) {
                        MAS_LOGD("MA client with current maclient appid connected!");
 
-                       /* Since the ma_request_speech_data() is not available, we will request speech data here.
-                          Need to remove below code when ma_request_speech_data() get implemented.
-                       */
-                       ecore_timer_add(5.0f, __request_speech_data_timer, (void*)(pid));
+                       if (g_wakeup_maclient_appid && strncmp(g_wakeup_maclient_appid, appid, MAX_APPID_LEN) == 0) {
+                               g_wakeup_maclient_appid = NULL;
+                               mas_client_request_speech_data(pid);
+                       } else {
+                               MAS_LOGE("[ERROR] g_wakeup_maclient_appid and appid differ : %s %s",
+                                       (g_wakeup_maclient_appid ? g_wakeup_maclient_appid : "NULL"), appid);
+                       }
                } else {
                        MAS_LOGD("MA client connected, but its appid does not match with current maclient");
                }
@@ -683,7 +663,8 @@ int mas_launch_client_by_appid(const char *appid)
        app_control_destroy (app_control);
 
        if (APP_CONTROL_ERROR_NONE == ret) {
-               g_launching_maclient_appid = appid;
+               g_wakeup_maclient_appid = appid;
+               MAS_LOGD("g_wakeup_maclient_appid : %s", appid);
        }
 
        return ret;