/* client list */
static GSList* g_client_list = NULL;
+static int g_temp_speech_data_requested = 0;
+void ma_client_set_temp_speech_data_requested(int val)
+{
+ g_temp_speech_data_requested = val;
+}
+int ma_client_get_temp_speech_data_requested()
+{
+ return g_temp_speech_data_requested;
+}
+
int ma_client_create(ma_client_s info)
{
ma_client_s* data = NULL;
/* 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(3.0f, __request_speech_data_timer, (void*)(pid));
+ ecore_timer_add(5.0f, __request_speech_data_timer, (void*)(pid));
} else {
MAS_LOGD("MA client connected, but its appid does not match with current maclient");
}
if (current_maclient_appid && 0 == strncmp(current_maclient_appid, appid, MAX_APPID_LEN)) {
MAS_LOGD("appid %s matches with current MA Client, requesting speech data", appid);
+ ma_client_set_temp_speech_data_requested(1);
ret = wakeup_service_request_speech_data();
if (0 != ret) {
MAS_LOGE("[ERROR] Fail to request speech data(%d)", ret);
{
MAS_LOGD("[Enter]");
+ /* We are going to terminate existing clients for testing purpose */
+ int pid = mas_get_current_client_pid();
+ if (pid != -1 && appid) {
+ ma_client_s *client = ma_client_find_by_pid(pid);
+ if (client && strncmp(appid, client->appid, MAX_APPID_LEN) != 0) {
+ int ret = aul_terminate_pid(pid);
+ if (ret != AUL_R_OK) {
+ MAS_LOGW("aul_terminate_pid for pid %d returned %d", pid, ret);
+ }
+ }
+ }
+
mas_set_current_client_by_appid(appid);
if (mas_get_client_pid_by_appid(appid) != -1) {
MAS_LOGD("MA Client with appid %s exists, requesting speech data", (appid ? appid : "NULL"));
+ ma_client_set_temp_speech_data_requested(1);
int ret = wakeup_service_request_speech_data();
if (0 != ret) {
MAS_LOGE("[ERROR] Fail to request speech data(%d)", ret);
}
app_control_destroy (app_control);
- if (APP_CONTROL_ERROR_NONE != ret) {
+ if (APP_CONTROL_ERROR_NONE == ret) {
g_launching_maclient_appid = appid;
}
#ifdef BUF_SAVE_MODE
static char g_temp_file_name[128] = {'\0',};
-static FILE* g_pFile;
+static FILE* g_pFile = NULL;
static int g_count = 1;
#endif
mas_set_current_client_by_wakeup_word(wakeup_word);
if (mas_get_client_pid_by_wakeup_word(wakeup_word) != -1) {
MAS_LOGD("MA Client with wakeup word %s exists, requesting speech data", (wakeup_word ? wakeup_word : "NULL"));
+ ma_client_set_temp_speech_data_requested(1);
int ret = wakeup_service_request_speech_data();
if (0 != ret) {
MAS_LOGE("[ERROR] Fail to request speech data(%d)", ret);
if (pid == -1) {
MAS_LOGE("[ERROR] Fail to retrieve pid of current MA client");
} else {
- int ret = masc_dbus_send_speech_data(pid, event, buffer, len);
- if (0 != ret) {
- MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret);
+ if (g_pFile) {
+ int ret = masc_dbus_send_speech_data(pid, event, buffer, len);
+ if (0 != ret) {
+ MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret);
+ }
+ } else {
+ if (ma_client_get_temp_speech_data_requested()) {
+ /* read file and send dbus here */
+ FILE *fp = fopen(g_temp_file_name, "rb");
+ if (fp) {
+ unsigned char content[640];
+ int first = 1;
+ size_t size;
+ while (size = fread(content, 1, 640, fp)) {
+ wakeup_service_speech_streaming_event_e event;
+ if (size == 640) {
+ event = (first ? WAKEUP_SPEECH_STREAMING_EVENT_START : WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE);
+ } else {
+ event = WAKEUP_SPEECH_STREAMING_EVENT_FINISH;
+ }
+ int ret = masc_dbus_send_speech_data(pid, event, content, size);
+ if (0 != ret) {
+ MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret);
+ }
+ first = 0;
+ }
+ fclose(fp);
+ }
+ }
}
}
+ ma_client_set_temp_speech_data_requested(0);
#ifdef BUF_SAVE_MODE
/* write pcm buffer */