[0.6.59] Add Check resume option in sound_focus callback. 93/146493/4 submit/tizen_3.0/20170831.061703
authorGilbok Lee <gilbok.lee@samsung.com>
Tue, 29 Aug 2017 05:57:32 +0000 (14:57 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Tue, 29 Aug 2017 10:43:25 +0000 (19:43 +0900)
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
src/mm_player_priv.c
src/mm_player_sound_focus.c

index b88cefa146d0df2b68a00ffff5ccaa7e117d3bc2..7e78bc0851110b605956159e4a3ddf948cee2206 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.58
+Version:    0.6.59
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index d00d5f48a3fdabac8a3461cf45c5c7c4585f58a0..a0678cc9efcebf998aae659c6a0503eb4e894bef 100644 (file)
@@ -8189,10 +8189,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");
@@ -8204,6 +8203,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 */
@@ -8279,10 +8279,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");
@@ -8295,9 +8294,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);
@@ -8306,6 +8306,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;
index 4e27284ab160715fc5f5ca5be91d46ad96b2a356..c9c42bfde9bff644019d24be859e62c319691430 100644 (file)
@@ -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;