int index = 0;
index = ttsd_data_is_client(uid);
+ SLOG(LOG_DEBUG, tts_tag(), "[DATA] sound_data_s: %p", *data);
+
if (index < 0) {
SECURE_SLOG(LOG_ERROR, tts_tag(), "[DATA ERROR] uid is not valid (%d)", uid);
return TTSD_ERROR_INVALID_PARAMETER;
return data_size;
}
+int ttsd_data_clear_speak_data(speak_data_s** speak_data)
+{
+ pthread_mutex_lock(&g_speak_data_mutex);
+
+ if (NULL != *speak_data) {
+ SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] utt(%d), text(%s), lang(%s), vctype(%d) speed(%d)",
+ (*speak_data)->utt_id, (*speak_data)->text, (*speak_data)->lang, (*speak_data)->vctype, (*speak_data)->speed);
+
+ if (NULL != (*speak_data)->text) {
+ free((*speak_data)->text);
+ (*speak_data)->text = NULL;
+ }
+ if (NULL != (*speak_data)->lang) {
+ free((*speak_data)->lang);
+ (*speak_data)->lang = NULL;
+ }
+
+ free(*speak_data);
+ *speak_data = NULL;
+ }
+
+ pthread_mutex_unlock(&g_speak_data_mutex);
+
+ return TTSD_ERROR_NONE;
+}
+
+int ttsd_data_clear_sound_data(sound_data_s** sound_data)
+{
+ pthread_mutex_lock(&g_sound_data_mutex);
+
+ if (NULL != *sound_data) {
+ SLOG(LOG_ERROR, tts_tag(), "[DEBUG][%p] event(%d) data(%p) size(%d) rate(%d) utt(%d)",
+ (*sound_data), (*sound_data)->event, (*sound_data)->data, (*sound_data)->data_size, (*sound_data)->rate, (*sound_data)->utt_id);
+
+ if (NULL != (*sound_data)->data) {
+ free((*sound_data)->data);
+ (*sound_data)->data = NULL;
+ }
+
+ free(*sound_data);
+ *sound_data = NULL;
+ }
+
+ pthread_mutex_unlock(&g_sound_data_mutex);
+
+ return TTSD_ERROR_NONE;
+}
+
int ttsd_data_clear_data(int uid)
{
int index = 0;
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
+ ttsd_data_clear_sound_data(&sound_data);
return;
}
SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
+ ttsd_data_clear_sound_data(&sound_data);
return;
}
if (0 != ttsdc_send_utt_finish_message(pid, player->uid, sound_data->utt_id)) {
}
}
SLOG(LOG_INFO, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
+ ttsd_data_clear_sound_data(&sound_data);
continue;
}
}
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
+ ttsd_data_clear_sound_data(&sound_data);
return;
}
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
-
- free(sound_data);
- sound_data = NULL;
+ ttsd_data_clear_sound_data(&sound_data);
return;
}
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data) {
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
-
- free(sound_data);
- sound_data = NULL;
- }
+ ttsd_data_clear_sound_data(&sound_data);
return;
}
SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Unprepare audio");
}
- if (NULL != sound_data) {
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
-
- free(sound_data);
- sound_data = NULL;
- }
+ ttsd_data_clear_sound_data(&sound_data);
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
return;
SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
+ ttsd_data_clear_sound_data(&sound_data);
return;
}
pid, player->uid, sound_data->utt_id);
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
+ ttsd_data_clear_sound_data(&sound_data);
return;
}
SLOG(LOG_INFO, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
}
- if (NULL != sound_data) {
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
-
- free(sound_data);
- sound_data = NULL;
- }
+ ttsd_data_clear_sound_data(&sound_data);
if (NULL == g_playing_info) {
SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Current player is NULL");
ttsdc_send_set_state_message(pid, uid, APP_STATE_READY);
- if (NULL != speak_data) {
- if (NULL != speak_data->lang) free(speak_data->lang);
- if (NULL != speak_data->text) free(speak_data->text);
-
- speak_data->lang = NULL;
- speak_data->text = NULL;
-
- free(speak_data);
- speak_data = NULL;
- }
+ ttsd_data_clear_speak_data(&speak_data);
return 0;
}
g_wait_timer = ecore_timer_add(0.05, __wait_synthesis, (void*)credential);
}
- if (NULL != speak_data) {
- if (NULL != speak_data->lang) free(speak_data->lang);
- if (NULL != speak_data->text) free(speak_data->text);
-
- speak_data->lang = NULL;
- speak_data->text = NULL;
-
- free(speak_data);
- speak_data = NULL;
- }
+ ttsd_data_clear_speak_data(&speak_data);
+ } else {
+ ttsd_data_clear_speak_data(&speak_data);
}
SLOG(LOG_DEBUG, tts_tag(), "@@@ SYNTHESIS END");