/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
AUDIO_STATE_NONE = 0,
AUDIO_STATE_READY,
AUDIO_STATE_PLAY
-}audio_state_e;
+} audio_state_e;
typedef struct {
int uid; /** client id */
bool is_paused_data;
int idx;
sound_data_s paused_data;
-}player_s;
+} player_s;
#define SOUND_BUFFER_LENGTH 2048
static audio_out_h g_audio_h;
/*
-* Internal Interfaces
+* Internal Interfaces
*/
player_s* __player_get_item(int uid)
int pid = ttsd_data_get_pid(g_playing_info->uid);
/* send message to client about changing state */
- ttsdc_send_set_state_message (pid, g_playing_info->uid, APP_STATE_PAUSED);
+ ttsdc_send_set_state_message(pid, g_playing_info->uid, APP_STATE_PAUSED);
}
SLOG(LOG_DEBUG, get_tag(), "=====");
} else {
SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] Destroy audio");
}
-
+
g_audio_type = 0;
g_sampling_rate = 0;
return;
}
- /* If wdata's event is 'start', current wdata is first data of engine for synthesis.
+ /* If wdata's event is 'start', current wdata is first data of engine for synthesis.
* If wdata's event is 'finish', player should check previous event to know whether this wdata is first or not.
- * When previous wdata's event is 'finish' and current wdata's event is 'finish',
- * the player should send utt started event.
+ * When previous wdata's event is 'finish' and current wdata's event is 'finish',
+ * the player should send utt started event.
*/
if (TTSP_RESULT_EVENT_START == wdata.event ||
(TTSP_RESULT_EVENT_FINISH == player->event && TTSP_RESULT_EVENT_FINISH == wdata.event)) {
}
/*
-* Player Interfaces
+* Player Interfaces
*/
int ttsd_player_init()
{
g_playing_info = NULL;
g_audio_state = AUDIO_STATE_NONE;
g_audio_h = NULL;
-
+
int ret;
if (TTSD_MODE_DEFAULT == ttsd_get_mode()) {
if (0 != ret) {
SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail to set session type");
}
-
+
ret = sound_manager_set_media_session_option(SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START, SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY);
if (0 != ret) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail set media session option");
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Fail set media session option");
} else {
- SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] set media session option");
+ SLOG(LOG_DEBUG, get_tag(), "[Player SUCCESS] set media session option");
}
}
ecore_thread_max_set(1);
-
+
ret = __create_audio_out(TTSP_AUDIO_TYPE_RAW_S16, 16000);
if (0 != ret)
return -1;
int ttsd_player_create_instance(int uid)
{
if (false == g_player_init) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
return -1;
}
-
+
/* Check uid is duplicated */
if (NULL != __player_get_item(uid)) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is already registered", uid);
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is already registered", uid);
return -1;
}
new_client->is_paused_data = false;
new_client->idx = 0;
new_client->paused_data.data = NULL;
-
+
SLOG(LOG_DEBUG, get_tag(), "[Player] Create player : uid(%d)", uid);
g_player_list = g_list_append(g_player_list, new_client);
int ttsd_player_destroy_instance(int uid)
{
if (false == g_player_init) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
return -1;
}
player_s* current;
current = __player_get_item(uid);
if (NULL == current) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
return -1;
}
if (NULL != data) {
/* compare uid */
if (uid == data->uid) {
- g_player_list = g_list_remove_link(g_player_list, iter);
+ g_player_list = g_list_remove_link(g_player_list, iter);
free(data);
break;
}
}
-
+
/* Get next item */
iter = g_list_next(iter);
}
int ttsd_player_play(int uid)
{
if (false == g_player_init) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
return -1;
}
}
}
- SLOG(LOG_DEBUG, get_tag(), "[Player] start play : uid(%d)", uid );
+ SLOG(LOG_DEBUG, get_tag(), "[Player] start play : uid(%d)", uid);
/* Check sound queue size */
if (0 == ttsd_data_get_sound_data_size(uid)) {
- SLOG(LOG_WARN, get_tag(), "[Player WARNING] A sound queue of current player(%d) is empty", uid);
+ SLOG(LOG_WARN, get_tag(), "[Player WARNING] A sound queue of current player(%d) is empty", uid);
return -1;
}
player_s* current;
current = __player_get_item(uid);
if (NULL == current) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
return -1;
}
current->state = APP_STATE_PLAYING;
-
+
g_playing_info = current;
SLOG(LOG_DEBUG, get_tag(), "[Player DEBUG] Active thread count : %d", ecore_thread_active_get());
player_s* current;
current = __player_get_item(uid);
if (NULL == current) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
return -1;
}
g_playing_info = NULL;
}
} else {
- SLOG(LOG_DEBUG, get_tag(), "[Player] No current playing");
+ SLOG(LOG_DEBUG, get_tag(), "[Player] No current playing");
}
if (true == current->is_paused_data) {
int ttsd_player_pause(int uid)
{
- SLOG(LOG_DEBUG, get_tag(), "[Player] pause player : uid(%d)", uid );
+ SLOG(LOG_DEBUG, get_tag(), "[Player] pause player : uid(%d)", uid);
if (false == g_player_init) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
return -1;
}
player_s* current;
current = __player_get_item(uid);
if (NULL == current) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] ttsd_player_pause() : uid(%d) is not valid", uid);
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] ttsd_player_pause() : uid(%d) is not valid", uid);
return -1;
}
int ttsd_player_resume(int uid)
{
- SLOG(LOG_DEBUG, get_tag(), "[Player] Resume player : uid(%d)", uid );
+ SLOG(LOG_DEBUG, get_tag(), "[Player] Resume player : uid(%d)", uid);
if (false == g_player_init) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
return -1;
}
player_s* current;
current = __player_get_item(uid);
if (NULL == current) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] uid(%d) is not valid", uid);
return -1;
}
int ttsd_player_all_stop()
{
if (false == g_player_init) {
- SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized" );
+ SLOG(LOG_ERROR, get_tag(), "[Player ERROR] Not Initialized");
return -1;
}
data->paused_data.data = NULL;
}
}
-
+
data->is_paused_data = false;
data->idx = 0;
}
-
+
/* Get next item */
iter = g_list_next(iter);
}