From: sooyeon.kim Date: Fri, 1 Nov 2019 09:52:04 +0000 (+0900) Subject: Fix to mix sound when interrupt mode and other modes are requested to play X-Git-Tag: accepted/tizen/unified/20191122.053225~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F08%2F216808%2F1;p=platform%2Fcore%2Fuifw%2Ftts.git Fix to mix sound when interrupt mode and other modes are requested to play Change-Id: I66461497d7c6ea3836587264fd4e07e31ddd3ac9 Signed-off-by: sooyeon.kim --- diff --git a/server/ttsd_player.c b/server/ttsd_player.c index 688bd6a..8e1f223 100644 --- a/server/ttsd_player.c +++ b/server/ttsd_player.c @@ -131,28 +131,26 @@ void __player_focus_state_cb(sound_stream_info_h stream_info, sound_stream_focus } SLOG(LOG_WARN, tts_tag(), "[Player] focus state changed to (%d) with reason(%d) and extra info(%s)", (int)focus_state, (int)reason_for_change, extra_info); - if (AUDIO_STATE_PLAY == g_audio_state && focus_mask == SOUND_STREAM_FOCUS_FOR_PLAYBACK && SOUND_STREAM_FOCUS_STATE_RELEASED == focus_state) { + if (NULL == g_playing_info) { + SLOG(LOG_WARN, tts_tag(), "[Player WARNING] No current player"); + return; + } + + if (APP_STATE_PLAYING == g_playing_info->state && focus_mask == SOUND_STREAM_FOCUS_FOR_PLAYBACK && SOUND_STREAM_FOCUS_STATE_RELEASED == focus_state) { if (TTSD_MODE_DEFAULT == ttsd_get_mode()) { g_audio_state = AUDIO_STATE_READY; - if (NULL == g_playing_info) { - SLOG(LOG_WARN, tts_tag(), "[Player WARNING] No current player"); + int uid = g_playing_info->uid; + + if (0 != ttsd_player_pause(uid)) { + SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to pause the player"); return; } - if (APP_STATE_PLAYING == g_playing_info->state) { - int uid = g_playing_info->uid; - - if (0 != ttsd_player_pause(uid)) { - SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to pause the player"); - return; - } - - ttsd_data_set_client_state(uid, APP_STATE_PAUSED); - int pid = ttsd_data_get_pid(uid); - /* send message to client about changing state */ - ttsdc_send_set_state_message(pid, uid, APP_STATE_PAUSED); - } + ttsd_data_set_client_state(uid, APP_STATE_PAUSED); + int pid = ttsd_data_get_pid(uid); + /* send message to client about changing state */ + ttsdc_send_set_state_message(pid, uid, APP_STATE_PAUSED); } else { SLOG(LOG_DEBUG, tts_tag(), "[Player] Ignore focus state cb - mode(%d)", ttsd_get_mode()); } @@ -204,37 +202,33 @@ void __player_focus_state_watch_cb(int id, sound_stream_focus_mask_e focus_mask, return; } - if (AUDIO_STATE_PLAY == g_audio_state && SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION == reason && + if (NULL == g_playing_info) { + SLOG(LOG_WARN, tts_tag(), "[Player WARNING] No current player"); + return; + } + + if (APP_STATE_PLAYING == g_playing_info->state && SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION == reason && NULL != extra_info && 0 == strncmp(extra_info, "TTSD_MODE_INTERRUPT", strlen(extra_info))) { /* If the focus is changed by "Interrupt" mode and current players of "SR" and "Noti" modes are on going, please stop the current players. */ g_audio_state = AUDIO_STATE_READY; - if (NULL == g_playing_info) { - SLOG(LOG_WARN, tts_tag(), "[Player WARNING] No current player"); + int uid = g_playing_info->uid; + + if (0 != ttsd_server_stop(uid)) { + SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to stop TTS server"); return; } - - if (APP_STATE_PLAYING == g_playing_info->state) { - int uid = g_playing_info->uid; - - if (0 != ttsd_server_stop(uid)) { - SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to stop TTS server"); - return; - } - if (0 != ttsd_player_stop(uid)) { - SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to stop the player"); - return; - } - - ttsd_data_set_client_state(uid, APP_STATE_READY); - int pid = ttsd_data_get_pid(uid); - /* send message to client about changing state */ - ttsdc_send_set_state_message(pid, uid, APP_STATE_READY); - } else { - SLOG(LOG_DEBUG, tts_tag(), "[Player] Not playing state"); + if (0 != ttsd_player_stop(uid)) { + SLOG(LOG_WARN, tts_tag(), "[Player WARNING] Fail to stop the player"); + return; } + + ttsd_data_set_client_state(uid, APP_STATE_READY); + int pid = ttsd_data_get_pid(uid); + /* send message to client about changing state */ + ttsdc_send_set_state_message(pid, uid, APP_STATE_READY); } else { - SLOG(LOG_DEBUG, tts_tag(), "[Player] This is not Interrupt mode or not playing state."); + SLOG(LOG_DEBUG, tts_tag(), "[Player] Extra info is not Interrupt mode(%s) or not playing state(%d).", extra_info, g_playing_info->state); } return;