return;
}
+static Eina_Bool __reconnect_by_engine_changed(void *data)
+{
+ stt_h stt = (stt_h)data;
+
+ stt_client_s* client = stt_client_get(stt);
+ if (NULL == client) {
+ SLOG(LOG_ERROR, TAG_STTC, "[WARNING] A handle is not valid");
+ return EINA_FALSE;
+ }
+
+ if (STT_STATE_READY != client->current_state) {
+ usleep(10000);
+ return EINA_TRUE;
+ }
+
+ int ret = stt_unprepare(stt);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
+ }
+ ret = stt_prepare(stt);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
+ }
+
+ return EINA_FALSE;
+}
+
void __stt_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, bool support_silence, bool need_credential, void* user_data)
{
stt_h stt = (stt_h)user_data;
if (NULL != language) SLOG(LOG_DEBUG, TAG_STTC, "Language(%s)", language);
SLOG(LOG_DEBUG, TAG_STTC, "Silence(%s), Credential(%s)", support_silence ? "on" : "off", need_credential ? "need" : "no need");
+ /* When the default engine is changed, please unload the old engine and load the new one. */
+ int ret = -1;
+
+ if (NULL == client->current_engine_id) {
+ if (STT_STATE_RECORDING == client->current_state || STT_STATE_PROCESSING == client->current_state) {
+ ret = stt_cancel(stt);
+ if (0 != ret) {
+ SLOG(LOG_DEBUG, TAG_STTC, "[DEBUG] STT client canceling...");
+ }
+
+ ecore_idler_add(__reconnect_by_engine_changed, (void*)stt);
+ } else if (STT_STATE_READY == client->current_state) {
+ ret = stt_unprepare(stt);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
+ }
+ ret = stt_prepare(stt);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
+ }
+ }
+ }
+
/* call callback function */
if (NULL != client->engine_changed_cb) {
client->engine_changed_cb(stt, engine_id, language, support_silence, need_credential, client->engine_changed_user_data);