SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Unset service state changed cb");
return TTS_ERROR_NONE;
}
+
+int tts_set_synthesized_pcm_cb(tts_h tts, tts_synthesized_pcm_cb callback, void* user_data)
+{
+ RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
+
+ tts_client_s* client = tts_client_get(tts);
+ RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
+ RETVM_IF(NULL == callback, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Set synthesized pcm cb : Input parameter is null");
+
+ tts_state_e current_state = tts_client_get_current_state(client);
+ RETVM_IF(TTS_STATE_CREATED != current_state, TTS_ERROR_INVALID_STATE, "[ERROR] The current state(%d) is invalid", current_state);
+
+ tts_client_set_synthesized_pcm_cb(client, callback, user_data);
+
+ SLOG(LOG_INFO, TAG_TTSC, "[SUCCESS] Set synthesized pcm cb");
+ return TTS_ERROR_NONE;
+}
+
+int tts_unset_synthesized_pcm_cb(tts_h tts)
+{
+ RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
+
+ tts_client_s* client = tts_client_get(tts);
+ RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] A handle is not valid. tts(%p)", tts);
+
+ tts_state_e current_state = tts_client_get_current_state(client);
+ RETVM_IF(TTS_STATE_CREATED != current_state, TTS_ERROR_INVALID_STATE, "[ERROR] The current state(%d) is invalid", current_state);
+
+ tts_client_set_synthesized_pcm_cb(client, NULL, NULL);
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Unset synthesized pcm cb");
+ return TTS_ERROR_NONE;
+}
\ No newline at end of file
client->service_state_changed_user_data = user_data;
}
+static inline void __set_synthesized_pcm_cb(tts_client_s* client, tts_synthesized_pcm_cb callback, void* user_data)
+{
+ client->synthesized_pcm_cb = callback;
+ client->synthesized_pcm_user_data = user_data;
+}
+
int tts_client_new(tts_h* tts)
{
tts_client_s* client = (tts_client_s*)calloc(1, sizeof(tts_client_s));
__set_service_state_changed_cb(client, callback, user_data);
}
+void tts_client_set_synthesized_pcm_cb(tts_client_s* client, tts_synthesized_pcm_cb callback, void* user_data)
+{
+ if (false == tts_client_is_valid_client(client)) {
+ return;
+ }
+ __set_synthesized_pcm_cb(client, callback, user_data);
+}
+
tts_state_changed_cb tts_client_get_state_changed_cb(tts_client_s* client)
{
if (false == tts_client_is_valid_client(client)) {
return client->service_state_changed_user_data;
}
+tts_synthesized_pcm_cb tts_client_get_synthesized_pcm_cb(tts_client_s* client)
+{
+ if (false == tts_client_is_valid_client(client)) {
+ return NULL;
+ }
+ return client->synthesized_pcm_cb;
+}
+
+void* tts_client_get_synthesized_pcm_user_data(tts_client_s* client)
+{
+ if (false == tts_client_is_valid_client(client)) {
+ return NULL;
+ }
+ return client->synthesized_pcm_user_data;
+}
+
int tts_client_get_registered_event_mask(tts_client_s* client)
{
if (false == tts_client_is_valid_client(client)) {
__set_engine_changed_cb(client, NULL, NULL);
__set_supported_voice_cb(client, NULL, NULL);
__set_service_state_changed_cb(client, NULL, NULL);
+ __set_synthesized_pcm_cb(client, NULL, NULL);
}
\ No newline at end of file
void* supported_voice_user_data;
tts_service_state_changed_cb service_state_changed_cb;
void* service_state_changed_user_data;
+ tts_synthesized_pcm_cb synthesized_pcm_cb;
+ void* synthesized_pcm_user_data;
+
int registered_event_mask;
/* mode / state */
void tts_client_set_screen_reader_changed_cb(tts_client_s* client, tts_screen_reader_changed_cb callback, void* user_data);
void tts_client_set_supported_voice_cb(tts_client_s* client, tts_supported_voice_cb callback, void* user_data);
void tts_client_set_service_state_changed_cb(tts_client_s* client, tts_service_state_changed_cb callback, void* user_data);
+void tts_client_set_synthesized_pcm_cb(tts_client_s* client, tts_synthesized_pcm_cb callback, void* user_data);
tts_state_changed_cb tts_client_get_state_changed_cb(tts_client_s* client);
void* tts_client_get_state_changed_user_data(tts_client_s* client);
tts_service_state_changed_cb tts_client_get_service_state_changed_cb(tts_client_s* client);
void* tts_client_get_service_state_changed_user_data(tts_client_s* client);
+tts_synthesized_pcm_cb tts_client_get_synthesized_pcm_cb(tts_client_s* client);
+void* tts_client_get_synthesized_pcm_user_data(tts_client_s* client);
+
int tts_client_get_registered_event_mask(tts_client_s* client);
void tts_client_unset_all_cb(tts_client_s* client);
/**
+ * @brief Enumeration for synthesized pcm event.
+ * @since_tizen 7.5
+*/
+typedef enum {
+ TTS_SYNTHESIZED_PCM_EVENT_FAIL = -1, /**< 'Error' event */
+ TTS_SYNTHESIZED_PCM_EVENT_START, /**< 'Started' event */
+ TTS_SYNTHESIZED_PCM_EVENT_CONTINUE, /**< 'Finished' event */
+ TTS_SYNTHESIZED_PCM_EVENT_FINISH, /**< 'Finished' event */
+} tts_synthesized_pcm_event_e;
+
+
+/**
* @brief Definition for automatic speaking speed.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
*/
typedef void (*tts_service_state_changed_cb)(tts_h tts, tts_service_state_e previous, tts_service_state_e current, void* user_data);
+
+/**
+ * @brief Called when the synthesized pcm data is come from the engine.
+ * @since_tizen 7.5
+ * @remarks The @a tts handle should not be destroyed in the callback.
+ * @param[in] tts The TTS handle, the same handle for which the callback was set.
+ * @param[in] event The event type
+ * @param[in] buffer The synthesized pcm data
+ * @param[in] buffer_size The size of the buffer
+ * @param[in] user_data The user data passed from the callback registration function
+ * @pre An application registers this callback using tts_set_synthesized_pcm_cb() to get pcm data.
+ * @see tts_set_synthesized_pcm_cb()
+ * @see tts_unset_synthesized_pcm_cb()
+ */
+typedef void (*tts_synthesized_pcm_cb)(tts_h tts, tts_synthesized_pcm_event_e event, char* buffer, int buffer_size, void *user_data);
+
+
/**
* @brief Creates a handle for TTS.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
int tts_unset_service_state_changed_cb(tts_h tts);
+
+/**
+ * @brief Sets the default to be called when the synthesized pcm data is recieved.
+ * @since_tizen 7.5
+ * @param[in] tts The TTS handle
+ * @param callback The callback function to register
+ * @param user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @pre The TTS state should be #TTS_STATE_CREATED.
+ * @see tts_synthesized_pcm_cb()
+ * @see tts_unset_synthesized_pcm_cb()
+ */
+int tts_set_synthesized_pcm_cb(tts_h tts, tts_synthesized_pcm_cb callback, void* user_data);
+
+
+/**
+ * @brief Unsets the callback function.
+ * @since_tizen 7.5
+ * @param tts The TTS handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @pre The TTS state should be #TTS_STATE_CREATED.
+ * @see tts_set_synthesized_pcm_cb()
+ */
+int tts_unset_synthesized_pcm_cb(tts_h tts);
+
#ifdef __cplusplus
}
#endif