Fix bug regarding roll-back scenario of focus reacquisition setting, revise some... 54/110354/2 accepted/tizen/3.0/common/20170118.130829 accepted/tizen/3.0/ivi/20170118.042800 accepted/tizen/3.0/mobile/20170118.042711 accepted/tizen/3.0/tv/20170118.042723 accepted/tizen/3.0/wearable/20170118.042740 submit/tizen_3.0/20170116.094232
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 16 Jan 2017 05:03:57 +0000 (14:03 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 16 Jan 2017 05:16:23 +0000 (14:16 +0900)
[Version] 0.10.82
[Profile] Common
[Issue Type] Bug fix and add log

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

index 51d79d3..c0e1c08 100644 (file)
@@ -485,8 +485,9 @@ int _mm_sound_mgr_focus_do_callback(focus_command_e command, focus_node_t *victi
                        if (reacquisition_changed) {
                                if (!victim_node->reacquisition) {
                                        for (list = g_focus_node_list; list != NULL; list = list->next) {
-                                               node = (focus_node_t *)list->data;
-                                               if (node && (node->taken_by_id[i].pid == victim_node->pid)) {
+                                               if (!(node = (focus_node_t *)list->data))
+                                                       continue;
+                                               if (node->taken_by_id[i].pid == victim_node->pid) {
                                                        UPDATE_FOCUS_TAKEN_INFO(backup, node, node->taken_by_id[i].pid, node->taken_by_id[i].handle_id, node->taken_by_id[i].by_session);
                                                        UPDATE_FOCUS_TAKEN_INFO(by_id, node, taken_pid, taken_hid, taken_by_session);
                                                } else if (!list->next) {
@@ -496,8 +497,9 @@ int _mm_sound_mgr_focus_do_callback(focus_command_e command, focus_node_t *victi
                                        }
                                } else {
                                        for (list = g_focus_node_list; list != NULL; list = list->next) {
-                                               node = (focus_node_t *)list->data;
-                                               if (node && (node->taken_backup[i].pid == victim_node->pid)) {
+                                               if (!(node = (focus_node_t *)list->data))
+                                                       continue;
+                                               if (node->taken_backup[i].pid == victim_node->pid) {
                                                        UPDATE_FOCUS_TAKEN_INFO(by_id, node, node->taken_backup[i].pid, node->taken_backup[i].handle_id, node->taken_backup[i].by_session);
                                                        UPDATE_FOCUS_TAKEN_INFO(backup, node, 0, 0, false);
                                                } else if (!list->next) {
@@ -549,8 +551,7 @@ static int _mm_sound_mgr_focus_list_dump ()
 
        debug_log("================================================ focus node list : start ===================================================\n");
        for (list = g_focus_node_list; list != NULL; list = list->next) {
-               node = (focus_node_t *)list->data;
-               if (node && !node->is_for_watch) {
+               if ((node = (focus_node_t *)list->data) && !node->is_for_watch) {
                        debug_log("*** pid[%5d]/handle_id[%2d]/[%14s]:priority[%2d],status[%s],taken_by[P(%5d/%2d/%2d)C(%5d/%2d/%2d)],session[%d],option[0x%x/0x%x],ext_info[%s/%s]\n",
                                        node->pid, node->handle_id, node->stream_type, node->priority, focus_status_str[node->status],
                                        node->taken_by_id[0].pid, node->taken_by_id[0].handle_id, node->taken_by_id[0].by_session, node->taken_by_id[1].pid,
@@ -570,10 +571,8 @@ static int _mm_sound_mgr_focus_watch_list_dump()
 
        debug_log("============================================= focus watch node list : start =================================================\n");
        for (list = g_focus_node_list; list != NULL; list = list->next) {
-               node = (focus_node_t *)list->data;
-               if (node && node->is_for_watch) {
+               if ((node = (focus_node_t *)list->data) && node->is_for_watch)
                        debug_log("*** pid[%5d]/handle_id[%d]/watch on focus status[%s]/for_session[%d]\n", node->pid, node->handle_id, focus_status_str[node->status], node->is_for_session);
-               }
        }
        debug_log("============================================= focus watch node list : end ===================================================\n");
 
@@ -788,9 +787,10 @@ int mm_sound_mgr_focus_set_reacquisition(const _mm_sound_mgr_focus_param_t *para
 
        if (!param->reacquisition) {
                for (list = g_focus_node_list; list != NULL; list = list->next) {
-                       node = (focus_node_t *)list->data;
+                       if (!(node = (focus_node_t *)list->data))
+                               continue;
                        for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
-                               if (node && (node->taken_by_id[i].pid == param->pid)) {
+                               if (node->taken_by_id[i].pid == param->pid) {
                                        /* victim node : append my node's taken info to my victim node */
                                        if (my_node->taken_by_id[i].pid != 0) {
                                                UPDATE_FOCUS_TAKEN_INFO(backup, node, node->taken_by_id[i].pid, node->taken_by_id[i].handle_id, node->taken_by_id[i].by_session);
@@ -805,10 +805,11 @@ int mm_sound_mgr_focus_set_reacquisition(const _mm_sound_mgr_focus_param_t *para
                }
        } else {
                for (list = g_focus_node_list; list != NULL; list = list->next) {
-                       node = (focus_node_t *)list->data;
+                       if (!(node = (focus_node_t *)list->data))
+                               continue;
                        for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
                                /* rollback and reset backup info. */
-                               if (node && (node->taken_backup[i].pid == param->pid)) {
+                               if (node->taken_by_id[i].pid && (node->taken_by_id[i].pid == my_node->taken_backup[i].pid)) {
                                        UPDATE_FOCUS_TAKEN_INFO(by_id, node, node->taken_backup[i].pid, node->taken_backup[i].handle_id, node->taken_backup[i].by_session);
                                        UPDATE_FOCUS_TAKEN_INFO(backup, node, 0, 0, false);
                                } else if (!list->next) {
@@ -847,8 +848,9 @@ int mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type_e focus_type
 
        /* Find node to set reacquisition */
        for (list = g_focus_node_list; list != NULL; list = list->next) {
-               node = (focus_node_t *)list->data;
-               if (node && !node->is_for_watch && (node->status & focus_type)) {
+               if (!(node = (focus_node_t *)list->data))
+                       continue;
+               if (!node->is_for_watch && (node->status & focus_type)) {
                        debug_msg("found a node : request_focus_type(%d), stream_type(%s)/ext info(%s) of acquired focus\n", focus_type, node->stream_type, node->ext_info);
                        *stream_type = node->stream_type;
                        *option = node->option[focus_type-1];
@@ -1097,8 +1099,9 @@ int mm_sound_mgr_focus_set_watch_cb(const _mm_sound_mgr_focus_param_t *param)
        g_list_foreach (g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
 
        for (list = g_focus_node_list; list != NULL; list = list->next) {
-               node = (focus_node_t *)list->data;
-               if (node && (node->pid == param->pid) && (node->handle_id == param->handle_id) && node->is_for_watch) {
+               if (!(node = (focus_node_t *)list->data))
+                       continue;
+               if ((node->pid == param->pid) && (node->handle_id == param->handle_id) && node->is_for_watch) {
                        debug_error("the node of pid[%d]/handle_id[%d] for watch focus is already created\n", param->pid, param->handle_id);
                        ret = MM_ERROR_INVALID_ARGUMENT;
                        goto FINISH;
@@ -1143,8 +1146,9 @@ int mm_sound_mgr_focus_unset_watch_cb(const _mm_sound_mgr_focus_param_t *param)
        g_list_foreach (g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
 
        for (list = g_focus_node_list; list != NULL; list = list->next) {
-               node = (focus_node_t *)list->data;
-               if (node && (node->pid == param->pid) && (node->handle_id == param->handle_id) && (node->is_for_watch)) {
+               if (!(node = (focus_node_t *)list->data))
+                       continue;
+               if ((node->pid == param->pid) && (node->handle_id == param->handle_id) && node->is_for_watch) {
                        debug_log("found the node of pid[%d]/handle_id[%d] for watch focus\n", param->pid, param->handle_id);
                        __clear_focus_pipe(node);
                        g_focus_node_list = g_list_remove(g_focus_node_list, node);
@@ -1185,8 +1189,9 @@ int mm_sound_mgr_focus_emergent_exit(const _mm_sound_mgr_focus_param_t *param)
 
        list = g_focus_node_list;
        while (list) {
-               node = (focus_node_t *)list->data;
-               if (node && (node->pid == param->pid)) {
+               if (!(node = (focus_node_t *)list->data))
+                       continue;
+               if (node->pid == param->pid) {
                        debug_log("found pid node");
                        if (node->is_for_watch) {
                                debug_log("clearing watch cb of pid(%d) handle(%d)", node->pid, node->handle_id);
@@ -1199,9 +1204,10 @@ int mm_sound_mgr_focus_emergent_exit(const _mm_sound_mgr_focus_param_t *param)
                                my_node = node;
                                /* update info of nodes that are lost their focus by the process exited */
                                for (list_s = g_focus_node_list; list_s != NULL; list_s = list_s->next) {
-                                       node = (focus_node_t *)list_s->data;
+                                       if (!(node = (focus_node_t *)list_s->data))
+                                               continue;
                                        for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
-                                               if (node && (node->taken_by_id[i].pid == param->pid)) {
+                                               if (node->taken_by_id[i].pid == param->pid) {
                                                        if (my_node->taken_by_id[i].pid) {
                                                                UPDATE_FOCUS_TAKEN_INFO(by_id, node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id, my_node->taken_by_id[i].by_session);
                                                        } else {
@@ -1225,21 +1231,20 @@ int mm_sound_mgr_focus_emergent_exit(const _mm_sound_mgr_focus_param_t *param)
                                param_s.handle_id = my_node->handle_id;
                                param_s.request_type = my_node->status;
                                for (list_s = g_focus_node_list; list_s != NULL; list_s = list_s->next) {
-                                       node = (focus_node_t *)list_s->data;
-                                       if (!node || my_node->pid == node->pid || node->is_for_watch) {
-                                               /* skip */
-                                       } else {
-                                               for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
-                                                       if (my_node->status & (i+1)) {
-                                                               if (node->taken_by_id[i].pid == param_s.pid && node->taken_by_id[i].handle_id == param_s.handle_id) {
-                                                                       /* do callback for resumption */
-                                                                       ret = _mm_sound_mgr_focus_do_callback(FOCUS_COMMAND_ACQUIRE, node, &param_s, my_node->stream_type);
-                                                                       if (ret) {
-                                                                               debug_error("Fail to _focus_do_callback for COMMAND ACQUIRE to node[%x], ret[0x%x]\n", node, ret);
-                                                                       }
-                                                                       if (!strncmp(my_node->stream_type, node->stream_type, MAX_STREAM_TYPE_LEN)) {
-                                                                               need_to_trigger_watch_cb = false;
-                                                                       }
+                                       if (!(node = (focus_node_t *)list_s->data))
+                                               continue;
+                                       if (my_node->pid == node->pid || node->is_for_watch)
+                                               continue;
+                                       for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
+                                               if (my_node->status & (i+1)) {
+                                                       if (node->taken_by_id[i].pid == param_s.pid && node->taken_by_id[i].handle_id == param_s.handle_id) {
+                                                               /* do callback for resumption */
+                                                               ret = _mm_sound_mgr_focus_do_callback(FOCUS_COMMAND_ACQUIRE, node, &param_s, my_node->stream_type);
+                                                               if (ret) {
+                                                                       debug_error("Fail to _focus_do_callback for COMMAND ACQUIRE to node[%x], ret[0x%x]\n", node, ret);
+                                                               }
+                                                               if (!strncmp(my_node->stream_type, node->stream_type, MAX_STREAM_TYPE_LEN)) {
+                                                                       need_to_trigger_watch_cb = false;
                                                                }
                                                        }
                                                }
index f6501ab..ee666d1 100644 (file)
@@ -1697,13 +1697,13 @@ int mm_sound_client_set_focus_reacquisition(int id, bool reacquisition)
        } else if (!result) {
                ret = mm_sound_proxy_set_foucs_reacquisition(instance, id, reacquisition);
                if (ret == MM_ERROR_NONE) {
-                       debug_msg("[Client] Success to set focus reacquisition\n");
+                       debug_msg("[Client] Success to set focus reacquisition to [%d]\n", reacquisition);
                } else {
                        debug_error("[Client] Error occurred : 0x%x \n",ret);
                        goto cleanup;
                }
        } else {
-               debug_warning("[Client] Inside the focus cb thread, bypassing dbus method call");
+               debug_warning("[Client] Inside the focus cb thread, set focus reacquisition to [%d]\n", reacquisition);
        }
 
        g_focus_sound_handle[index].auto_reacquire = reacquisition;
index f8dab30..4dccbbc 100644 (file)
@@ -198,7 +198,6 @@ int mm_sound_set_focus_reacquisition(int id, bool reacquisition)
        }
 
        ret = mm_sound_client_set_focus_reacquisition(id, reacquisition);
-
        if (ret) {
                debug_error("Could not set focus reacquisition, ret[0x%x]\n", ret);
        }
index 58b59f3..e174f58 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.10.81
+Version:    0.10.82
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0