}
#endif
-static void set_policy_for_playing(void)
+static void set_policy_for_playing(unsigned int uid)
{
- g_audio_stream->acquireSoundFocus();
+ /* In case of DEFAULT and INTERRUPT mode, acquire sound focus */
+ ttsd_mode_e mode = ttsd_data_get_mode(uid);
+ SLOG(LOG_INFO, tts_tag(), "[Player INFO] Current uid(%d)'s mode(%d)", uid, (int)mode);
+ if (TTSD_MODE_DEFAULT == mode || TTSD_MODE_INTERRUPT == mode)
+ g_audio_stream->acquireSoundFocus();
+
g_background_volume->applyVolumeRatio();
g_is_set_policy = true;
SLOG(LOG_ERROR, tts_tag(), "[BG] g_is_set_policy(%d)", static_cast<int>(g_is_set_policy.load()));
SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] set policy for playing");
}
-static void unset_policy_for_playing()
+static void unset_policy_for_playing(unsigned int uid)
{
- g_audio_stream->releaseSoundFocus();
+/* In case of DEFAULT and INTERRUPT mode, release sound focus */
+ ttsd_mode_e mode = ttsd_data_get_mode(uid);
+ SLOG(LOG_INFO, tts_tag(), "[Player INFO] Current uid(%d)'s mode(%d)", uid, (int)mode);
+ if (TTSD_MODE_DEFAULT == mode || TTSD_MODE_INTERRUPT == mode)
+ g_audio_stream->releaseSoundFocus();
+
g_background_volume->recoverVolumeRatio();
g_is_set_policy = false;
SLOG(LOG_ERROR, tts_tag(), "[BG] g_is_set_policy(%d)", static_cast<int>(g_is_set_policy.load()));
// Check whether set_policy is done or not
if (false == g_is_set_policy.load()) {
- SLOG(LOG_INFO, tts_tag(), "[Player INFO] Set policy");
- set_policy_for_playing();
+ SLOG(LOG_INFO, tts_tag(), "[Player INFO] Set policy. uid(%d)", uid);
+ set_policy_for_playing(uid);
}
if (TTSD_ERROR_NONE != g_audio_stream->prepareAudioOut()) {
if (TTSD_SYNTHESIS_CONTROL_DOING != synth_control) {
if (AudioStream::AUDIO_STATE_PLAY == g_audio_stream->getState()) {
g_audio_stream->unprepareAudioOut();
- unset_policy_for_playing();
+ unset_policy_for_playing(uid); // uid == current uid
}
}
prev_synth_control = synth_control;
SLOG(LOG_INFO, tts_tag(), "[Player] No Sound data. Event(%d), uid(%u), uttid(%d)", event, uid, utt_id);
if (TTSE_RESULT_EVENT_FINISH == event) {
- unset_policy_for_playing();
+ unset_policy_for_playing(uid);
if (TTSD_ERROR_INVALID_PARAMETER == notify_utterance_completed_event(uid, utt_id)) {
break;
}
sound_data = nullptr;
if (TTSE_RESULT_EVENT_FINISH == event) {
- unset_policy_for_playing();
+ unset_policy_for_playing(uid);
if (TTSD_ERROR_NONE != notify_utterance_completed_event(uid, utt_id)) {
break;
}
}
g_audio_stream->unprepareAudioOut();
- unset_policy_for_playing();
+ unset_policy_for_playing(uid);
#ifdef BUF_SAVE_MODE
close_buffer_dump_file();