* limitations under the License.
*/
+#include <app_manager.h>
#include <aul.h>
#include <Ecore.h>
if (uid > 0) {
if (TTSD_SYNTHESIS_CONTROL_DOING == __server_get_synth_control()) {
- usleep(100000);
return EINA_TRUE;
} else {
g_wait_timer = NULL;
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)) {
}
int pid = ttsd_data_get_pid(uid);
- char appid[128] = {0, };
- if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
+ char appid[1024] = {0, };
+ if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid) - 1)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id");
}
int pid = ttsd_data_get_pid(uid);
ttsdc_send_set_state_message(pid, uid, APP_STATE_READY);
} else {
- g_wait_timer = ecore_timer_add(0, __wait_synthesis, (void*)credential);
+ g_wait_timer = ecore_timer_add(0.05, __wait_synthesis, (void*)credential);
}
if (NULL != speak_data) {
}
}
- SLOG(LOG_DEBUG, tts_tag(), "===== SYNTHESIS END");
- SLOG(LOG_DEBUG, tts_tag(), " ");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@ SYNTHESIS END");
return 0;
}
int uttid = g_utt.uttid;
int tmp_pid = ttsd_data_get_pid(uid);
- SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] Error msg from engine, pid(%d), uid(%d), uttid(%d), error(%d), msg(%s)", tmp_pid, uid, uttid, error, msg);
+ SLOG(LOG_ERROR, tts_tag(), "[SERVER ERROR] Error msg from engine, pid(%d), uid(%d), uttid(%d), error(%d), msg(%s)", tmp_pid, uid, uttid, error, (NULL == msg ? "NULL" : msg));
__server_set_synth_control(TTSD_SYNTHESIS_CONTROL_EXPIRED);
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 __get_client_cb(int pid, int uid, app_state_e state, void* user_data)
+bool __get_client_cb(int pid, int uid, app_tts_state_e state, void* user_data)
{
/* clear client data */
ttsd_data_clear_data(uid);
return;
}
-bool __terminate_client(int pid, int uid, app_state_e state, void* user_data)
+bool __terminate_client(int pid, int uid, app_tts_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;
}
}
if (0 != ttsd_engine_agent_is_credential_needed(uid, credential_needed)) {
- SLOG(LOG_ERROR, tts_tag(), "Server ERROR] Fail to get credential necessity");
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get credential necessity");
return TTSD_ERROR_OPERATION_FAILED;
}
+
+ if (true == *credential_needed) {
+ char* appid = NULL;
+ if (0 != app_manager_get_app_id(pid, &appid)) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id, pid(%d)", pid);
+ }
+ bool is_agreed = false;
+ if (0 != ttsd_engine_check_app_agreed(appid, &is_agreed)) {
+ SLOG(LOG_ERROR, tts_tag(), "Server ERROR] Fail to check app agreed");
+ if (!appid)
+ free(appid);
+ return TTSD_ERROR_OPERATION_FAILED;
+ }
+ if (!appid)
+ free(appid);
+
+ if (false == is_agreed) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] App is not agreed");
+ return TTSD_ERROR_PERMISSION_DENIED;
+ }
+ }
+
if (0 != ttsd_data_new_client(pid, uid)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to add client info");
return TTSD_ERROR_OPERATION_FAILED;
return;
}
-bool __get_client_for_clean_up(int pid, int uid, app_state_e state, void* user_data)
+bool __get_client_for_clean_up(int pid, int uid, app_tts_state_e state, void* user_data)
{
bool exist = false;
int i = 0;
return true;
#if 0
- char appid[128] = {0, };
- if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
+ char appid[1024] = {0, };
+ if (0 != aul_app_get_appid_bypid(pid, appid, sizeof(appid) - 1)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to get app id");
}
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;
}
{
SLOG(LOG_INFO, tts_tag(), "[Server] Server finalize");
- app_state_e state;
+ app_tts_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] ttsd_server_finalize : uid is not valid");
}
int ttsd_server_add_queue(int uid, const char* text, const char* lang, int voice_type, int speed, int utt_id, const char* credential)
{
- app_state_e state;
+ app_tts_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] ttsd_server_add_queue : uid is not valid");
return TTSD_ERROR_INVALID_PARAMETER;
int ttsd_server_play(int uid, const char* credential)
{
- app_state_e state;
+ app_tts_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;
}
}
+ /* check the current playback focus */
+ if (TTSD_MODE_INTERRUPT != ttsd_get_mode()) {
+ bool is_current_interrupt = false;
+ if (0 != ttsd_player_check_current_playback_focus(&is_current_interrupt)) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to check the current playback focus");
+ } else {
+ if (true == is_current_interrupt) {
+ SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Current playback focus is set on Interrupt mode. Cannot play default, screen reader, and noti modes.");
+ return TTSD_ERROR_AUDIO_POLICY_BLOCKED;
+ }
+ }
+ }
+
int current_uid = ttsd_data_get_current_playing();
SLOG(LOG_INFO, tts_tag(), "[Server] playing uid (%d)", current_uid);
int ttsd_server_stop(int uid)
{
- app_state_e state;
+ app_tts_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 (TTSD_SYNTHESIS_CONTROL_DOING == __server_get_synth_control()) {
+ if (TTSD_SYNTHESIS_CONTROL_DOING == __server_get_synth_control() && uid == ttsd_data_get_current_playing()) {
SLOG(LOG_DEBUG, tts_tag(), "[Server] TTS-engine is running");
int ret = 0;
int ttsd_server_pause(int uid, int* utt_id)
{
- app_state_e state;
+ app_tts_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] ttsd_server_pause : uid is not valid");
return TTSD_ERROR_INVALID_PARAMETER;
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);
int ttsd_server_get_support_voices(int uid, GList** voice_list)
{
- app_state_e state;
+ app_tts_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;
int ttsd_server_get_current_voice(int uid, char** language, int* voice_type)
{
- app_state_e state;
+ app_tts_state_e state;
if (0 > ttsd_data_get_client_state(uid, &state)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] ttsd_server_get_current_voice : uid is not valid");
return TTSD_ERROR_INVALID_PARAMETER;
int ttsd_server_set_private_data(int uid, const char* key, const char* data)
{
- app_state_e state;
+ app_tts_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;
int ttsd_server_get_private_data(int uid, const char* key, char** data)
{
- app_state_e state;
+ app_tts_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;
int ttsd_server_play_pcm(int uid)
{
- app_state_e state;
+ app_tts_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;
return TTSD_ERROR_OPERATION_FAILED;
}
+ if (APP_STATE_PAUSED == state) {
+ SLOG(LOG_DEBUG, tts_tag(), "[Server] uid(%d) is 'Pause' state : resume player", uid);
+
+ /* Resume player */
+ if (0 != ttsd_player_resume(uid)) {
+ SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Fail to ttsd_player_resume()");
+ }
+ } else {
+ if (0 != ttsd_player_play_pcm(uid)) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to play pcm sound : uid(%d)", uid);
+
+ // Change ready state
+ ttsd_server_stop_pcm(uid);
+
+ int tmp_pid;
+ tmp_pid = ttsd_data_get_pid(uid);
+ ttsdc_send_set_state_message(tmp_pid, uid, APP_STATE_READY);
+ }
+ }
+
return TTSD_ERROR_NONE;
}
int ttsd_server_stop_pcm(int uid)
{
- app_state_e state;
+ app_tts_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()");
-
+ if (APP_STATE_PLAYING == state || APP_STATE_PAUSED == state || APP_STATE_READY == state) {
ttsd_data_set_client_state(uid, APP_STATE_READY);
}
/* Reset all data */
ttsd_data_clear_data(uid);
+ ttsd_player_stop(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");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@ ADD PCM");
int uttid = -1;
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(), "=====");
- SLOG(LOG_DEBUG, tts_tag(), " ");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@");
return TTSD_ERROR_INVALID_PARAMETER;
}
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)) {
+/* if (0 != ttsd_player_play(uid)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to play sound : uid(%d)", uid);
- /* Change ready state */
+ // 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(), "=====");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@");
return TTSD_ERROR_NONE;
}