static int __synthesis(int uid, const char* credential)
{
- SLOG(LOG_DEBUG, tts_tag(), "===== SYNTHESIS START");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@ SYNTHESIS START");
speak_data_s* speak_data = NULL;
if (0 == ttsd_data_get_speak_data(uid, &speak_data)) {
}
}
- SLOG(LOG_DEBUG, tts_tag(), "===== SYNTHESIS END");
- SLOG(LOG_DEBUG, tts_tag(), " ");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@ SYNTHESIS END");
return 0;
}
int ttsd_send_result(ttse_result_event_e event, const void* data, unsigned int data_size, ttse_audio_type_e audio_type, int rate, void* user_data)
{
- SLOG(LOG_DEBUG, tts_tag(), "===== SEND SYNTHESIS RESULT START");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@ SEND SYNTHESIS RESULT START");
int uid = g_utt.uid;
int uttid = g_utt.uttid;
if (false == ttsd_data_is_uttid_valid(uid, uttid)) {
__server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] uttid is NOT valid !!!! - uid(%d), uttid(%d)", uid, uttid);
- SLOG(LOG_DEBUG, tts_tag(), "=====");
- SLOG(LOG_DEBUG, tts_tag(), " ");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@");
return TTSD_ERROR_OPERATION_FAILED;
}
if (rate <= 0 || audio_type < 0 || audio_type > TTSE_AUDIO_TYPE_MAX) {
__server_set_synth_control(TTSD_SYNTHESIS_CONTROL_DONE);
SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] audio data is invalid");
- SLOG(LOG_DEBUG, tts_tag(), "=====");
- SLOG(LOG_DEBUG, tts_tag(), " ");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@");
return TTSD_ERROR_INVALID_PARAMETER;
}
}
- /*SLOG(LOG_DEBUG, tts_tag(), "===== SYNTHESIS RESULT CALLBACK END");
+ /*SLOG(LOG_DEBUG, tts_tag(), "@@@ SYNTHESIS RESULT CALLBACK END");
SLOG(LOG_DEBUG, tts_tag(), " ");*/
return TTSD_ERROR_NONE;
bool __terminate_client(int pid, int uid, app_state_e state, void* user_data)
{
- SLOG(LOG_INFO, tts_tag(), "=== Start to terminate client [%d] ===", uid);
+ SLOG(LOG_INFO, tts_tag(), "@@@ Start to terminate client [%d]", uid);
ttsd_server_finalize(uid);
return true;
}
ttsd_network_finalize();
ttsd_finalize();
ecore_main_loop_quit();
+ ecore_shutdown();
return EINA_FALSE;
}
Eina_Bool ttsd_cleanup_client(void *data)
{
- SLOG(LOG_DEBUG, tts_tag(), "===== CLEAN UP CLIENT START");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@ CLEAN UP CLIENT START");
__read_proc();
if (0 < ttsd_data_get_client_count()) {
ecore_timer_add(0, __quit_ecore_loop, NULL);
}
- SLOG(LOG_DEBUG, tts_tag(), "=====");
- SLOG(LOG_DEBUG, tts_tag(), " ");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@");
return EINA_TRUE;
}
return TTSD_ERROR_NONE;
}
-
int ttsd_server_stop(int uid)
{
app_state_e state;
return TTSD_ERROR_INVALID_STATE;
}
- SLOG(LOG_INFO, tts_tag(), "[Server] server pause, uid(%d), utt_id(%d)", uid, utt_id);
+ *utt_id = g_utt.uttid;
+ SLOG(LOG_INFO, tts_tag(), "[Server] server pause, uid(%d), g_uid(%d), utt_id(%d)", uid, g_utt.uid, *utt_id);
int ret = 0;
ret = ttsd_player_pause(uid);
return ret;
}
+int ttsd_server_play_pcm(int uid)
+{
+ app_state_e state;
+ if (0 > ttsd_data_get_client_state(uid, &state)) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid(%d) is NOT valid ", uid);
+ return TTSD_ERROR_INVALID_PARAMETER;
+ }
+
+ if (APP_STATE_PLAYING == state) {
+ SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Current state(%d) is 'play' ", uid);
+ return TTSD_ERROR_NONE;
+ }
+
+ int current_uid = ttsd_data_get_current_playing();
+ SLOG(LOG_INFO, tts_tag(), "[Server] playing uid (%d)", current_uid);
+
+ if (uid != current_uid && -1 != current_uid) {
+ if (TTSD_MODE_DEFAULT != ttsd_get_mode()) {
+ /* Send interrupt message */
+ SLOG(LOG_DEBUG, tts_tag(), "[Server] Old uid(%d) will be interrupted into 'Stop' state ", current_uid);
+
+ /* pause player */
+ if (0 != ttsd_server_stop(current_uid)) {
+ SLOG(LOG_WARN, tts_tag(), "[Server ERROR] Fail to stop : uid (%d)", current_uid);
+ }
+ if (0 != ttsd_player_stop(current_uid)) {
+ SLOG(LOG_WARN, tts_tag(), "[Server ERROR] Fail to player stop : uid (%d)", current_uid);
+ }
+
+ intptr_t pcurrent_uid = (intptr_t)current_uid;
+ ecore_timer_add(0, __send_interrupt_client, (void*)pcurrent_uid);
+ } else {
+ /* Default mode policy of interrupt is "Pause" */
+
+ /* Send interrupt message */
+ SLOG(LOG_DEBUG, tts_tag(), "[Server] Old uid(%d) will be interrupted into 'Pause' state ", current_uid);
+
+ /* pause player */
+ if (0 != ttsd_player_pause(current_uid)) {
+ SLOG(LOG_WARN, tts_tag(), "[Server ERROR] Fail to ttsd_player_pause() : uid (%d)", current_uid);
+ }
+
+ /* change state */
+ ttsd_data_set_client_state(current_uid, APP_STATE_PAUSED);
+
+ intptr_t pcurrent_uid = (intptr_t)current_uid;
+ ecore_timer_add(0, __send_interrupt_client, (void*)pcurrent_uid);
+ }
+ }
+
+ /* Change current play */
+ if (0 != ttsd_data_set_client_state(uid, APP_STATE_PLAYING)) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set state : uid(%d)", uid);
+ return TTSD_ERROR_OPERATION_FAILED;
+ }
+
+ return TTSD_ERROR_NONE;
+}
+
+int ttsd_server_stop_pcm(int uid)
+{
+ app_state_e state;
+ if (0 > ttsd_data_get_client_state(uid, &state)) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] uid is not valid");
+ return TTSD_ERROR_INVALID_PARAMETER;
+ }
+
+ SLOG(LOG_INFO, tts_tag(), "[Server] server stop, state(%d)", state);
+
+ if (APP_STATE_PLAYING == state || APP_STATE_PAUSED == state) {
+ if (0 != ttsd_player_clear(uid))
+ SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsd_player_stop()");
+
+ ttsd_data_set_client_state(uid, APP_STATE_READY);
+ }
+
+ /* Reset all data */
+ ttsd_data_clear_data(uid);
+
+ return TTSD_ERROR_NONE;
+}
+
+int ttsd_server_add_pcm(int uid, int event, void* data, int data_size, int audio_type, int rate)
+{
+ SLOG(LOG_DEBUG, tts_tag(), "@@@ ADD PCM");
+
+ int uttid = -1;
+
+ /* Synthesis is success */
+ if (TTSE_RESULT_EVENT_START == event || TTSE_RESULT_EVENT_CONTINUE == event || TTSE_RESULT_EVENT_FINISH == event) {
+ if (TTSE_RESULT_EVENT_START == event) {
+ SLOG(LOG_INFO, tts_tag(), "[SERVER] Event : TTSE_RESULT_EVENT_START");
+ SECURE_SLOG(LOG_DEBUG, tts_tag(), "[SERVER] PCM Info : uid(%d), utt(%d), data(%p), data size(%d) audiotype(%d) rate(%d)",
+ uid, uttid, data, data_size, audio_type, rate);
+ } else if (TTSE_RESULT_EVENT_FINISH == event) {
+ SLOG(LOG_INFO, tts_tag(), "[SERVER] Event : TTSE_RESULT_EVENT_FINISH");
+ SECURE_SLOG(LOG_DEBUG, tts_tag(), "[SERVER] PCM Info : uid(%d), utt(%d), data(%p), data size(%d) audiotype(%d) rate(%d)",
+ uid, uttid, data, data_size, audio_type, rate);
+ } else {
+ /*if (TTSE_RESULT_EVENT_CONTINUE == event) SLOG(LOG_DEBUG, tts_tag(), "[SERVER] Event : TTSE_RESULT_EVENT_CONTINUE");*/
+ }
+
+ if (rate <= 0 || audio_type < 0 || audio_type > TTSE_AUDIO_TYPE_MAX) {
+ SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] audio data is invalid");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@");
+ return TTSD_ERROR_INVALID_PARAMETER;
+ }
+
+ /* add wav data */
+ sound_data_s* temp_sound_data = NULL;
+ temp_sound_data = (sound_data_s*)calloc(1, sizeof(sound_data_s));
+ if (NULL == temp_sound_data) {
+ SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] Out of memory");
+ return TTSD_ERROR_OUT_OF_MEMORY;
+ }
+
+ temp_sound_data->data = NULL;
+ temp_sound_data->rate = 0;
+ temp_sound_data->data_size = 0;
+
+ if (0 < data_size) {
+ temp_sound_data->data = (char*)calloc(data_size + 5, sizeof(char));
+ if (NULL != temp_sound_data->data) {
+ memcpy(temp_sound_data->data, data, data_size);
+ temp_sound_data->data_size = data_size;
+ SLOG(LOG_INFO, tts_tag(), "[DEBUG][memcpy] uid(%d), event(%d) sound_data(%p) data(%p) size(%d)",
+ uid, event, temp_sound_data, temp_sound_data->data, temp_sound_data->data_size);
+ } else {
+ SLOG(LOG_ERROR, tts_tag(), "Fail to allocate memory");
+ }
+ } else {
+ SLOG(LOG_ERROR, tts_tag(), "Sound data is NULL");
+ }
+
+ temp_sound_data->utt_id = uttid;
+ temp_sound_data->event = event;
+ temp_sound_data->audio_type = audio_type;
+ temp_sound_data->rate = rate;
+
+ if (0 != ttsd_data_add_sound_data(uid, temp_sound_data)) {
+ SECURE_SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] Fail to add sound data : uid(%d)", uid);
+
+ if (NULL != temp_sound_data->data) {
+ free(temp_sound_data->data);
+ temp_sound_data->data = NULL;
+ }
+ free(temp_sound_data);
+ temp_sound_data = NULL;
+ }
+
+ if (0 != ttsd_player_play(uid)) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to play sound : uid(%d)", uid);
+
+ /* Change ready state */
+ ttsd_server_stop(uid);
+
+ int tmp_pid;
+ tmp_pid = ttsd_data_get_pid(uid);
+ ttsdc_send_set_state_message(tmp_pid, uid, APP_STATE_READY);
+ }
+ } else {
+ SLOG(LOG_DEBUG, tts_tag(), "[SERVER] Event : TTSE_RESULT_EVENT_ERROR");
+ }
+
+ SLOG(LOG_DEBUG, tts_tag(), "@@@");
+
+ return TTSD_ERROR_NONE;
+}