if (STTD_RECORDER_STATE_READY == g_recorder_state)
return 0;
+ // critical section required because this function can be called from stt engine thread context
+ SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Enter critical section");
+ pthread_mutex_lock(&sttd_audio_in_handle_mutex);
+
/* Check engine id is valid */
if (NULL == g_recorder) {
SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Engine id is not valid");
+ pthread_mutex_unlock(&sttd_audio_in_handle_mutex);
return STTD_ERROR_INVALID_PARAMETER;
}
#ifdef BUF_SAVE_MODE
fclose(g_pFile);
#endif
+ pthread_mutex_unlock(&sttd_audio_in_handle_mutex);
+ SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Leave critical section");
return 0;
}