From 1db41fc04d47e33c3ee3f1b49e0897e9269ae85e Mon Sep 17 00:00:00 2001 From: Gilbok Lee Date: Tue, 29 Aug 2017 14:57:32 +0900 Subject: [PATCH] [0.6.65] Add Check resume option in sound_focus callback. player resume even if the MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED option is not set. Change-Id: I8ae4a3ffea20e8d5467b5a9aa5d3d436add231d6 --- packaging/libmm-player.spec | 2 +- src/mm_player_priv.c | 26 +++++++++++++++++--------- src/mm_player_sound_focus.c | 13 +++++++++++-- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index d7894d4..d5aeffd 100644 --- a/packaging/libmm-player.spec +++ b/packaging/libmm-player.spec @@ -1,6 +1,6 @@ Name: libmm-player Summary: Multimedia Framework Player Library -Version: 0.6.64 +Version: 0.6.65 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 10ce600..a60de08 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -8098,10 +8098,9 @@ void __mmplayer_sound_focus_watch_callback(int id, mm_sound_focus_type_e focus_t if (MM_ERROR_NONE == __mmplayer_convert_sound_focus_state(FALSE, reason_for_change, &msg)) player->sound_focus.focus_changed_msg = (int)msg; - if (strstr(reason_for_change, "call") || - strstr(reason_for_change, "voip") || /* FIXME: to check */ - strstr(reason_for_change, "alarm") || - strstr(reason_for_change, "media")) { + if (player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_CALL || + player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_ALARM || + player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA ) { if (!MMPLAYER_IS_RTSP_STREAMING(player)) { // hold 0.7 second to excute "fadedown mute" effect LOGW("do fade down->pause->undo fade down"); @@ -8113,6 +8112,7 @@ void __mmplayer_sound_focus_watch_callback(int id, mm_sound_focus_type_e focus_t LOGW("fail to set Pause state by asm"); goto EXIT; } + __mmplayer_undo_sound_fadedown(player); } else /* rtsp should connect again in specific network becasue tcp session can't be kept any more */ @@ -8188,10 +8188,9 @@ __mmplayer_sound_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sou if (MM_ERROR_NONE == __mmplayer_convert_sound_focus_state(FALSE, reason_for_change, &msg)) player->sound_focus.focus_changed_msg = (int)msg; - if (strstr(reason_for_change, "call") || - strstr(reason_for_change, "voip") || /* FIXME: to check */ - strstr(reason_for_change, "alarm") || - strstr(reason_for_change, "media")) { + if (player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_CALL || + player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_ALARM || + player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA ) { if (!MMPLAYER_IS_RTSP_STREAMING(player)) { //hold 0.7 second to excute "fadedown mute" effect LOGW("do fade down->pause->undo fade down"); @@ -8204,9 +8203,10 @@ __mmplayer_sound_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sou goto EXIT; } __mmplayer_undo_sound_fadedown(player); - } else + } else { /* rtsp should connect again in specific network becasue tcp session can't be kept any more */ _mmplayer_unrealize((MMHandleType)player); + } } else { LOGW("pause immediately"); result = _mmplayer_pause((MMHandleType)player); @@ -8215,6 +8215,14 @@ __mmplayer_sound_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sou goto EXIT; } } + + if (player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA && + player->sound_focus.session_type == MM_SESSION_TYPE_MEDIA && + !(player->sound_focus.session_flags & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED)) { + result = mm_sound_set_focus_reacquisition_for_session(player->sound_focus.focus_id, false); + if (result != MM_ERROR_NONE) + LOGW("fail to set focus reacquisition to FALSE, skip going on.."); + } } else if (focus_state == FOCUS_IS_ACQUIRED) { LOGW("FOCUS_IS_ACQUIRED: Got msg from asm to resume"); player->sound_focus.antishock = TRUE; diff --git a/src/mm_player_sound_focus.c b/src/mm_player_sound_focus.c index 4e27284..c9c42bf 100644 --- a/src/mm_player_sound_focus.c +++ b/src/mm_player_sound_focus.c @@ -147,8 +147,12 @@ _mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus) } if (_mmplayer_is_using_internal_sound_focus(sound_focus)) { + if (sound_focus->session_type == MM_SESSION_TYPE_MEDIA) + /* option: 1 for no-resume */ + ret = mm_sound_acquire_focus_with_option(sound_focus->focus_id, FOCUS_FOR_BOTH, 1, "mm-player acquire focus"); + else + ret = mm_sound_acquire_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player acquire focus"); - ret = mm_sound_acquire_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player acquire focus"); if (ret != MM_ERROR_NONE) { LOGE("failed to acquire sound focus [0x%X]", ret); return ret; @@ -201,7 +205,12 @@ _mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus) } if (_mmplayer_is_using_internal_sound_focus(sound_focus)) { - ret = mm_sound_release_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player release focus"); + if (sound_focus->session_type == MM_SESSION_TYPE_MEDIA) + /* option: 1 for no-resume */ + ret = mm_sound_release_focus_with_option(sound_focus->focus_id, FOCUS_FOR_BOTH, 1, "mm-player release focus"); + else + ret = mm_sound_release_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player release focus"); + if (ret != MM_ERROR_NONE) { LOGE("failed to release sound focus\n"); return ret; -- 2.34.1