From: Wonnam Jang Date: Thu, 2 Jun 2016 10:58:54 +0000 (+0900) Subject: Add error types X-Git-Tag: accepted/tizen/common/20160614.144211~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F72785%2F3;p=platform%2Fcore%2Fuifw%2Fstt.git Add error types Change-Id: I5733d625d42cbd5166f9297241f8962ff19bac63 Signed-off-by: Wonnam Jang --- diff --git a/client/stt.c b/client/stt.c index 19e7cb1..5fb6f49 100644 --- a/client/stt.c +++ b/client/stt.c @@ -1446,7 +1446,7 @@ int stt_start(stt_h stt, const char* language, const char* type) 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); - return STT_ERROR_INVALID_STATE; + return STT_ERROR_IN_PROGRESS_TO_RECORDING; } int ret = -1; @@ -1466,54 +1466,6 @@ int stt_start(stt_h stt, const char* language, const char* type) temp = strdup(language); } -#if 0 - ret = -1; - /* do request */ - int count = 0; - while (0 != ret) { - ret = stt_dbus_request_start(client->uid, temp, type, client->silence, appid); - if (0 > ret) { - /* Failure */ - if (STT_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start : %s", __stt_get_error_code(ret)); - if (NULL != temp) free(temp); - return ret; - } else { - SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry to start"); - usleep(10000); - count++; - if (STT_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request"); - if (NULL != temp) free(temp); - return ret; - } - } - } else { - /* Success */ - if (NULL != temp) free(temp); - - if (STT_RESULT_STATE_DONE == ret) { - SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Start is done : %d", ret); - client->before_state = client->current_state; - client->current_state = STT_STATE_RECORDING; - - if (NULL != client->state_changed_cb) { - ecore_main_loop_thread_safe_call_async(__stt_notify_state_changed, client); - } else { - SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null"); - } - } else if (STT_RESULT_STATE_NOT_DONE == ret) { - SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Start is not done : %d", ret); - client->internal_state = STT_INTERNAL_STATE_STARTING; - } else { - SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid result : %d", ret); - } - - ret = STT_ERROR_NONE; - break; - } - } -#else 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); return STT_ERROR_PERMISSION_DENIED; @@ -1528,7 +1480,7 @@ int stt_start(stt_h stt, const char* language, const char* type) } if (NULL != temp) free(temp); -#endif + SLOG(LOG_DEBUG, TAG_STTC, "====="); SLOG(LOG_DEBUG, TAG_STTC, " "); @@ -1565,51 +1517,9 @@ int stt_stop(stt_h stt) 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); - return STT_ERROR_INVALID_STATE; + return STT_ERROR_IN_PROGRESS_TO_PROCESSING; } -#if 0 - int ret = -1; - /* do request */ - int count = 0; - while (0 != ret) { - ret = stt_dbus_request_stop(client->uid); - if (0 > ret) { - /* Failure */ - if (STT_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to stop : %s", __stt_get_error_code(ret)); - return ret; - } else { - SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry stop"); - usleep(10000); - count++; - if (STT_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request"); - return ret; - } - } - } else { - if (STT_RESULT_STATE_DONE == ret) { - SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Stop is done : %d", ret); - client->before_state = client->current_state; - client->current_state = STT_STATE_PROCESSING; - - if (NULL != client->state_changed_cb) { - ecore_main_loop_thread_safe_call_async(__stt_notify_state_changed, client); - SLOG(LOG_DEBUG, TAG_STTC, "State changed callback is called"); - } else { - SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null"); - } - } else if (STT_RESULT_STATE_NOT_DONE == ret) { - SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Stop is not done : %d", ret); - client->internal_state = STT_INTERNAL_STATE_STOPING; - } else { - SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid result : %d", ret); - } - ret = STT_ERROR_NONE; - break; - } - } -#else + int ret = stt_dbus_request_stop(client->uid); if (0 != ret) { @@ -1618,7 +1528,7 @@ int stt_stop(stt_h stt) SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Stop is successful but not done"); client->internal_state = STT_INTERNAL_STATE_STOPING; } -#endif + SLOG(LOG_DEBUG, TAG_STTC, "====="); SLOG(LOG_DEBUG, TAG_STTC, " "); @@ -1658,45 +1568,9 @@ int stt_cancel(stt_h stt) 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); - return STT_ERROR_INVALID_STATE; + return STT_ERROR_IN_PROGRESS_TO_READY; } -#if 0 - int ret = -1; - /* do request */ - int count = 0; - while (0 != ret) { - ret = stt_dbus_request_cancel(client->uid); - if (0 != ret) { - /* Failure */ - if (STT_ERROR_TIMED_OUT != ret) { - SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Fail to cancel : %s", __stt_get_error_code(ret)); - return ret; - } else { - SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry"); - usleep(10000); - count++; - if (STT_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request"); - return ret; - } - } - } else { - SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]"); - - client->before_state = client->current_state; - client->current_state = STT_STATE_READY; - if (NULL != client->state_changed_cb) { - ecore_main_loop_thread_safe_call_async(__stt_notify_state_changed, client); - SLOG(LOG_DEBUG, TAG_STTC, "State changed callback is called"); - } else { - SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null"); - } - ret = STT_ERROR_NONE; - break; - } - } -#else int ret = stt_dbus_request_cancel(client->uid); if (0 != ret) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to cancel : %s", __stt_get_error_code(ret)); @@ -1704,7 +1578,7 @@ int stt_cancel(stt_h stt) SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Cancel is successful but not done"); client->internal_state = STT_INTERNAL_STATE_CANCELING; } -#endif + SLOG(LOG_DEBUG, TAG_STTC, "====="); SLOG(LOG_DEBUG, TAG_STTC, " "); diff --git a/include/stt.h b/include/stt.h index 30b3ff7..113cb1c 100644 --- a/include/stt.h +++ b/include/stt.h @@ -52,7 +52,10 @@ typedef enum { STT_ERROR_ENGINE_NOT_FOUND = TIZEN_ERROR_STT | 0x03, /**< No available engine */ STT_ERROR_OPERATION_FAILED = TIZEN_ERROR_STT | 0x04, /**< Operation failed */ STT_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_STT | 0x05, /**< Not supported feature of current engine */ - STT_ERROR_NO_SPEECH = TIZEN_ERROR_STT | 0x06 /**< No speech while recording */ + STT_ERROR_NO_SPEECH = TIZEN_ERROR_STT | 0x06, /**< No speech while recording */ + STT_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_STT | 0x07, /**< Progress to ready is not finished */ + STT_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_STT | 0x08, /**< Progress to recording is not finished */ + STT_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_STT | 0x09 /**< Progress to processing is not finished */ } stt_error_e; /** @@ -764,10 +767,12 @@ int stt_unset_stop_sound(stt_h stt); * @retval #STT_ERROR_RECORDER_BUSY Recorder busy * @retval #STT_ERROR_INVALID_LANGUAGE Invalid language * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported + * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished * * @pre The state should be #STT_STATE_READY. * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n * If this function succeeds, the STT state will be #STT_STATE_RECORDING. + * If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_RECORDING. * * @see stt_stop() * @see stt_cancel() @@ -789,10 +794,12 @@ int stt_start(stt_h stt, const char* language, const char* type); * @retval #STT_ERROR_INVALID_STATE Invalid state * @retval #STT_ERROR_OPERATION_FAILED Operation failure * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported + * @retval #STT_ERROR_IN_PROGRESS_TO_PROCESSING Progress to processing is not finished * * @pre The state should be #STT_STATE_RECORDING. * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n * If this function succeeds, the STT state will be #STT_STATE_PROCESSING. \n + * If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_PROCESSING. * After processing of engine, stt_result_cb() is called. * * @see stt_start() @@ -818,10 +825,12 @@ int stt_stop(stt_h stt); * @retval #STT_ERROR_INVALID_STATE Invalid state * @retval #STT_ERROR_OPERATION_FAILED Operation failure * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported + * @retval #STT_ERROR_IN_PROGRESS_TO_READY Progress to ready is not finished * * @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING. * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n * If this function succeeds, the STT state will be #STT_STATE_READY. + * If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_READY. * * @see stt_start() * @see stt_stop()