return STT_ERROR_NONE;
}
-static int __stt_check_precondition(stt_h stt, stt_client_s* client)
+static int __stt_check_precondition(stt_h stt, stt_client_s** client)
{
RETV_IF(0 != __stt_get_feature_enabled(), STT_ERROR_NOT_SUPPORTED);
RETV_IF(0 != __stt_check_privilege(), STT_ERROR_PERMISSION_DENIED);
int stt_destroy(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== Destroy STT");
/* check used callback */
int stt_foreach_supported_engines(stt_h stt, stt_supported_engine_cb callback, void* user_data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== Foreach Supported engine");
- if (NULL == callback) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- if (client->current_state != STT_STATE_CREATED) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not CREATED", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == callback, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(client->current_state != STT_STATE_CREATED, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not CREATED", client->current_state);
client->supported_engine_cb = callback;
client->supported_engine_user_data = user_data;
int stt_get_engine(stt_h stt, char** engine_id)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== Get current engine");
- if (NULL == engine_id) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- if (client->current_state != STT_STATE_CREATED) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not CREATED", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == engine_id, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(client->current_state != STT_STATE_CREATED, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not CREATED", client->current_state);
int ret = 0;
SLOG(LOG_INFO, TAG_STTC, "===== Set current engine");
- if (NULL == engine_id) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- /* check state */
- if (client->current_state != STT_STATE_CREATED) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not CREATED", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == engine_id, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(client->current_state != STT_STATE_CREATED, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not CREATED", client->current_state);
if (NULL != client->current_engine_id) {
free(client->current_engine_id);
int stt_set_credential(stt_h stt, const char* credential)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== Set credential");
- if (NULL == credential) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
- return STT_ERROR_INVALID_PARAMETER;
- }
+ RETVM_IF(NULL == credential, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
/* check state */
if (client->current_state != STT_STATE_CREATED && client->current_state != STT_STATE_READY) {
int stt_set_private_data(stt_h stt, const char* key, const char* data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== Set private data");
- if (NULL == key || NULL == data) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid parameter");
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- /* check state */
- if (STT_STATE_READY != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == key || NULL == data, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter");
+ RETVM_IF(STT_STATE_READY != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
if (true != client->internal && (0 == strcmp(key, "server") || 0 == strcmp(key, "rampcode") || 0 == strcmp(key, "epd"))) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] This is not an internal app"); //LCOV_EXCL_LINE
int stt_get_private_data(stt_h stt, const char* key, char** data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== Get private data");
- if (NULL == key || NULL == data) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid parameter");
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- /* check state */
- if (STT_STATE_READY != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == key || NULL == data, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter");
+ RETVM_IF(STT_STATE_READY != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
int ret = -1;
int count = 0;
int ret = -1;
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== Set STT server");
- if (NULL == key || NULL == user_data) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid parameter");
- return STT_ERROR_INVALID_PARAMETER;
- }
+ RETVM_IF(NULL == key || NULL == user_data, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter");
if (STT_STATE_CREATED != client->current_state && STT_STATE_READY != client->current_state) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] The current state is invalid (%d).", client->current_state);
int stt_prepare(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== Prepare STT");
/* check state */
- if (client->current_state != STT_STATE_CREATED) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not 'CREATED'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(STT_STATE_CREATED != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not 'CREATED'", client->current_state);
ecore_thread_main_loop_begin();
g_connect_timer = ecore_timer_add(0.02, __stt_connect_daemon, (void*)client);
int stt_unprepare(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== Unprepare STT");
/* check state */
- if (client->current_state != STT_STATE_READY) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(STT_STATE_READY != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not 'READY'", client->current_state);
int ret = -1;
int count = 0;
int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callback, void* user_data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== Foreach Supported Language");
- if (NULL == callback) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
+ RETVM_IF(NULL == callback, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
int ret;
char* current_engine_id = NULL;
int stt_get_default_language(stt_h stt, char** language)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== Get Default Language");
- if (NULL == language) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
+ RETVM_IF(NULL == language, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
int ret = 0;
ret = stt_config_mgr_get_default_language(language);
int stt_get_state(stt_h stt, stt_state_e* state)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
- if (NULL == state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
+ RETVM_IF(NULL == state, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
*state = client->current_state;
int stt_get_error_message(stt_h stt, char** err_msg)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
-
- if (NULL == err_msg) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
- return STT_ERROR_INVALID_PARAMETER;
- }
- if (false == g_err_callback_status) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] This callback should be called during an err_callback");
- return STT_ERROR_OPERATION_FAILED;
- }
+ RETVM_IF(NULL == err_msg, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(false == g_err_callback_status, STT_ERROR_OPERATION_FAILED, "[ERROR] This callback should be called during an err_callback");
if (NULL != client->err_msg) {
*err_msg = strdup(client->err_msg);
int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
- if (NULL == type || NULL == support) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- /* check state */
- if (client->current_state != STT_STATE_READY) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == type || NULL == support, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(client->current_state != STT_STATE_READY, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
int ret = -1;
int count = 0;
int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
/* check state */
if (client->current_state != STT_STATE_READY) {
int stt_set_start_sound(stt_h stt, const char* filename)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== STT SET START SOUND");
- if (NULL == filename) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- if (0 != access(filename, F_OK)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] File does not exist"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- /* check state */
- if (client->current_state != STT_STATE_READY) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == filename, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(0 != access(filename, F_OK), STT_ERROR_INVALID_PARAMETER, "[ERROR] File does not exist");
+ RETVM_IF(STT_STATE_READY != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
int ret = -1;
int count = 0;
int stt_unset_start_sound(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== STT UNSET START SOUND");
/* check state */
- if (client->current_state != STT_STATE_READY) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(STT_STATE_READY != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
int ret = -1;
int count = 0;
int stt_set_stop_sound(stt_h stt, const char* filename)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== STT SET STOP SOUND");
-
- if (NULL == filename) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- if (0 != access(filename, F_OK)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] File does not exist"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- /* check state */
- if (client->current_state != STT_STATE_READY) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == filename, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(0 != access(filename, F_OK), STT_ERROR_INVALID_PARAMETER, "[ERROR] File does not exist");
+ RETVM_IF(STT_STATE_READY != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
int ret = -1;
int count = 0;
int stt_unset_stop_sound(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== STT UNSET STOP SOUND");
-
- /* check state */
- if (client->current_state != STT_STATE_READY) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(STT_STATE_READY != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
int ret = -1;
int count = 0;
int stt_start(stt_h stt, const char* language, const char* type)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
- return temp;
+ int tmp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != tmp) {
+ return tmp;
}
SLOG(LOG_INFO, TAG_STTC, "===== STT START");
-
- /* check state */
- if (client->current_state != STT_STATE_READY) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
-
- if (STT_INTERNAL_STATE_NONE != client->internal_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is NOT none : %d", client->internal_state); //LCOV_EXCL_LINE
- return STT_ERROR_IN_PROGRESS_TO_RECORDING;
- }
+ RETVM_IF(STT_STATE_READY != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
+ RETVM_IF(STT_INTERNAL_STATE_NONE != client->internal_state, STT_ERROR_IN_PROGRESS_TO_RECORDING, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
int ret = -1;
char appid[1024] = {0, };
temp = strdup(language);
}
- if (NULL == temp) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory");
- return STT_ERROR_OUT_OF_MEMORY;
- }
+ RETVM_IF(NULL == temp, STT_ERROR_OUT_OF_MEMORY, "[ERROR] Fail to allocate memory");
if (true == client->credential_needed && NULL == client->credential) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Do not have app credential for this engine(%s)", client->current_engine_id); //LCOV_EXCL_LINE
int stt_stop(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== STT STOP");
-
- /* check state */
- if (client->current_state != STT_STATE_RECORDING) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Current state(%d) is NOT RECORDING", client->current_state); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(STT_STATE_RECORDING != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State : Current state(%d) is NOT RECORDING", client->current_state);
if (STT_INTERNAL_STATE_STARTING == client->internal_state) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STARTING : %d", client->internal_state); //LCOV_EXCL_LINE
int stt_cancel(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== STT CANCEL");
int stt_get_recording_volume(stt_h stt, float* volume)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
- if (NULL == volume) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- if (STT_STATE_RECORDING != client->current_state) {
- SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Invalid state : NO 'Recording' state, cur(%d)", client->current_state); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == volume, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(STT_STATE_RECORDING != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Invalid state : NO 'Recording' state, cur(%d)", client->current_state);
*volume = g_volume_db;
int stt_foreach_detailed_result(stt_h stt, stt_result_time_cb callback, void* user_data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== STT FOREACH DETAILED RESULT");
-
- if (NULL == callback) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
+ RETVM_IF(NULL == callback, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
client->result_time_cb = callback;
client->result_time_user_data = user_data;
stt_client_s* client = (stt_client_s*)data;
SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error from sttd");
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid"); //LCOV_EXCL_LINE
- return;
- }
+ RETM_IF(NULL == client, "[ERROR] Fail to notify error : A handle is not valid");
if (NULL == stt_client_get_by_uid(client->uid))
return;
stt_client_s* client = (stt_client_s*)data;
/* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid"); //LCOV_EXCL_LINE
- return;
- }
-
- if (NULL == stt_client_get_by_uid(client->uid)) {
- return;
- }
+ RETM_IF(NULL == client, "[ERROR] Fail to notify error : A handle is not valid");
+ RET_IF(NULL == stt_client_get_by_uid(client->uid));
if (STT_INTERNAL_STATE_STARTING == client->internal_state && STT_STATE_RECORDING == client->current_state) {
client->internal_state = STT_INTERNAL_STATE_NONE;
int __stt_cb_result(unsigned int uid, int event, char** data, int data_count, const char* msg)
{
stt_client_s* client = stt_client_get_by_uid(uid);
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "Handle is NOT valid. uid(%u)", uid); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_PARAMETER;
- }
+ RETVM_IF(NULL == client, STT_ERROR_INVALID_PARAMETER, "Handle is NOT valid. uid(%u)", uid);
if (NULL != msg)
SECURE_SLOG(LOG_INFO, TAG_STTC, "Recognition Result Message = %s", msg);
stt_client_s* client = (stt_client_s*)data;
/* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify speech status : A handle is not valid"); //LCOV_EXCL_LINE
- return;
- }
-
- if (NULL == stt_client_get_by_uid(client->uid)) {
- return;
- }
+ RETM_IF(NULL == client, "[ERROR] Fail to notify speech status : A handle is not valid");
+ RET_IF(NULL == stt_client_get_by_uid(client->uid));
if (NULL != client->speech_status_cb) {
stt_client_use_callback(client);
int stt_set_recognition_result_cb(stt_h stt, stt_recognition_result_cb callback, void* user_data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
if (callback == NULL)
return STT_ERROR_INVALID_PARAMETER;
int stt_unset_recognition_result_cb(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
if (STT_STATE_CREATED != client->current_state) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* user_data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
- if (NULL == callback)
- return STT_ERROR_INVALID_PARAMETER;
-
- if (STT_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == callback, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(STT_STATE_CREATED != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
SLOG(LOG_INFO, TAG_STTC, "[INFO] Set state changed cb");
int stt_unset_state_changed_cb(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
- if (STT_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(STT_STATE_CREATED != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
SLOG(LOG_INFO, TAG_STTC, "[INFO] Unset state changed cb");
int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
-
- if (NULL == callback)
- return STT_ERROR_INVALID_PARAMETER;
- if (STT_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == callback, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(STT_STATE_CREATED != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
SLOG(LOG_INFO, TAG_STTC, "[INFO] Set error cb");
int stt_unset_error_cb(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
- if (STT_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(STT_STATE_CREATED != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
SLOG(LOG_INFO, TAG_STTC, "[INFO] Unset error cb");
int stt_set_default_language_changed_cb(stt_h stt, stt_default_language_changed_cb callback, void* user_data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
- if (NULL == callback)
- return STT_ERROR_INVALID_PARAMETER;
-
- if (STT_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == callback, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(STT_STATE_CREATED != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
SLOG(LOG_INFO, TAG_STTC, "[INFO] Set default language changed cb");
int stt_unset_default_language_changed_cb(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
- if (STT_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(STT_STATE_CREATED != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
SLOG(LOG_INFO, TAG_STTC, "[INFO] Unset default language changed cb");
int stt_set_engine_changed_cb(stt_h stt, stt_engine_changed_cb callback, void* user_data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
- if (NULL == callback)
- return STT_ERROR_INVALID_PARAMETER;
-
- if (STT_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == callback, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(STT_STATE_CREATED != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
SLOG(LOG_INFO, TAG_STTC, "[INFO] Set engine changed cb");
int stt_unset_engine_changed_cb(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
- if (STT_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(STT_STATE_CREATED != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
SLOG(LOG_INFO, TAG_STTC, "[INFO] Unset engine changed cb");
int stt_set_speech_status_cb(stt_h stt, stt_speech_status_cb callback, void* user_data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
-
- if (NULL == callback)
- return STT_ERROR_INVALID_PARAMETER;
- if (STT_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(NULL == callback, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
+ RETVM_IF(STT_STATE_CREATED != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
SLOG(LOG_INFO, TAG_STTC, "[INFO] Set speech status cb");
int stt_unset_speech_status_cb(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
- if (STT_STATE_CREATED != client->current_state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(STT_STATE_CREATED != client->current_state, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
SLOG(LOG_INFO, TAG_STTC, "[INFO] Unset speech status cb");
int stt_start_file(stt_h stt, const char* language, const char* type, const char* filepath, stt_audio_type_e audio_type, int sample_rate)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
- return temp;
- }
- if (NULL == filepath) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
- return STT_ERROR_INVALID_PARAMETER;
+ int tmp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != tmp) {
+ return tmp;
}
+ RETVM_IF(NULL == filepath, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL");
SLOG(LOG_INFO, TAG_STTC, "===== STT START FILE");
temp = strdup(language);
}
- if (NULL == temp) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory");
- return STT_ERROR_OUT_OF_MEMORY;
- }
+ RETVM_IF(NULL == temp, STT_ERROR_OUT_OF_MEMORY, "[ERROR] Fail to allocate memory");
if (true == client->credential_needed && NULL == client->credential) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Do not have app credential for this engine(%s)", client->current_engine_id);
int stt_cancel_file(stt_h stt)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
SLOG(LOG_INFO, TAG_STTC, "===== STT CANCEL FILE");
SLOG(LOG_DEBUG, TAG_STTC, "[STT] Change system volume, volume_event(%d)", volume_event);
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
/* check state */
if (client->current_state != STT_STATE_READY && client->current_state != STT_STATE_CREATED) {
SLOG(LOG_DEBUG, TAG_STTC, "[STT] recover system volume");
stt_client_s* client = NULL;
- int temp = __stt_check_precondition(stt, client);
- if (STT_ERROR_NONE != temp)) {
+ int temp = __stt_check_precondition(stt, &client);
+ if (STT_ERROR_NONE != temp)
return temp;
- }
/* check state */
if (client->current_state != STT_STATE_READY && client->current_state != STT_STATE_CREATED) {