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";
}
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;
}
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_RECORDING_TIMED_OUT = TIZEN_ERROR_STT | 0x10 /**< Recording timed out */
+ STT_ERROR_RECORDING_TIMED_OUT = TIZEN_ERROR_STT | 0x10, /**< Recording timed out */
+ STT_ERROR_SERVICE_RESET = TIZEN_ERROR_STT | 0x11 /**< Service reset */
} stt_error_e;
/**
STTD_ERROR_OPERATION_FAILED = TIZEN_ERROR_STT | 0x04, /**< Operation failed */
STTD_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_STT | 0x05, /**< Not supported feature of current engine */
STTD_ERROR_NO_SPEECH = TIZEN_ERROR_STT | 0x06, /**< No speech while recording */
- STTD_ERROR_RECORDING_TIMED_OUT = TIZEN_ERROR_STT | 0x10 /**< Recording timed out */
+ STTD_ERROR_RECORDING_TIMED_OUT = TIZEN_ERROR_STT | 0x10, /**< Recording timed out */
+ STTD_ERROR_SERVICE_RESET = TIZEN_ERROR_STT | 0x11 /**< Service reset */
} stt_error_e;
typedef enum {
* Daemon function
*/
+static void __sig_handler(int signo)
+{
+ /* restore signal handler */
+ signal(signo, SIG_DFL);
+
+ /* Send error signal to clients */
+ int* client_list = NULL;
+ int client_count = 0;
+ int i = 0;
+ if (0 != sttd_client_get_list(&client_list, &client_count)) {
+ if (NULL != client_list)
+ free(client_list);
+ }
+
+ if (NULL != client_list) {
+ for (i = 0; i < client_count; i++) {
+ sttdc_send_error_signal(client_list[i], STTD_ERROR_SERVICE_RESET, "Service Reset");
+ }
+ free(client_list);
+ }
+
+ /* invoke signal again */
+ raise(signo);
+}
+
+static void __register_sig_handler()
+{
+ signal(SIGSEGV, __sig_handler);
+ signal(SIGABRT, __sig_handler);
+ signal(SIGTERM, __sig_handler);
+ signal(SIGINT, __sig_handler);
+ signal(SIGQUIT, __sig_handler);
+}
+
int sttd_initialize()
{
int ret = 0;
+ __register_sig_handler();
+
if (0 != pthread_mutex_init(&sttpe_result_mutex, NULL)) {
SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to initialize sttpe result mutex.");
}