Check my node with is_for_session parameter 99/104099/1 accepted/tizen/common/20161212.185717 accepted/tizen/ivi/20161213.003530 accepted/tizen/mobile/20161213.003439 accepted/tizen/tv/20161213.003453 accepted/tizen/wearable/20161213.003515 submit/tizen/20161212.134937
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 6 Dec 2016 06:13:03 +0000 (15:13 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Mon, 12 Dec 2016 09:26:05 +0000 (01:26 -0800)
An error can occur when registering a focus node via sound-manager
if there already exists a node with the same index of the same process.
Because a node which is requested by sound-manager uses pulseaudio context id
whereas an internal focus node for session backward compatibility uses index
counted by focus_server itself.
This patch distinguishes both cases and ensures normal operation in this case.

[Version] 0.10.69
[Profile] Common
[Issue Type] Bug fix

Change-Id: Icbc9ec96940ea42bdb5cafa8d849f5cd767cc03c
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
(cherry picked from commit 049364a3f660ab9a94ca9afe5929e94ed2763eb1)

focus_server/include/mm_sound_mgr_focus_ipc.h
focus_server/mm_sound_mgr_focus.c
focus_server/mm_sound_mgr_focus_dbus.c
focus_server/mm_sound_mgr_focus_ipc.c
packaging/libmm-sound.spec

index b637904..1d72525 100644 (file)
@@ -27,8 +27,8 @@
 int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, const char* stream_type, bool is_for_session);
 int __mm_sound_mgr_focus_ipc_set_focus_reacquisition(int pid, int handle_id, bool reacquisition);
 int __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info);
-int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info);
-int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info);
+int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_for_session);
+int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_for_session);
 int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session);
 int __mm_sound_mgr_focus_ipc_unwatch_focus(int pid, int handle_id);
 int __mm_sound_mgr_focus_ipc_unregister_focus(int pid, int handle_id);
index 0e07c97..b15e6bc 100644 (file)
@@ -74,6 +74,9 @@ typedef struct {
        x_node->taken_##x_postfix[i].by_session = x_by_session; \
 } while (0)
 
+#define CHECK_MY_NODE(x_node, x_param) \
+       (x_node && !x_node->is_for_watch && (x_node->pid == x_param->pid) && (x_node->handle_id == x_param->handle_id) && (x_node->is_for_session == x_param->is_for_session))
+
 static char* __get_focus_pipe_path(int instance_id, int handle, const char* postfix, bool is_watch)
 {
        gchar* path = NULL;
@@ -606,7 +609,7 @@ int mm_sound_mgr_focus_create_node(const _mm_sound_mgr_focus_param_t *param)
 
        for (list = g_focus_node_list; list != NULL; list = list->next) {
                node = (focus_node_t *)list->data;
-               if (node && !node->is_for_watch && (node->pid == param->pid) && (node->handle_id == param->handle_id)) {
+               if (CHECK_MY_NODE(node, param)) {
                        debug_error("the node of pid[%d]/handle_id[%d] is already created\n", param->pid, param->handle_id);
                        ret = MM_ERROR_INVALID_ARGUMENT;
                        goto FINISH;
@@ -662,7 +665,7 @@ int mm_sound_mgr_focus_destroy_node(const _mm_sound_mgr_focus_param_t *param)
 
        for (list = g_focus_node_list; list != NULL; list = list->next) {
                node = (focus_node_t *)list->data;
-               if (node && !node->is_for_watch && (node->pid == param->pid) && (node->handle_id == param->handle_id)) {
+               if (CHECK_MY_NODE(node, param)) {
                        debug_log("found the node of pid[%d]/handle_id[%d]\n", param->pid, param->handle_id);
                        my_node = node;
                        break;
@@ -753,7 +756,7 @@ int mm_sound_mgr_focus_set_reacquisition(const _mm_sound_mgr_focus_param_t *para
        /* 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->pid == param->pid) && (node->handle_id == param->handle_id)) {
+               if (CHECK_MY_NODE(node, param)) {
                        if (node->reacquisition == param->reacquisition) {
                                debug_msg("it is already set as same value of reacquisition(%d)\n", param->reacquisition);
                                goto FINISH;
@@ -867,7 +870,7 @@ int mm_sound_mgr_focus_request_acquire(const _mm_sound_mgr_focus_param_t *param)
 
        for (list = g_focus_node_list; list != NULL; list = list->next) {
                node = (focus_node_t *)list->data;
-               if (node && !node->is_for_watch && (node->pid == param->pid) && (node->handle_id == param->handle_id)) {
+               if (CHECK_MY_NODE(node, param)) {
                        my_node = node;
                        if ((my_node->status > FOCUS_STATUS_DEACTIVATED) && (my_node->status & param->request_type)) {
                                debug_error("focus status is already activated");
@@ -984,7 +987,7 @@ int mm_sound_mgr_focus_request_release(const _mm_sound_mgr_focus_param_t *param)
 
        for (list = g_focus_node_list; list != NULL; list = list->next) {
                node = (focus_node_t *)list->data;
-               if (node && !node->is_for_watch && (node->pid == param->pid) && (node->handle_id == param->handle_id)) {
+               if (CHECK_MY_NODE(node, param)) {
                        my_node = node;
                        if (my_node->status == FOCUS_STATUS_DEACTIVATED) {
                                debug_error("focus status is already deactivated");
index 9f8f748..119ce49 100644 (file)
@@ -393,7 +393,7 @@ static void handle_method_acquire_focus(GDBusMethodInvocation* invocation)
        }
 
        g_variant_get(params, "(iiiisb)", &pid, &handle_id, &focus_type, &option, &ext_info, &is_for_session);
-       ret = __mm_sound_mgr_focus_ipc_acquire_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, focus_type, option, ext_info);
+       ret = __mm_sound_mgr_focus_ipc_acquire_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, focus_type, option, ext_info, is_for_session);
 
 send_reply:
        if (ret == MM_ERROR_NONE) {
@@ -422,7 +422,7 @@ static void handle_method_release_focus(GDBusMethodInvocation* invocation)
        }
 
        g_variant_get(params, "(iiiisb)", &pid, &handle_id, &focus_type, &option, &ext_info, &is_for_session);
-       ret = __mm_sound_mgr_focus_ipc_release_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, focus_type, option, ext_info);
+       ret = __mm_sound_mgr_focus_ipc_release_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, focus_type, option, ext_info, is_for_session);
 
 send_reply:
        if (ret == MM_ERROR_NONE) {
index ed3a679..90962bf 100644 (file)
@@ -70,6 +70,7 @@ int __mm_sound_mgr_focus_ipc_set_focus_reacquisition(int pid, int handle_id, boo
        param.pid = pid;
        param.handle_id = handle_id;
        param.reacquisition = reacquisition;
+       param.is_for_session = false;
 
        ret = mm_sound_mgr_focus_set_reacquisition(&param);
 
@@ -97,7 +98,7 @@ int __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(int focus_type, char
 }
 
 // method -> callback
-int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info)
+int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_for_session)
 {
        _mm_sound_mgr_focus_param_t param;
        int ret = MM_ERROR_NONE;
@@ -107,6 +108,7 @@ int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_typ
        param.handle_id = handle_id;
        param.request_type = focus_type;
        param.option = option;
+       param.is_for_session = is_for_session;
        MMSOUND_STRNCPY(param.ext_info, ext_info, MM_SOUND_NAME_NUM);
 
        ret = mm_sound_mgr_focus_request_acquire(&param);
@@ -115,7 +117,7 @@ int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_typ
 }
 
 // method -> callback
-int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info)
+int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info, bool is_for_session)
 {
        _mm_sound_mgr_focus_param_t param;
        int ret = MM_ERROR_NONE;
@@ -125,6 +127,7 @@ int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_typ
        param.handle_id = handle_id;
        param.request_type = focus_type;
        param.option = option;
+       param.is_for_session = is_for_session;
        MMSOUND_STRNCPY(param.ext_info, ext_info, MM_SOUND_NAME_NUM);
 
        ret = mm_sound_mgr_focus_request_release(&param);
index 2c48ef6..762f06c 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.10.68
+Version:    0.10.69
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0