#include "sttd_dbus.h"
#include "sttd_recorder.h"
#include "sttd_engine_agent.h"
+#include "stt_dlog.h"
#define AUDIO_CREATE_ON_START
int sttd_engine_agent_load_current_engine(stte_request_callback_s *callback)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(false == g_agent_init, STTD_ERROR_OPERATION_FAILED, "[Engine Agent ERROR] Not Initialized");
/* Get current engine info */
sttengine_info_s* info;
int sttd_engine_agent_get_engine_list(GSList** engine_list)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(false == g_agent_init, STTD_ERROR_OPERATION_FAILED, "[Engine Agent ERROR] Not Initialized");
SLOG(LOG_DEBUG, TAG_STTD, "--------------------------------------");
return 0;
}
-int sttd_engine_agent_get_current_engine(char** engine_uuid)
+static int __sttd_engine_agent_check_precondition()
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == engine_uuid) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
+ RETVM_IF(false == g_agent_init, STTD_ERROR_OPERATION_FAILED, "[Engine Agent ERROR] Not Initialized");
+ RETVM_IF(NULL == g_engine_info, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] The engine is not valid");
+ RETVM_IF(false == g_engine_info->is_loaded, STTD_ERROR_OPERATION_FAILED, "[Engine Agent ERROR] Not loaded engine");
+ return STTD_ERROR_NONE;
+}
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+int sttd_engine_agent_get_current_engine(char** engine_uuid)
+{
+ RETVM_IF(NULL == engine_uuid, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Invalid parameter");
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
*engine_uuid = strdup(g_engine_info->engine_uuid);
bool sttd_engine_agent_need_network()
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
+ RETVM_IF(false == g_agent_init, STTD_ERROR_OPERATION_FAILED, "[Engine Agent ERROR] Not Initialized");
if (NULL != g_engine_info)
return g_engine_info->use_network;
int sttd_engine_agent_supported_langs(GSList** lang_list)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == lang_list) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Input parameter is NULL");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(NULL == lang_list, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Input parameter");
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
int ret = stt_engine_get_supported_langs(lang_list);
if (0 != ret) {
int sttd_engine_agent_get_default_lang(char** lang)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == lang) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(NULL == lang, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Input parameter");
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
/* get default language */
bool is_valid = false;
int sttd_engine_agent_set_private_data(const char* key, const char* data)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == key || NULL == data) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(NULL == key || NULL == data, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Input parameter");
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
/* set private data */
int ret = -1;
int sttd_engine_agent_get_private_data(const char* key, char** data)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == key || NULL == data) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(NULL == key || NULL == data, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Input parameter");
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
/* get default language */
int ret = -1;
int sttd_engine_agent_get_option_supported(bool* silence)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == silence) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(NULL == silence, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Input parameter");
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
bool temp = false;
if (0 != stt_engine_support_silence(&temp)) {
int sttd_engine_agent_is_credential_needed(unsigned int uid, bool* credential)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == credential) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] uid(%u) is not valid", uid);
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(NULL == credential, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Input parameter");
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
bool temp = false;
int ret;
int sttd_engine_agent_is_recognition_type_supported(const char* type, bool* support)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == type || NULL == support) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(NULL == type || NULL == support, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Input parameter");
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
bool temp = false;
int ret;
int sttd_engine_agent_recognize_start_engine(unsigned int uid, const char* lang, const char* recognition_type,
int silence, const char* appid, const char* credential, void* user_param)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == lang || NULL == recognition_type) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(NULL == lang || NULL == recognition_type, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Input parameter");
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
if (0 != __set_option(g_engine_info, silence)) {
SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set options");
int sttd_engine_agent_recognize_start_recorder(unsigned int uid, const char* appid)
{
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Start recorder");
int sttd_engine_agent_recognize_start_file(unsigned int uid, const char* filepath)
{
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Start recorder");
int sttd_engine_agent_set_recording_data(const void* data, unsigned int length)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == data || 0 == length) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(NULL == data || 0 == length, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Input parameter");
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
int ret = stt_engine_set_recording_data(data, length);
if (0 != ret) {
int sttd_engine_agent_recognize_stop_file()
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Stop recorder");
int ret;
int sttd_engine_agent_recognize_stop_recorder()
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Stop recorder");
int ret;
int sttd_engine_agent_recognize_stop_engine()
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Stop engine");
int sttd_engine_agent_recognize_cancel()
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Cancel engine");
int sttd_engine_agent_set_default_engine(const char* engine_uuid)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == engine_uuid) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
+ RETVM_IF(false == g_agent_init, STTD_ERROR_OPERATION_FAILED, "[Engine Agent ERROR] Not Initialized");
+ RETVM_IF(NULL == engine_uuid, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Invalid Parameter");
__log_enginelist();
- if (NULL == g_engine_info) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Default engine is not valid");
- return STTD_ERROR_ENGINE_NOT_FOUND;
- }
+ RETVM_IF(NULL == g_engine_info, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] The Default engine is not valid");
SECURE_SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Default engine uuid(%s)", g_engine_info->engine_uuid);
int sttd_engine_agent_set_default_language(const char* language)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == language) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter");
- return STTD_ERROR_INVALID_PARAMETER;
- }
+ RETVM_IF(NULL == language, STTD_ERROR_INVALID_PARAMETER, "[Engine Agent ERROR] Input parameter");
+ RETVM_IF(false == g_agent_init, STTD_ERROR_OPERATION_FAILED, "[Engine Agent ERROR] Not Initialized");
if (NULL != g_default_language)
free(g_default_language);
int sttd_engine_agent_set_silence_detection(bool value)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(false == g_agent_init, STTD_ERROR_OPERATION_FAILED, "[Engine Agent ERROR] Not Initialized");
g_default_silence_detected = value;
int sttd_engine_agent_check_app_agreed(const char* appid, bool* result)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
int ret;
ret = stt_engine_check_app_agreed(appid, result);
const char* msg, void* time_info, void *user_data)
{
int ret = -1;
-
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Result Callback : Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(false == g_agent_init, STTD_ERROR_OPERATION_FAILED, "[Engine Agent ERROR] Not Initialized");
SLOG(LOG_INFO, TAG_STTD, "[Server] === Result time callback ===");
int sttd_engine_agent_send_speech_status(stte_speech_status_e status, void* user_data)
{
int ret = STTD_ERROR_NONE;
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Silence Callback : Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(false == g_agent_init, STTD_ERROR_OPERATION_FAILED, "[Engine Agent ERROR] Not Initialized");
ret = g_speech_status_cb(status, user_data);
return ret;
int sttd_engine_agent_set_audio_type(const char* audio_type)
{
- if (false == g_agent_init) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
- return STTD_ERROR_OPERATION_FAILED;
- }
-
- if (NULL == g_engine_info) {
- SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine of is not valid");
- return STTD_ERROR_INVALID_PARAMETER;
- }
-
- if (false == g_engine_info->is_loaded) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
- return STTD_ERROR_OPERATION_FAILED;
- }
+ int tmp = __sttd_engine_agent_check_precondition();
+ if (STTD_ERROR_NONE != tmp)
+ return tmp;
SLOG(LOG_INFO, TAG_STTD, "[Server Info] Set audio type(%s)", audio_type);