- /* 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;