#include <app_manager.h>
#include <aul.h>
#include <Ecore.h>
+#include <sys/time.h>
#include "ttsd_config.h"
#include "ttsd_data.h"
#define CLIENT_CLEAN_UP_TIME 500
+/* for checking time */
+#define TIME_DIFF(start, end) \
+ ((uint64_t)((end).tv_sec - (start).tv_sec) * 1000000 + (((end).tv_nsec - (start).tv_nsec) / 1000)) / 1000
+
+static struct timespec g_request_playing, g_start_playing;
+static double g_avg_latency;
+static double g_min_latency;
+static double g_max_latency;
+static int g_file_num;
+
typedef struct {
int uid;
int uttid;
SLOG(LOG_INFO, tts_tag(), "[SERVER] Event : TTSE_RESULT_EVENT_START");
SECURE_SLOG(LOG_DEBUG, tts_tag(), "[SERVER] Result Info : uid(%d), utt(%d), data(%p), data size(%d) audiotype(%d) rate(%d)",
uid, uttid, data, data_size, audio_type, rate);
+
+ clock_gettime(CLOCK_MONOTONIC_RAW, &g_start_playing);
+ long long int latency = (uint64_t)TIME_DIFF(g_request_playing, g_start_playing);
+ SLOG(LOG_INFO, tts_tag(), "[SERVER] Latency (Request playing ~ Get 1st synthesized results): %lld ms", latency);
+ double d_latency = (double)latency;
+ g_avg_latency += d_latency;
+ g_min_latency = (d_latency < g_min_latency) ? d_latency : g_min_latency;
+ g_max_latency = (d_latency > g_max_latency) ? d_latency : g_max_latency;
+ g_file_num++;
+ SLOG(LOG_INFO, tts_tag(), "[Server] File num(%d), Avg Latency(%lf), Min(%lf), Max(%lf)", g_file_num, (g_avg_latency / (double)g_file_num), g_min_latency, g_max_latency);
} 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] Result Info : uid(%d), utt(%d), data(%p), data size(%d) audiotype(%d) rate(%d)",
return TTSD_ERROR_OPERATION_FAILED;
}
+ g_file_num = 0;
+ g_min_latency = 10000.0;
+ g_max_latency = 0.0;
+ g_avg_latency = 0.0;
+
+
return TTSD_ERROR_NONE;
}
int ttsd_server_finalize(int uid)
{
SLOG(LOG_INFO, tts_tag(), "[Server] Server finalize");
+ SLOG(LOG_INFO, tts_tag(), "[Server] File num(%d), Avg Latency(%lf), Min(%lf), Max(%lf)", g_file_num, (g_avg_latency / (double)g_file_num), g_min_latency, g_max_latency);
app_tts_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
}
/* Check whether tts-engine is running or not */
+ clock_gettime(CLOCK_MONOTONIC_RAW, &g_request_playing);
if (TTSD_SYNTHESIS_CONTROL_DOING == ttsd_get_synth_control()) {
SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Engine has already been running.");
} else {