Make ttse_set_personal_tts_id_cb optional callback 49/314249/1
authorsooyeon <sooyeon.kim@samsung.com>
Tue, 9 Jul 2024 08:19:00 +0000 (17:19 +0900)
committersooyeon <sooyeon.kim@samsung.com>
Tue, 9 Jul 2024 08:19:00 +0000 (17:19 +0900)
Change-Id: I6ac487d6d79aa8ab3b55a50c7df68402cbf67e9e
Signed-off-by: sooyeon <sooyeon.kim@samsung.com>
include/ttse.h
server/ttsd_engine_agent.c
server/ttsd_engine_agent.h
server/ttsd_main.h
server/ttsd_server.c
server/ttsd_server.h
server/ttse.c

index 1e5b0a4883e97e41eb8ca8e4ad93b0a536fd763e..df897fa09f975035ed6d8c46a1c4cf0bda59875e 100755 (executable)
@@ -210,7 +210,7 @@ typedef int (*ttse_set_pitch_cb)(int pitch);
 /**
 * @brief Called when the engine service user sets the personal tts id of TTS engine.
 * @since_tizen 9.0
-* @remarks This callback function is mandatory and must be registered using ttse_main().
+* @remarks This callback function is optional and is registered using ttse_set_personal_tts_id_set_cb().
 * @param[in] ptts_id The personal tts id
 * @return @c 0 on success,
 *         otherwise a negative error value
@@ -219,7 +219,7 @@ typedef int (*ttse_set_pitch_cb)(int pitch);
 * @retval #TTSE_ERROR_INVALID_STATE Not initialized
 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
 */
-typedef int (*ttse_set_personal_tts_id)(const char* ptts_id);
+typedef int (*ttse_set_personal_tts_id_cb)(const char* ptts_id);
 
 
 /**
@@ -432,7 +432,6 @@ typedef struct {
        ttse_foreach_supported_voices_cb        foreach_voices; /**< Called when the engine service user gets the whole supported voice list */
        ttse_is_valid_voice_cb                  is_valid_voice; /**< Called when the engine service user checks whether the voice is valid or not in TTS engine */
        ttse_set_pitch_cb                       set_pitch; /**< Called when the engine service user sets the default pitch of TTS engine */
-       ttse_set_personal_tts_id                set_personal_tts_id; /**< Called when the engine service user sets the personal tts of TTS engine */
 
        ttse_load_voice_cb                      load_voice; /**< Called when the engine service user requests to load the corresponding voice type for the first time */
        ttse_unload_voice_cb                    unload_voice; /**< Called when the engine service user requests to unload the corresponding voice type or to stop using voice */
@@ -703,6 +702,24 @@ int ttse_get_activated_mode(int* activated_mode);
 int ttse_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback);
 
 
+/**
+* @brief Sets a callback function to be called when a personal TTS id is set.
+* @since_tizen 9.0
+* @remarks The ttse_set_personal_tts_id_cb() function is called when the activated TTS modes are changed.
+* @param[in] callback ttse_activated_mode_changed event callback function
+* @return @c 0 on success,
+*         otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_NOT_SUPPORTED TTS NOT supported
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_INVALID_STATE Not initialized
+* @pre The ttse_main() function should be invoked before this function is called.
+* @see ttse_activated_mode_changed_cb()
+* @see ttse_get_activated_mode()
+*/
+int ttse_set_personal_tts_id_set_cb(ttse_set_personal_tts_id_cb callback);
+
+
 #ifdef __cplusplus
 }
 #endif
index 169c96df9d7d272d02d047a90730444523a16370..92426e756c8ca0b72a32cd92fda192e1ee0d5a99 100644 (file)
@@ -824,6 +824,11 @@ int ttsd_engine_agent_set_personal_tts_id(const char* ptts_id)
                return ret;
        }
 
+       if (NULL == g_engine_info->callbacks->set_personal_tts_id) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Personal tts is not supported. Fail to set personal tts id.");
+               return TTSD_ERROR_NOT_SUPPORTED_FEATURE;
+       }
+
        ret = g_engine_info->callbacks->set_personal_tts_id(ptts_id);
        if (0 != ret) {
                SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to set personal tts id : ptts_id(%s), result(%s)",
@@ -1322,3 +1327,15 @@ int ttsd_engine_agent_set_activated_mode_changed_cb(ttse_activated_mode_changed_
 
        return TTSD_ERROR_NONE;
 }
+
+int ttsd_engine_agent_set_personal_tts_id_set_cb(ttse_set_personal_tts_id_cb callback)
+{
+       if (false == __is_agent_initialized()) {
+               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
+               return TTSD_ERROR_INVALID_STATE;
+       }
+
+       g_engine_info->callbacks->set_personal_tts_id = callback;
+
+       return TTSD_ERROR_NONE;
+}
\ No newline at end of file
index 1376a3e0b43323196f44f2fb7184f8c80e938ed8..a84ccbfb34484acff2145afc9015634e73b8fc5f 100644 (file)
@@ -40,6 +40,7 @@ int ttsd_engine_agent_load_current_engine();
 int ttsd_engine_agent_set_private_data_set_cb(ttse_private_data_set_cb callback);
 int ttsd_engine_agent_set_private_data_requested_cb(ttse_private_data_requested_cb callback);
 int ttsd_engine_agent_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback);
+int ttsd_engine_agent_set_personal_tts_id_set_cb(ttse_set_personal_tts_id_cb callback);
 
 /** Unload current engine */
 int ttsd_engine_agent_unload_current_engine();
index 7fa915ac0a54afe4ce5303ba1988d1ff3c56458f..8d85c89d5a82e51edc4a5d54d693ac429eb0ed4a 100644 (file)
@@ -100,7 +100,7 @@ typedef struct {
        ttse_foreach_supported_voices_cb        foreach_voices;
        ttse_is_valid_voice_cb                  is_valid_voice;
        ttse_set_pitch_cb                       set_pitch;
-       ttse_set_personal_tts_id                set_personal_tts_id;
+       ttse_set_personal_tts_id_cb             set_personal_tts_id;
 
        ttse_load_voice_cb                      load_voice;
        ttse_unload_voice_cb                    unload_voice;
index ea6c746286226bf700401df1fec1adcd50f16a78..ed7bfca7d89731ffc91d6c8f136e259529795590 100644 (file)
@@ -1604,6 +1604,16 @@ int ttsd_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback)
        return ret;
 }
 
+int ttsd_set_personal_tts_id_set_cb(ttse_set_personal_tts_id_cb callback)
+{
+       int ret = ttsd_engine_agent_set_personal_tts_id_set_cb(callback);
+       if (TTSD_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set personal tts id set cb : ret(%d)", ret);
+       }
+
+       return ret;
+}
+
 int ttsd_server_play_pcm(unsigned int uid)
 {
        app_tts_state_e state = ttsd_data_get_client_state(uid);
index f04998c6c99a2919bcd1594ca03c5cf43a421796..ea20c7b703d9a844f5bdde328de7b3b7ee801646 100644 (file)
@@ -43,6 +43,9 @@ int ttsd_set_private_data_requested_cb(ttse_private_data_requested_cb callback);
 int ttsd_get_activated_mode(int* activated_mode);
 int ttsd_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback);
 
+int ttsd_set_personal_tts_id_set_cb(ttse_set_personal_tts_id_cb callback);
+
+
 /*
 * Server API for client
 */
index ba01bc0007559d4d787cdc29044ecfab2c48267b..67a159bd5f305ee2f20dfed507a191e70a941330 100755 (executable)
@@ -352,3 +352,27 @@ int ttse_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback)
 
        return ret;
 }
+
+int ttse_set_personal_tts_id_set_cb(ttse_set_personal_tts_id_cb callback)
+{
+       if (false == is_feature_enabled()) {
+               return TTSE_ERROR_NOT_SUPPORTED;
+       }
+
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter");
+               return TTSE_ERROR_INVALID_PARAMETER;
+       }
+
+       if (false == g_is_started) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Service engine is not started.");
+               return TTSE_ERROR_INVALID_STATE;
+       }
+
+       int ret = ttsd_set_personal_tts_id_set_cb(callback);
+       if (TTSD_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to set personal tts id set cb. ret(%d/%s)", ret, get_error_message(ret));
+       }
+
+       return ret;
+}