} 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);
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;
} 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;
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);
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");
}
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;