FOCUS_TYPE_BOTH can be passed to argument of mm_sound_mgr_focus_get_stream_type_of_ac... 68/127868/1
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 18 Apr 2017 01:04:30 +0000 (10:04 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 2 May 2017 06:12:38 +0000 (15:12 +0900)
Some codes that check validation of arguments are also added.

[Version] 0.10.114
[Profile] Common
[Issue Type] Enhancement

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

index e1a5d3c..9c77c13 100644 (file)
@@ -969,9 +969,7 @@ int mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type_e focus_type
 
        debug_fenter();
 
-       if (focus_type == FOCUS_TYPE_BOTH) /* focus_type should be "playback" or "capture" */
-               return MM_ERROR_INVALID_ARGUMENT;
-       if (!stream_type)
+       if (!stream_type || !option)
                return MM_ERROR_INVALID_ARGUMENT;
 
        MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_focus_node_list_mutex, MM_ERROR_SOUND_INTERNAL);
@@ -984,11 +982,19 @@ int mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type_e 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);
+                        /* In case of FOCUS_TYPE_BOTH, we use index for FOCUS_TYPE_PLAYBACK's forcedly.
+                         * It is because this function can not return both index of option, ext_info results
+                         * via out-parameter. This case is only used in framework internally for session
+                         * backward compatibilty. */
+                       int index = (focus_type == FOCUS_TYPE_BOTH) ? FOCUS_TYPE_PLAYBACK - 1 : focus_type - 1;
+
+                       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[index]);
+
                        *stream_type = node->stream_type;
-                       *option = node->option[focus_type-1];
+                       *option = node->option[index];
                        if (ext_info)
-                               *ext_info = node->ext_info[focus_type-1];
+                               *ext_info = node->ext_info[index];
                        ret = MM_ERROR_NONE;
                        break;
                }
index 9e5c44d..b89e4c3 100644 (file)
@@ -371,11 +371,10 @@ static void handle_method_get_acquired_focus_stream_type(GDBusMethodInvocation*
        ret = __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(focus_type, &stream_type, &option, &ext_info);
 
 send_reply:
-       if (ret == MM_ERROR_NONE) {
+       if (ret == MM_ERROR_NONE)
                _method_call_return_value(invocation, g_variant_new("(sis)", stream_type, option, ext_info));
-       } else {
+       else
                _method_call_return_error(invocation, ret);
-       }
 
        debug_fleave();
 }
index 443748f..8a7ec1b 100644 (file)
@@ -85,7 +85,7 @@ int __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(int focus_type, char
        char *stream_type_str = NULL;
        char *ext_info_str = NULL;
 
-       if (!stream_type)
+       if (!stream_type || !option)
                return MM_ERROR_INVALID_ARGUMENT;
 
        ret = mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type, &stream_type_str, option, &ext_info_str);
index 57afc72..c386cdb 100644 (file)
@@ -1961,16 +1961,19 @@ cleanup:
 int mm_sound_client_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info)
 {
        int ret = MM_ERROR_NONE;
-       char *ext_str = NULL;
+       char *stream_type_str = NULL;
+       char *ext_info_str = NULL;
 
        debug_fenter();
 
-       ret = mm_sound_proxy_get_acquired_focus_stream_type(focus_type, stream_type, option, &ext_str);
+       ret = mm_sound_proxy_get_acquired_focus_stream_type(focus_type, &stream_type_str, option, &ext_info_str);
        if (ret == MM_ERROR_NONE) {
                debug_msg("[Client] Success to get stream type of acquired focus, stream_type(%s), ext_info(%s)\n",
-                               *stream_type, ext_str);
-               *ext_info = strdup(ext_str);
-               g_free(ext_str);
+                         stream_type_str, ext_info_str);
+               *stream_type = strdup(stream_type_str);
+               *ext_info = strdup(ext_info_str);
+               g_free(stream_type_str);
+               g_free(ext_info_str);
        } else {
                debug_error("[Client] Error occurred : 0x%x \n",ret);
        }
index a4aad36..88c19ed 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.10.113
+Version:    0.10.114
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0