return;
}
-static Eina_Bool __stt_notify_result(void *data)
+int __stt_cb_result(unsigned int uid, int event, char** data, int data_count, const char* msg)
{
- stt_client_s* client = (stt_client_s*)data;
-
- /* check handle */
+ stt_client_s* client = stt_client_get_by_uid(uid);
if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid"); //LCOV_EXCL_LINE
- return EINA_FALSE;
+ SLOG(LOG_ERROR, TAG_STTC, "Handle is NOT valid. uid(%u)", uid); //LCOV_EXCL_LINE
+ return STT_ERROR_INVALID_PARAMETER;
}
- if (NULL == stt_client_get_by_uid(client->uid)) {
- return EINA_FALSE;
+ if (NULL != msg)
+ SECURE_SLOG(LOG_INFO, TAG_STTC, "Recognition Result Message = %s", msg);
+
+ for (int i = 0; i < data_count; i++) {
+ if (NULL != data[i])
+ SECURE_SLOG(LOG_INFO, TAG_STTC, "Recognition Result[%d] = %s", i, data[i]);
}
if (NULL != client->recognition_result_cb) {
stt_client_use_callback(client);
- client->recognition_result_cb(client->stt, client->event, (const char**)client->data_list, client->data_count,
- client->msg, client->recognition_result_user_data);
+ client->recognition_result_cb(client->stt, event, (const char**)data, data_count,
+ msg, client->recognition_result_user_data);
stt_client_not_use_callback(client);
SLOG(LOG_INFO, TAG_STTC, "client recognition result callback called");
} else {
SLOG(LOG_WARN, TAG_STTC, "[WARNING] User recognition result callback is NULL");
}
- if (NULL != client->msg) {
- free(client->msg);
- client->msg = NULL;
- }
-
- if (NULL != client->data_list) {
- char **temp = NULL;
- temp = client->data_list;
-
- int i = 0;
- for (i = 0; i < client->data_count; i++) {
- if (NULL != temp[i]) {
- free(temp[i]);
- temp[i] = NULL;
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result data is error"); //LCOV_EXCL_LINE
- }
- }
- free(client->data_list);
- client->data_list = NULL;
- }
-
- client->data_count = 0;
-
stt_config_mgr_remove_time_info_file();
- if (STT_RESULT_EVENT_FINAL_RESULT == client->event || STT_RESULT_EVENT_ERROR == client->event) {
+ if (STT_RESULT_EVENT_FINAL_RESULT == event || STT_RESULT_EVENT_ERROR == event) {
client->before_state = client->current_state;
client->current_state = STT_STATE_READY;
}
}
- return EINA_FALSE;
-}
-
-int __stt_cb_result(unsigned int uid, int event, char** data, int data_count, const char* msg)
-{
- stt_client_s* client = NULL;
-
- client = stt_client_get_by_uid(uid);
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "Handle is NOT valid"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL != msg)
- SECURE_SLOG(LOG_INFO, TAG_STTC, "Recognition Result Message = %s", msg);
-
- int i = 0;
- for (i = 0; i < data_count; i++) {
- if (NULL != data[i])
- SECURE_SLOG(LOG_INFO, TAG_STTC, "Recognition Result[%d] = %s", i, data[i]);
- }
-
- if (NULL != client->recognition_result_cb) {
- client->event = event;
- if (NULL != msg) {
- client->msg = strdup(msg);
- }
-
- client->data_count = data_count;
-
- if (data_count > 0) {
- char **temp = NULL;
- temp = (char**)calloc(data_count, sizeof(char*));
- if (NULL == temp) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory"); //LCOV_EXCL_LINE
- return STT_ERROR_OUT_OF_MEMORY;
- }
-
- for (i = 0; i < data_count; i++) {
- if (NULL != data[i])
- temp[i] = strdup(data[i]);
- else
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result data is error"); //LCOV_EXCL_LINE
- }
-
- client->data_list = temp;
- }
- } else {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] User result callback is null");
- }
-
- __stt_notify_result(client);
-
return STT_ERROR_NONE;
}