return 0;
}
+static void __recorder_destroy(void* data)
+{
+ sttp_result_event_e event = (sttp_result_event_e)data;
+
+ SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Destroy recorder by ecore_thread_safe func");
+
+ if (0 != sttd_recorder_destroy(g_recording_engine_id)) {
+ SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to destroy recorder(%d)", g_recording_engine_id);
+ }
+
+ if (event == STTP_RESULT_EVENT_FINAL_RESULT || event == STTP_RESULT_EVENT_ERROR) {
+ g_recording_engine_id = -1;
+ }
+}
+
+
/*
* STT Engine Callback Functions ` *
*/
#ifdef AUDIO_CREATE_ON_START
if (event == STTP_RESULT_EVENT_ERROR) {
+#if 1
+ ecore_main_loop_thread_safe_call_async(__recorder_destroy, (void*)event);
+#else
SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Destroy recorder");
if (0 != sttd_recorder_destroy(g_recording_engine_id))
SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to destroy recorder(%d)", g_recording_engine_id);
+#endif
}
#endif
+#ifndef AUDIO_CREATE_ON_START
if (event == STTP_RESULT_EVENT_FINAL_RESULT || event == STTP_RESULT_EVENT_ERROR) {
g_recording_engine_id = -1;
}
-
+#endif
return;
}
if (NULL != recorder) {
g_recorder_list = g_slist_remove(g_recorder_list, recorder);
- audio_in_destroy(recorder->audio_h);
-
+ if(recorder->audio_h) {
+ audio_in_destroy(recorder->audio_h);
+ recorder->audio_h = NULL;
+ }
free(recorder);
}
recorder = (stt_recorder_s*)calloc(1, sizeof(stt_recorder_s));
if (NULL == recorder) {
#ifndef TV_BT_MODE
- audio_in_destroy(temp_in_h);
+ if (temp_in_h) {
+ audio_in_destroy(temp_in_h);
+ temp_in_h = NULL;
+ }
#endif
SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to allocate memory");
return STTD_ERROR_OUT_OF_MEMORY;
#ifndef TV_BT_MODE
int ret;
if (STTD_RECORDER_STATE_RECORDING == g_recorder_state) {
- ret = audio_in_unprepare(recorder->audio_h);
- if (AUDIO_IO_ERROR_NONE != ret) {
- SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unprepare audioin : %d", ret);
+ if (recorder->audio_h) {
+ ret = audio_in_unprepare(recorder->audio_h);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unprepare audioin : %d", ret);
+ }
}
g_recorder_state = STTD_RECORDER_STATE_READY;
}
- ret = audio_in_destroy(recorder->audio_h);
- if (AUDIO_IO_ERROR_NONE != ret) {
- SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to destroy audioin : %d", ret);
+ if (recorder->audio_h) {
+ ret = audio_in_destroy(recorder->audio_h);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to destroy audioin : %d", ret);
+ }
+ recorder->audio_h = NULL;
}
#else
if (STTD_RECORDER_STATE_RECORDING == g_recorder_state) {