/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
case STT_ERROR_ENGINE_NOT_FOUND: return "STT_ERROR_ENGINE_NOT_FOUND";
case STT_ERROR_OPERATION_FAILED: return "STT_ERROR_OPERATION_FAILED";
case STT_ERROR_NOT_SUPPORTED_FEATURE: return "STT_ERROR_NOT_SUPPORTED_FEATURE";
+ case STT_ERROR_SERVICE_RESET: return "STT_ERROR_SERVICE_RESET";
default:
return "Invalid error code";
}
int stt_destroy(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== Destroy STT");
-
- if (NULL == stt) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input handle is null");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
- return STT_ERROR_INVALID_PARAMETER;
- }
+ SLOG(LOG_DEBUG, TAG_STTC, "===== Destroy STT");
/* check used callback */
if (0 != stt_client_get_use_callback(client)) {
int stt_foreach_supported_engines(stt_h stt, stt_supported_engine_cb callback, void* user_data)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach Supported engine");
-
- if (NULL == stt || NULL == callback) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
+ SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach Supported engine");
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
int stt_get_engine(stt_h stt, char** engine_id)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== Get current engine");
-
- if (NULL == stt || NULL == engine_id) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ if (0 != __stt_check_privilege()) {
+ return STT_ERROR_PERMISSION_DENIED;
+ }
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
+ SLOG(LOG_DEBUG, TAG_STTC, "===== Get current engine");
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (NULL == engine_id) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
int stt_set_engine(stt_h stt, const char* engine_id)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== Set current engine");
-
- if (NULL == stt || NULL == engine_id) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
+ SLOG(LOG_DEBUG, TAG_STTC, "===== Set current engine");
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (NULL == engine_id) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
int stt_set_credential(stt_h stt, const char* credential)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== Set credential");
-
- if (NULL == stt || NULL == credential) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL, stt(%s), credential(%a)", stt, credential);
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
+ SLOG(LOG_DEBUG, TAG_STTC, "===== Set credential");
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (NULL == credential) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
int stt_set_private_data(stt_h stt, const char* key, const char* data)
{
stt_client_s* client = NULL;
-
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
int stt_get_private_data(stt_h stt, const char* key, char** data)
{
stt_client_s* client = NULL;
-
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
int stt_prepare(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== Prepare STT");
-
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
int stt_unprepare(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== Unprepare STT");
-
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
+ SLOG(LOG_DEBUG, 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);
int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callback, void* user_data)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach Supported Language");
-
- if (NULL == stt || NULL == callback) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
+ SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach Supported Language");
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
int stt_get_default_language(stt_h stt, char** language)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
+ if (0 != __stt_check_handle(stt, &client)) {
+ return STT_ERROR_INVALID_PARAMETER;
+ }
SLOG(LOG_DEBUG, TAG_STTC, "===== Get Default Language");
- if (NULL == stt || NULL == language) {
+ if (NULL == language) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
- return STT_ERROR_INVALID_PARAMETER;
- }
-
int ret = 0;
ret = stt_config_mgr_get_default_language(language);
ret = __stt_convert_config_error_code(ret);
int stt_get_state(stt_h stt, stt_state_e* state)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt || NULL == state) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
+ if (NULL == state) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
int stt_get_error_message(stt_h stt, char** err_msg)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
+ if (0 != __stt_check_handle(stt, &client)) {
+ return STT_ERROR_INVALID_PARAMETER;
+ }
- if (NULL == stt || NULL == err_msg) {
+ if (NULL == err_msg) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
return STT_ERROR_OPERATION_FAILED;
}
- stt_client_s* client = stt_client_get(stt);
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get error msg : A handle is not valid");
- return STT_ERROR_INVALID_PARAMETER;
- }
-
if (NULL != client->err_msg) {
*err_msg = strdup(client->err_msg);
SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Error msg (%s)", *err_msg);
int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt || NULL == type || NULL == support) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not valid");
+ if (NULL == type || NULL == support) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
- return STT_ERROR_INVALID_PARAMETER;
- }
-
- stt_client_s* client = stt_client_get(stt);
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
int stt_set_start_sound(stt_h stt, const char* filename)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
+ if (0 != __stt_check_handle(stt, &client)) {
+ return STT_ERROR_INVALID_PARAMETER;
+ }
SLOG(LOG_DEBUG, TAG_STTC, "===== STT SET START SOUND");
- if (NULL == stt || NULL == filename) {
+ if (NULL == filename) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
- 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);
int stt_unset_start_sound(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== STT UNSET START SOUND");
-
- if (NULL == stt) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
-
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
- return STT_ERROR_INVALID_PARAMETER;
- }
+ SLOG(LOG_DEBUG, TAG_STTC, "===== STT UNSET START SOUND");
/* check state */
if (client->current_state != STT_STATE_READY) {
int stt_set_stop_sound(stt_h stt, const char* filename)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
+ if (0 != __stt_check_handle(stt, &client)) {
+ return STT_ERROR_INVALID_PARAMETER;
+ }
SLOG(LOG_DEBUG, TAG_STTC, "===== STT SET STOP SOUND");
- if (NULL == stt || NULL == filename) {
+ if (NULL == filename) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
-
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
- 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);
int stt_unset_stop_sound(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== STT UNSET STOP SOUND");
-
- if (NULL == stt) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
-
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
- return STT_ERROR_INVALID_PARAMETER;
- }
+ SLOG(LOG_DEBUG, TAG_STTC, "===== STT UNSET STOP SOUND");
/* check state */
if (client->current_state != STT_STATE_READY) {
int stt_start(stt_h stt, const char* language, const char* type)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== STT START");
-
- if (NULL == stt) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
- return STT_ERROR_INVALID_PARAMETER;
- }
+ SLOG(LOG_DEBUG, TAG_STTC, "===== STT START");
/* check state */
if (client->current_state != STT_STATE_READY) {
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;
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;
}
if (NULL != temp) free(temp);
-#endif
+
SLOG(LOG_DEBUG, TAG_STTC, "=====");
SLOG(LOG_DEBUG, TAG_STTC, " ");
int stt_stop(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== STT STOP");
-
- if (NULL == stt) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
- return STT_ERROR_INVALID_PARAMETER;
- }
+ SLOG(LOG_DEBUG, TAG_STTC, "===== STT STOP");
/* check state */
if (client->current_state != STT_STATE_RECORDING) {
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);
- return STT_ERROR_INVALID_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);
+ return STT_ERROR_IN_PROGRESS_TO_RECORDING;
+ } else if (STT_INTERNAL_STATE_CANCELING == client->internal_state) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is CANCELING : %d", client->internal_state);
+ return STT_ERROR_IN_PROGRESS_TO_READY;
+ } else if (STT_INTERNAL_STATE_STOPPING == client->internal_state) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STOPPING : %d", client->internal_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) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to stop : %s", __stt_get_error_code(ret));
} else {
SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Stop is successful but not done");
- client->internal_state = STT_INTERNAL_STATE_STOPING;
+ client->internal_state = STT_INTERNAL_STATE_STOPPING;
}
-#endif
+
SLOG(LOG_DEBUG, TAG_STTC, "=====");
SLOG(LOG_DEBUG, TAG_STTC, " ");
int stt_cancel(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- SLOG(LOG_DEBUG, TAG_STTC, "===== STT CANCEL");
-
- if (NULL == stt) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input handle is null");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
- return STT_ERROR_INVALID_PARAMETER;
- }
+ SLOG(LOG_DEBUG, TAG_STTC, "===== STT CANCEL");
/* check state */
if (STT_STATE_RECORDING != client->current_state && STT_STATE_PROCESSING != 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);
- return STT_ERROR_INVALID_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);
+ return STT_ERROR_IN_PROGRESS_TO_RECORDING;
+ } else if (STT_INTERNAL_STATE_STOPPING == client->internal_state) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STOPPING : %d", client->internal_state);
+ return STT_ERROR_IN_PROGRESS_TO_PROCESSING;
+ } else if (STT_INTERNAL_STATE_CANCELING == client->internal_state) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is CANCELING : %d", client->internal_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));
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, " ");
int stt_get_recording_volume(stt_h stt, float* volume)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt || NULL == volume) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (NULL == volume) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
return STT_ERROR_INVALID_PARAMETER;
}
int stt_foreach_detailed_result(stt_h stt, stt_result_time_cb callback, void* user_data)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
+ if (0 != __stt_check_handle(stt, &client)) {
+ return STT_ERROR_INVALID_PARAMETER;
+ }
SLOG(LOG_DEBUG, TAG_STTC, "===== STT FOREACH DETAILED RESULT");
return STT_ERROR_INVALID_PARAMETER;
}
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail : A handle is not valid");
- return STT_ERROR_INVALID_PARAMETER;
- }
-
client->result_time_cb = callback;
client->result_time_user_data = user_data;
SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is null");
}
+ if (STT_ERROR_SERVICE_RESET == reason) {
+ SLOG(LOG_WARN, TAG_STTC, "[WARNING] Service reset");
+
+ client->current_state = STT_STATE_CREATED;
+ if (0 != stt_prepare(client->stt)) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare");
+ }
+ }
+
return 0;
}
if (STT_INTERNAL_STATE_STARTING == client->internal_state && STT_STATE_RECORDING == client->current_state) {
client->internal_state = STT_INTERNAL_STATE_NONE;
SLOG(LOG_DEBUG, TAG_STTC, "Internal state change to NONE");
- } else if (STT_INTERNAL_STATE_STOPING == client->internal_state && STT_STATE_PROCESSING == client->current_state) {
+ } else if (STT_INTERNAL_STATE_STOPPING == client->internal_state && STT_STATE_PROCESSING == client->current_state) {
client->internal_state = STT_INTERNAL_STATE_NONE;
SLOG(LOG_DEBUG, TAG_STTC, "Internal state change to NONE");
} else if (STT_INTERNAL_STATE_CANCELING == client->internal_state && STT_STATE_READY == client->current_state) {
int stt_set_recognition_result_cb(stt_h stt, stt_recognition_result_cb callback, void* user_data)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (stt == NULL || callback == NULL)
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
+ }
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (callback == NULL)
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);
int stt_unset_recognition_result_cb(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt)
- return STT_ERROR_INVALID_PARAMETER;
-
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* user_data)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt || NULL == callback)
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
+ }
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ 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);
int stt_unset_state_changed_cb(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt)
- return STT_ERROR_INVALID_PARAMETER;
-
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt || NULL == callback)
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
+ }
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ 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);
int stt_unset_error_cb(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt)
- return STT_ERROR_INVALID_PARAMETER;
-
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
int stt_set_default_language_changed_cb(stt_h stt, stt_default_language_changed_cb callback, void* user_data)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt || NULL == callback)
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
+ }
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ 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);
int stt_unset_default_language_changed_cb(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt)
- return STT_ERROR_INVALID_PARAMETER;
-
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}
int stt_set_engine_changed_cb(stt_h stt, stt_engine_changed_cb callback, void* user_data)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt || NULL == callback)
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
+ }
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ 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);
int stt_unset_engine_changed_cb(stt_h stt)
{
+ stt_client_s* client = NULL;
if (0 != __stt_get_feature_enabled()) {
return STT_ERROR_NOT_SUPPORTED;
}
if (0 != __stt_check_privilege()) {
return STT_ERROR_PERMISSION_DENIED;
}
-
- if (NULL == stt)
- return STT_ERROR_INVALID_PARAMETER;
-
- stt_client_s* client = stt_client_get(stt);
-
- /* check handle */
- if (NULL == client) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+ if (0 != __stt_check_handle(stt, &client)) {
return STT_ERROR_INVALID_PARAMETER;
}