return TTS_ERROR_NONE;
}
-static bool __tts_supported_voice_cb(const char* engine_id, const char* language, int type, void* user_data)
-{
- tts_client_s* client = (tts_client_s*)user_data;
-
- /* call callback function */
- // TODO: pass return value of callback
- tts_core_notify_supported_voice(client, language, type);
- return false;
-}
-
int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, void* user_data)
{
if (0 != __tts_get_feature_enabled()) {
int ret = 0;
char* current_engine = NULL;
ret = tts_config_mgr_get_engine(¤t_engine);
- if (0 != ret) {
+ if (0 != ret || NULL == current_engine) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get current engine : %d", ret);
return __tts_convert_config_error_code(ret);
}
- tts_client_set_supported_voice_cb(client, callback, user_data);
- ret = tts_config_mgr_get_voice_list(current_engine, __tts_supported_voice_cb, client);
- tts_client_set_supported_voice_cb(client, NULL, NULL);
+ ret = tts_core_foreach_supported_voices(client, current_engine, callback, user_data);
if (NULL != current_engine) {
free(current_engine);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Result : %d", ret);
- ret = TTS_ERROR_OPERATION_FAILED;
}
SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
-
return ret;
}
return;
}
+static bool __supported_voice_cb(const char* engine_id, const char* language, int type, void* user_data)
+{
+ int uid = (int)user_data;
+ tts_client_s* client = tts_client_get_by_uid(uid);
+ if (NULL == client) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Uid is not valid. (%d)", uid);
+ return false;
+ }
+
+ /* call callback function */
+ tts_supported_voice_cb callback = tts_client_get_supported_voice_cb(client);
+ void* data = tts_client_get_supported_voice_user_data(client);
+
+ if (NULL != callback) {
+ return callback(tts_client_get_handle(client), language, type, data);
+ }
+
+ return false;
+}
/* Public functions */
int tts_core_initialize()
return TTS_ERROR_NONE;
}
-int tts_core_notify_supported_voice(tts_client_s* client, const char* language, int voice_type)
-{
- /* check handle */
- if (NULL == client || false == tts_client_is_valid(client->uid)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Handle is not valid.");
- return TTS_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == language) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid parameter.");
- return TTS_ERROR_INVALID_PARAMETER;
- }
-
- SLOG(LOG_DEBUG, TAG_TTSC, "Supported voice data : language(%s), voicd_type(%d)", language, voice_type);
-
- if (NULL != client->supported_voice_cb) {
- SLOG(LOG_DEBUG, TAG_TTSC, "Notify supported voice");
- tts_client_use_callback(client);
- client->supported_voice_cb(tts_client_get_handle(client), language, voice_type, client->supported_voice_user_data);
- tts_client_not_use_callback(client);
- } else {
- SLOG(LOG_WARN, TAG_TTSC, "No registered callback(supported_voice)");
- }
-
- return TTS_ERROR_NONE;
-}
-
int tts_core_receive_hello(int uid, int ret, int credential_needed)
{
tts_client_s* client = tts_client_get_by_uid(uid);
return TTS_ERROR_NONE;
}
+
+int tts_core_foreach_supported_voices(tts_client_s* client, const char* engine_id, tts_supported_voice_cb callback, void* user_data)
+{
+ tts_client_set_supported_voice_cb(client, callback, user_data);
+ int ret = tts_config_mgr_get_voice_list(engine_id, __supported_voice_cb, (void*)client->uid);
+ tts_client_set_supported_voice_cb(client, NULL, NULL);
+
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get voice list");
+ return TTS_ERROR_OPERATION_FAILED;
+ }
+
+ return TTS_ERROR_NONE;
+}
int tts_core_notify_error_async(tts_client_s* client, int utt_id, tts_error_e reason);
int tts_core_notify_default_voice_changed(tts_client_s* client, const char* before_lang, int before_voice_type, const char* language, int voice_type);
int tts_core_notify_engine_changed(tts_client_s* client, const char* engine_id, const char* language, int voice_type, bool need_credential);
-int tts_core_notify_supported_voice(tts_client_s* client, const char* language, int voice_type);
// called by tts.c
int tts_core_initialize();
int tts_core_unprepare(tts_client_s* client, bool is_screen_reader_on);
int tts_core_reprepare();
+int tts_core_foreach_supported_voices(tts_client_s* client, const char* engine_id, tts_supported_voice_cb callback, void* user_data);
+
// called by tts_dbus.c
int tts_core_receive_hello(int uid, int ret, int credential_needed);