stt_engine.c produces the circular dependency problem by including sttd_engine_agent.h.
This patch removes sttd_engine_agent.h from stt_engine.c to remove circular depedency.
To remove sttd_engine_agent.h, this patch also changes and removes some functions in stt_engine.c.
Change-Id: I815660e70d9094f20c8b17f380a5e4e7bc3eb4d2
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
#include <stdbool.h>
#include "stt_engine.h"
-#include "sttd_engine_agent.h"
#include "stt_defs.h"
return 0;
}
-int stt_engine_send_result(stte_result_event_e event, const char* type, const char** result, int result_count,
- const char* msg, void* time_info, void* user_data)
+int stt_engine_get_recognition_result_cb(stt_engine_result_cb* result_cb)
{
- if (NULL == type || NULL == result) {
+ if (NULL == result_cb) {
SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid parameter");
+ return STTE_ERROR_INVALID_PARAMETER;
}
- int ret = STTE_ERROR_NONE;
if (false == __stt_get_engine_from()) {
- ret = sttd_engine_agent_send_result(event, type, result, result_count, msg, time_info, user_data);
- if (0 != ret) {
- SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to send result");
- }
- } else {
- ret = g_result_cb(event, type, result, result_count, msg, time_info, user_data);
+ SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Engine is not loaded from file");
+ return STTE_ERROR_NOT_SUPPORTED;
}
- return ret;
-}
-int stt_engine_send_error(stte_error_e error, const char* msg)
-{
- int ret = STTE_ERROR_NONE;
- ret = sttd_engine_agent_send_error(error, msg);
- if (0 != ret) {
- SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to send error info");
- }
- return ret;
-}
-
-int stt_engine_send_speech_status(stte_speech_status_e status, void* user_data)
-{
- int ret = STTE_ERROR_NONE;
- ret = sttd_engine_agent_send_speech_status(status, user_data);
- if (0 != ret) {
- SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to send speech status");
- }
- return ret;
+ *result_cb = g_result_cb;
+ return STTE_ERROR_NONE;
}
int stt_engine_set_private_data_set_cb(stte_private_data_set_cb private_data_set_cb, void* user_data)
/* File recognition */
-int stt_engine_recognize_start_file(const char* lang, const char* recognition_type,
+int stt_engine_recognize_start_file(const char* lang, const char* recognition_type,
const char* filepath, stte_audio_type_e audio_type, int sample_rate, void* user_param);
int stt_engine_recognize_cancel_file();
int stt_engine_set_recognition_result_cb(stt_engine_result_cb result_cb, void* user_data);
-int stt_engine_send_result(stte_result_event_e event, const char* type, const char** result, int result_count,
- const char* msg, void* time_info, void* user_data);
-
-int stt_engine_send_error(stte_error_e error, const char* msg);
-
-int stt_engine_send_speech_status(stte_speech_status_e status, void* user_data);
+int stt_engine_get_recognition_result_cb(stt_engine_result_cb* result_cb);
int stt_engine_set_private_data_set_cb(stte_private_data_set_cb private_data_set_cb, void* user_data);
#include "stt_network.h"
#include "sttd_dbus.h"
#include "sttd_server.h"
+#include "sttd_engine_agent.h"
#include "stte.h"
}
int ret = STTE_ERROR_NONE;
- ret = stt_engine_send_result(event, type, result, result_count, msg, time_info, user_data);
- if (0 != ret) {
+ stt_engine_result_cb result_cb = NULL;
+ ret = stt_engine_get_recognition_result_cb(&result_cb);
+ if (STTE_ERROR_NONE == ret && NULL != result_cb) {
+ ret = result_cb(event, type, result, result_count, msg, time_info, user_data);
+ } else {
+ ret = sttd_engine_agent_send_result(event, type, result, result_count, msg, time_info, user_data);
+ }
+
+ if (STTE_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send result");
}
return ret;
int stte_send_error(stte_error_e error, const char* msg)
{
int ret = STTE_ERROR_NONE;
- ret = stt_engine_send_error(error, msg);
+ ret = sttd_engine_agent_send_error(error, msg);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send error info");
}
int stte_send_speech_status(stte_speech_status_e status, void* user_data)
{
int ret = STTE_ERROR_NONE;
- ret = stt_engine_send_speech_status(status, user_data);
+ ret = sttd_engine_agent_send_speech_status(status, user_data);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to send speech status");
}