Enhance session backward compatibility 78/120178/3
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 22 Mar 2017 04:17:40 +0000 (13:17 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 23 Mar 2017 05:08:06 +0000 (14:08 +0900)
In case of audio-io, mm-player, mm-camcorder, it provides interrupted_cb API to inform session resumption
to an application. Even if this callback function notifies resumption situation, the application can determine
whether resume previous stream or not in this callback. This patch is to make that when invoking focus state
changed callback for acquiring, the state of the node managed in focus server will not be updated rather
updated when the next request to acquire focus is coming from the application side.

[Version] 0.10.104
[Profile] Common
[Issue Type] Backward compatibility

Change-Id: I9d99ade37c07903cae235b0c2960dbd498306622
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
focus_server/include/mm_sound_mgr_focus.h
focus_server/mm_sound_mgr_focus.c
packaging/libmm-sound.spec

index d592971..b9b3213 100644 (file)
@@ -60,7 +60,8 @@ typedef struct {
        void *cbdata;
        bool reacquisition;
 
-       bool is_for_session;    /* will be removed when the session concept is completely left out*/
+       /* It will be removed when the session concept is completely left out*/
+       bool is_for_session;
 } _mm_sound_mgr_focus_param_t;
 
 typedef struct _taken_by_id
@@ -85,8 +86,9 @@ typedef struct {
        void *cbdata;
        bool reacquisition;
 
-       bool is_for_session;    /* will be removed when the session concept is completely left out*/
-
+       /* These will be removed when the session concept is completely left out*/
+       bool is_for_session;
+       bool reacquisition_with_released_state;
 } focus_node_t;
 
 int MMSoundMgrFocusInit(void);
index 9b8c577..7d87eca 100644 (file)
@@ -515,7 +515,10 @@ int _mm_sound_mgr_focus_do_callback(focus_command_e command, focus_node_t *victi
                }
        }
 
-       victim_node->status = (command == FOCUS_COMMAND_RELEASE) ? (victim_node->status & ~(cb_data.type)) : (victim_node->status | cb_data.type);
+       if (command == FOCUS_COMMAND_RELEASE || victim_node->reacquisition_with_released_state)
+               victim_node->status = victim_node->status & ~(cb_data.type);
+       else if (command == FOCUS_COMMAND_ACQUIRE)
+               victim_node->status = victim_node->status | cb_data.type;
 
        if (strncmp(assaulter_stream_type, victim_node->stream_type, MAX_STREAM_TYPE_LEN))
                _mm_sound_mgr_focus_do_watch_callback((focus_type_e)assaulter_param->request_type, command, victim_node, assaulter_param);
@@ -864,6 +867,28 @@ int mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type_e focus_type
        return ret;
 }
 
+static void update_reacquisition_with_released_state(focus_node_t *node, int direction)
+{
+       if (!node) {
+               debug_error("node is null");
+               return;
+       }
+       if (direction >= NUM_OF_STREAM_IO_TYPE) {
+               debug_error("invalid direction(%d)", direction);
+               return;
+       }
+
+       /* In case of session backward compatibility for audio-io, mm-player, mm-camcorder, we mark a specific flag here.
+        When invoking focus state changed callback for acquiring, state of the node will not be updated rather updated
+        when the next request to acquire. */
+       if (!strncmp("audio-io acquire focus", node->ext_info[direction], strlen(node->ext_info[direction])) ||
+               !strncmp("mm-player acquire focus", node->ext_info[direction], strlen(node->ext_info[direction])) ||
+               !strncmp("mm-camcorder acquire focus", node->ext_info[direction], strlen(node->ext_info[direction]))) {
+               debug_msg("this node needs reacquisition with focus released state\n");
+               node->reacquisition_with_released_state = true;
+       }
+}
+
 int mm_sound_mgr_focus_request_acquire(const _mm_sound_mgr_focus_param_t *param)
 {
        int ret = MM_ERROR_NONE;
@@ -953,6 +978,7 @@ int mm_sound_mgr_focus_request_acquire(const _mm_sound_mgr_focus_param_t *param)
                        if (param->request_type & (i+1)) {
                                MMSOUND_STRNCPY(my_node->ext_info[i], param->ext_info, MM_SOUND_NAME_NUM);
                                my_node->option[i] = param->option;
+                               update_reacquisition_with_released_state(my_node, i);
                        }
                }
                /* update status */
index 1e647e6..5678195 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.10.103
+Version:    0.10.104
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0