return TTSD_ERROR_NONE;
}
+static void __wait_sound_data(player_s* player)
+{
+ while (0 >= ttsd_data_get_sound_data_size(player->uid)) { // 2nd while(1)
+ usleep(10000);
+ if (false == __is_player_valid(player)) {
+ return;
+ }
+
+ /* If engine is not on processing */
+ ttsd_synthesis_control_e synth_control = ttsd_get_synth_control();
+ if (TTSD_SYNTHESIS_CONTROL_DOING != synth_control) {
+ SLOG(LOG_INFO, tts_tag(), "[Server INFO] synth_control(%d)", synth_control);
+ if (AudioStream::AUDIO_STATE_PLAY == g_audio_stream->getState()) {
+ g_audio_stream->unprepareAudioOut();
+ __unset_policy_for_playing();
+ }
+ }
+ }
+}
+
static void __play_thread_old(void *data, Ecore_Thread *thread)
{
SLOG(LOG_DEBUG, tts_tag(), "@@@ Start thread");
sound_data_s* sound_data = NULL;
int ret = -1;
-
- /* set volume policy as 40% */
- __set_policy_for_playing();
while (1) { // 1st while(1)
/* check g_playing_info one more time */
if (false == __is_player_valid(player)) {
ttsd_data_set_paused_data_existing(player->uid, false);
if (NULL == sound_data) {
- /* Request unprepare */
g_audio_stream->unprepareAudioOut();
-
- /* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
return;
}
/* empty queue */
SLOG(LOG_ERROR, tts_tag(), "[Player] No sound data. Waiting mode");
- /* wait for new audio data come */
- while (1) { // 2nd while(1)
- usleep(10000);
- if (false == __is_player_valid(player)) {
- /* current playing uid is replaced */
- SLOG(LOG_INFO, tts_tag(), "[Player] Finish thread");
- if (AudioStream::AUDIO_STATE_PLAY == g_audio_stream->getState()) {
- /* release audio & recover session */
- g_audio_stream->unprepareAudioOut();
- }
- /* unset volume policy, volume will be 100% */
- __unset_policy_for_playing();
- return;
- } else if (0 < ttsd_data_get_sound_data_size(player->uid)) {
- /* new audio data come */
- SLOG(LOG_INFO, tts_tag(), "[Player] Resume thread");
- break; // exit from 2nd while(1)
- }
-
- /* If engine is not on processing */
- ttsd_synthesis_control_e synth_control = ttsd_get_synth_control();
- if (TTSD_SYNTHESIS_CONTROL_DOING != synth_control) {
- SLOG(LOG_INFO, tts_tag(), "[Server INFO] synth_control(%d)", synth_control);
- if (AudioStream::AUDIO_STATE_PLAY == g_audio_stream->getState()) {
- /* release audio & recover session */
- g_audio_stream->unprepareAudioOut();
-
- /* unset volume policy, volume will be 100% */
- __unset_policy_for_playing();
- }
- }
- } // end of 2nd while(1). waiting for new audio data come
-
- SLOG(LOG_INFO, tts_tag(), "[Player] Finish to wait for new audio data come");
-
- if (AudioStream::AUDIO_STATE_READY == g_audio_stream->getState() || AudioStream::AUDIO_STATE_WAIT_FOR_PLAYING == g_audio_stream->getState()) {
- /* set volume policy as 40%, when resume play thread*/
- __set_policy_for_playing();
+ __wait_sound_data(player);
+ if (false == __is_player_valid(player)) {
+ SLOG(LOG_INFO, tts_tag(), "[Player] Finish thread");
+ g_audio_stream->unprepareAudioOut();
+ __unset_policy_for_playing();
+ return;
}
+ SLOG(LOG_INFO, tts_tag(), "[Player] Finish to wait for new audio data come");
continue;
} // NULL == sound_data