ret = sound_manager_get_current_playback_focus(&reason, &sound_behavior, &extra_info);
- if (SOUND_MANAGER_ERROR_NONE == ret && NULL != extra_info) {
+ SLOG(LOG_DEBUG, tts_tag(), "[Player] current playback focus: extra_info(%s), reason(%d), sound_behavior(%d)", extra_info, reason, sound_behavior, extra_info);
+
+ if (SOUND_MANAGER_ERROR_NONE == ret && NULL != extra_info && 0 < strlen(extra_info)) {
if (SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION == reason && 0 == strncmp(extra_info, "TTSD_MODE_INTERRUPT", strlen(extra_info))) {
SLOG(LOG_DEBUG, tts_tag(), "[Player] The current focus in Interrupt. Cannot play the requested sound data");
*is_current_interrupt = true;
if (0 != ret || NULL == sound_data) {
/* empty queue */
SLOG(LOG_DEBUG, tts_tag(), "[Player] No sound data. Waiting mode");
- /* release audio & recover session */
- ret = audio_out_unprepare(g_audio_h);
- if (AUDIO_IO_ERROR_NONE != ret) {
- SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
- } else {
- SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Unprepare audio");
- }
- g_audio_state = AUDIO_STATE_READY;
-
- /* unset volume policy, volume will be 100% */
- __unset_policy_for_playing();
/* wait for new audio data come */
while (1) {
if (NULL == g_playing_info) {
/* current playing uid is replaced */
SLOG(LOG_INFO, tts_tag(), "[Player] Finish thread");
+ if (AUDIO_STATE_PLAY == g_audio_state) {
+ /* release audio & recover session */
+ ret = audio_out_unprepare(g_audio_h);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
+ } else {
+ SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Unprepare audio");
+ }
+ g_audio_state = AUDIO_STATE_READY;
+ }
+ /* 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;
}
+
+ /* If engine is not on processing */
+ if (TTSD_SYNTHESIS_CONTROL_DOING != ttsd_get_synth_control()) {
+ if (AUDIO_STATE_PLAY == g_audio_state) {
+ /* release audio & recover session */
+ ret = audio_out_unprepare(g_audio_h);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to unprepare audio : %d", ret);
+ } else {
+ SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Unprepare audio");
+ }
+ g_audio_state = AUDIO_STATE_READY;
+
+ /* unset volume policy, volume will be 100% */
+ __unset_policy_for_playing();
+ }
+ }
}
SLOG(LOG_INFO, tts_tag(), "[Player] Finish to wait for new audio data come");
- /* set volume policy as 40%, when resume play thread*/
- __set_policy_for_playing(40);
+ if (AUDIO_STATE_READY == g_audio_state) {
+ /* set volume policy as 40%, when resume play thread*/
+ __set_policy_for_playing(40);
+ }
/* resume play thread */
player->state = APP_STATE_PLAYING;
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
return;
}
SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
return;
}
if (0 != ttsdc_send_utt_finish_message(pid, player->uid, sound_data->utt_id)) {
}
}
SLOG(LOG_INFO, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
+ ttsd_data_clear_sound_data(player->uid, &sound_data);
continue;
}
}
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
+ ttsd_data_clear_sound_data(player->uid, &sound_data);
return;
}
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
-
- free(sound_data);
- sound_data = NULL;
+ ttsd_data_clear_sound_data(player->uid, &sound_data);
return;
}
}
char* temp_data = sound_data->data;
+ SLOG(LOG_INFO, tts_tag(), "[Player INFO] Before audio_out_write. temp_data(%p), idx(%d), data_idx(%d), uid(%d), utt_id(%d), len(%d)",
+ temp_data, idx, &temp_data[idx], player->uid, sound_data->utt_id, len);
ret = audio_out_write(g_audio_h, &temp_data[idx], len);
if (0 > ret) {
SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to audio write - %d", ret);
} else {
idx += len;
+ SLOG(LOG_INFO, tts_tag(), "[Player INFO] After audio_out_write. temp_data(%p), idx(%d), data_idx(%d), uid(%d), utt_id(%d), len(%d)",
+ temp_data, idx, &temp_data[idx], player->uid, sound_data->utt_id, len);
}
if (NULL == g_playing_info && APP_STATE_PAUSED != player->state) {
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data) {
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
-
- free(sound_data);
- sound_data = NULL;
- }
+ ttsd_data_clear_sound_data(player->uid, &sound_data);
return;
}
SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Unprepare audio");
}
- if (NULL != sound_data) {
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
-
- free(sound_data);
- sound_data = NULL;
- }
+ ttsd_data_clear_sound_data(player->uid, &sound_data);
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
return;
SLOG(LOG_WARN, tts_tag(), "[Send WARNIING] Current player is not valid");
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
return;
}
pid, player->uid, sound_data->utt_id);
/* unset volume policy, volume will be 100% */
__unset_policy_for_playing();
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
- free(sound_data);
- sound_data = NULL;
+ ttsd_data_clear_sound_data(player->uid, &sound_data);
return;
}
SLOG(LOG_INFO, tts_tag(), "[Player] Finish utterance : uid(%d), uttid(%d)", player->uid, sound_data->utt_id);
}
- if (NULL != sound_data) {
- if (NULL != sound_data->data) {
- free(sound_data->data);
- sound_data->data = NULL;
- }
-
- free(sound_data);
- sound_data = NULL;
- }
+ ttsd_data_clear_sound_data(player->uid, &sound_data);
if (NULL == g_playing_info) {
SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Current player is NULL");
ret = sound_manager_add_focus_state_watch_cb(SOUND_STREAM_FOCUS_FOR_PLAYBACK, __player_focus_state_watch_cb, NULL, &g_focus_watch_id);
if (SOUND_MANAGER_ERROR_NONE != ret) {
SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to add sound focus watch callback");
+ sound_manager_destroy_stream_information(g_stream_info_h);
return -1;
} else {
SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Add sound focus watch callback");
ecore_thread_max_set(1);
ret = __create_audio_out(TTSE_AUDIO_TYPE_RAW_S16, 16000);
- if (0 != ret)
+ if (0 != ret) {
+ sound_manager_destroy_stream_information(g_stream_info_h);
+ sound_manager_remove_focus_state_watch_cb(g_focus_watch_id);
return -1;
+ }
g_player_init = true;