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_with_state(stt, &client, STT_STATE_CREATED);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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);
SLOG(LOG_INFO, TAG_STTC, "===== Foreach Supported engine");
int stt_get_engine(stt_h stt, char** engine_id)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition_with_state(stt, &client, STT_STATE_CREATED);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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);
+
SLOG(LOG_INFO, TAG_STTC, "===== Get current engine");
int ret = 0;
SLOG(LOG_INFO, TAG_STTC, "===== Set credential");
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) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not CREATED or READY", client->current_state); //LCOV_EXCL_LINE
- return STT_ERROR_INVALID_STATE;
- }
+ RETVM_IF(client->current_state != STT_STATE_CREATED && client->current_state != STT_STATE_READY, STT_ERROR_INVALID_STATE,
+ "[ERROR] Invalid State: Current state(%d) is not CREATED or READY", client->current_state);
if (NULL != client->credential) {
free(client->credential);
int stt_set_private_data(stt_h stt, const char* key, const char* data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition_with_state(stt, &client, STT_STATE_READY);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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);
+
SLOG(LOG_INFO, TAG_STTC, "===== Set private data");
if (true != client->internal && (0 == strcmp(key, "server") || 0 == strcmp(key, "rampcode") || 0 == strcmp(key, "epd"))) {
int stt_get_private_data(stt_h stt, const char* key, char** data)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition_with_state(stt, &client, STT_STATE_READY);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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);
+
SLOG(LOG_INFO, TAG_STTC, "===== Get private data");
int ret = -1;
int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition_with_state(stt, &client, STT_STATE_READY);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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;
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition_with_state(stt, &client, STT_STATE_READY);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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);
SLOG(LOG_INFO, TAG_STTC, "===== STT SET START SOUND");
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition_with_state(stt, &client, STT_STATE_READY);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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);
+
SLOG(LOG_INFO, TAG_STTC, "===== STT SET STOP SOUND");
int ret = -1;
int stt_get_recording_volume(stt_h stt, float* volume)
{
stt_client_s* client = NULL;
- int temp = __stt_check_precondition_with_state(stt, &client, STT_STATE_RECORDING);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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_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_with_state(stt, &client, STT_STATE_CREATED);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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 recognition result cb");
client->recognition_result_cb = callback;
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_with_state(stt, &client, STT_STATE_CREATED);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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");
client->state_changed_cb = callback;
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_with_state(stt, &client, STT_STATE_CREATED);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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");
client->error_cb = callback;
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_with_state(stt, &client, STT_STATE_CREATED);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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");
client->default_lang_changed_cb = callback;
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_with_state(stt, &client, STT_STATE_CREATED);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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");
client->engine_changed_cb = callback;
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_with_state(stt, &client, STT_STATE_CREATED);
+ int temp = __stt_check_precondition(stt, &client);
if (STT_ERROR_NONE != temp)
return temp;
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");
client->speech_status_cb = callback;
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 tmp = __stt_check_precondition_with_state(stt, &client, STT_STATE_READY);
+ 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");
+ RETVM_IF(client->current_state != STT_STATE_READY, STT_ERROR_INVALID_STATE, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
+
SLOG(LOG_INFO, TAG_STTC, "===== STT START FILE");
if (STT_INTERNAL_STATE_NONE != client->internal_state) {