Send device_id list to pulseaudio via dbus when applying devices for manual routing 07/41107/2
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 4 May 2015 01:09:44 +0000 (10:09 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 8 Jul 2015 05:37:50 +0000 (14:37 +0900)
Modify sound_manager_test for manual routing

Change-Id: Ie8c6c9098c9447cf3c1c00f451549150b1219e5c

include/sound_manager_private.h
packaging/capi-media-sound-manager.spec
src/sound_manager.c
src/sound_manager_private.c
test/sound_manager_test.c

index 09e8ad34eaa4c4219aae8139c565b5ec4808374d..d7c382e9b7342941386412e6946563dd68ba3d8e 100644 (file)
@@ -90,10 +90,8 @@ typedef struct _stream_conf_info_s {
 } stream_conf_info_s;
 
 typedef struct _manual_route_info_s {
-       char *route_in_devices[AVAIL_DEVICES_MAX];
-       char *route_out_devices[AVAIL_DEVICES_MAX];
-       int route_in_devices_idx[AVAIL_DEVICES_MAX];
-       int route_out_devices_idx[AVAIL_DEVICES_MAX];
+       unsigned int route_in_devices[AVAIL_DEVICES_MAX];
+       unsigned int route_out_devices[AVAIL_DEVICES_MAX];
 } manual_route_info_s;
 
 typedef struct _sound_stream_info_s {
index 893d9aade72abeb849ce8aad46341affe85b09bf..d97ff0142fc004dfb5a64d1febf5e93530ddbe5b 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.3.2
+Version:    0.3.3
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index c2b573362c5ee677ce85ecb117efd51665daaf4d..1dbe830e449274cf7a1fe5c76c2b4dc0763f7a09 100644 (file)
@@ -192,6 +192,7 @@ int sound_manager_add_device_for_stream_routing (sound_stream_info_h stream_info
        int j = 0;
        bool added_successfully = false;
        char *device_type_str = NULL;
+       int device_id = 0;
        mm_sound_device_type_e device_type;
        mm_sound_device_io_direction_e device_direction;
        sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
@@ -202,6 +203,10 @@ int sound_manager_add_device_for_stream_routing (sound_stream_info_h stream_info
        SM_NULL_ARG_CHECK(device);
 
        if (stream_h->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL) {
+               ret = mm_sound_get_device_id(device, &device_id);
+               if (ret) {
+                       return __convert_sound_manager_error_code(__func__, ret);
+               }
                ret = mm_sound_get_device_type(device, &device_type);
                if (ret) {
                        return __convert_sound_manager_error_code(__func__, ret);
@@ -220,11 +225,11 @@ int sound_manager_add_device_for_stream_routing (sound_stream_info_h stream_info
                                        if(!strncmp(stream_h->stream_conf_info.avail_in_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
                                                for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
                                                        if (!stream_h->manual_route_info.route_in_devices[j]) {
-                                                               stream_h->manual_route_info.route_in_devices[j] = strdup(device_type_str);
+                                                               stream_h->manual_route_info.route_in_devices[j] = (unsigned int)device_id;
                                                                added_successfully = true;
                                                                break;
                                                        }
-                                                       if (!strncmp(stream_h->manual_route_info.route_in_devices[j], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
+                                                       if (stream_h->manual_route_info.route_in_devices[j] == (unsigned int)device_id) {
                                                                /* it was already set */
                                                                return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_DUPLICATED);
                                                        }
@@ -241,11 +246,11 @@ int sound_manager_add_device_for_stream_routing (sound_stream_info_h stream_info
                                        if(!strncmp(stream_h->stream_conf_info.avail_out_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
                                                for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
                                                        if (!stream_h->manual_route_info.route_out_devices[j]) {
-                                                               stream_h->manual_route_info.route_out_devices[j] = strdup(device_type_str);
+                                                               stream_h->manual_route_info.route_out_devices[j] = (unsigned int)device_id;
                                                                added_successfully = true;
                                                                break;
                                                        }
-                                                       if (!strncmp(stream_h->manual_route_info.route_out_devices[j], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
+                                                       if (stream_h->manual_route_info.route_out_devices[j] == (unsigned int)device_id) {
                                                                /* it was already set */
                                                                return __convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_DUPLICATED);
                                                        }
@@ -274,6 +279,7 @@ int sound_manager_remove_device_for_stream_routing (sound_stream_info_h stream_i
        int j = 0;
        bool removed_successfully = false;
        char *device_type_str = NULL;
+       int device_id = 0;
        mm_sound_device_type_e device_type;
        mm_sound_device_io_direction_e device_direction;
        sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
@@ -284,6 +290,10 @@ int sound_manager_remove_device_for_stream_routing (sound_stream_info_h stream_i
        SM_NULL_ARG_CHECK(device);
 
        if (stream_h->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL) {
+               ret = mm_sound_get_device_id(device, &device_id);
+               if (ret) {
+                       return __convert_sound_manager_error_code(__func__, ret);
+               }
                ret = mm_sound_get_device_type(device, &device_type);
                if (ret) {
                        return __convert_sound_manager_error_code(__func__, ret);
@@ -301,10 +311,9 @@ int sound_manager_remove_device_for_stream_routing (sound_stream_info_h stream_i
                                if (stream_h->stream_conf_info.avail_in_devices[i]) {
                                        if(!strncmp(stream_h->stream_conf_info.avail_in_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
                                                for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
-                                                       if (!strncmp(stream_h->manual_route_info.route_in_devices[j], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
+                                                       if (stream_h->manual_route_info.route_in_devices[j] == (unsigned int)device_id) {
                                                                removed_successfully = true;
-                                                               free(stream_h->manual_route_info.route_in_devices[j]);
-                                                               stream_h->manual_route_info.route_in_devices[j] = NULL;
+                                                               stream_h->manual_route_info.route_in_devices[j] = 0;
                                                                break;
                                                        }
                                                }
@@ -319,10 +328,9 @@ int sound_manager_remove_device_for_stream_routing (sound_stream_info_h stream_i
                                if (stream_h->stream_conf_info.avail_out_devices[i]) {
                                        if(!strncmp(stream_h->stream_conf_info.avail_out_devices[i], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
                                                for (j = 0; j < AVAIL_DEVICES_MAX; j++) {
-                                                       if (!strncmp(stream_h->manual_route_info.route_out_devices[j], device_type_str, SOUND_DEVICE_TYPE_LEN)) {
+                                                       if (stream_h->manual_route_info.route_out_devices[j] == (unsigned int)device_id) {
                                                                removed_successfully = true;
-                                                               free(stream_h->manual_route_info.route_out_devices[j]);
-                                                               stream_h->manual_route_info.route_out_devices[j] = NULL;
+                                                               stream_h->manual_route_info.route_out_devices[j] = 0;
                                                                break;
                                                        }
                                                }
index 61fbc47e69c93741c934bbdc3e0ad080e7e1613f..d6e5da78bd0c98a8fce21542b5303219a7d7a8cb 100644 (file)
@@ -578,20 +578,20 @@ int __set_manual_route_info (unsigned int index, manual_route_info_s *info)
                return MM_ERROR_SOUND_INTERNAL;
        }
 
-       builder_for_in_devices = g_variant_builder_new(G_VARIANT_TYPE("as"));
-       builder_for_out_devices = g_variant_builder_new(G_VARIANT_TYPE("as"));
+       builder_for_in_devices = g_variant_builder_new(G_VARIANT_TYPE("au"));
+       builder_for_out_devices = g_variant_builder_new(G_VARIANT_TYPE("au"));
        for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
                if (info->route_in_devices[i]) {
-                       g_variant_builder_add(builder_for_in_devices, "s", info->route_in_devices[i]);
-                       LOGI("[IN] %s", info->route_in_devices[i]);
+                       g_variant_builder_add(builder_for_in_devices, "u", info->route_in_devices[i]);
+                       LOGI("[IN] device_id:%u", info->route_in_devices[i]);
                } else {
                        break;
                }
        }
        for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
                if (info->route_out_devices[i]) {
-                       g_variant_builder_add(builder_for_out_devices, "s", info->route_out_devices[i]);
-                       LOGI("[OUT] %s", info->route_out_devices[i]);
+                       g_variant_builder_add(builder_for_out_devices, "u", info->route_out_devices[i]);
+                       LOGI("[OUT] device_id:%u", info->route_out_devices[i]);
                } else {
                        break;
                }
@@ -602,7 +602,7 @@ int __set_manual_route_info (unsigned int index, manual_route_info_s *info)
                                                        PA_STREAM_MANAGER_OBJECT_PATH,
                                                        PA_STREAM_MANAGER_INTERFACE,
                                                        PA_STREAM_MANAGER_METHOD_NAME_SET_STREAM_ROUTE_DEVICES,
-                                                       g_variant_new ("(uasas)", index, builder_for_in_devices, builder_for_out_devices),
+                                                       g_variant_new ("(uauau)", index, builder_for_in_devices, builder_for_out_devices),
                                                        G_VARIANT_TYPE("(s)"),
                                                        G_DBUS_CALL_FLAGS_NONE,
                                                        2000,
@@ -1069,12 +1069,6 @@ int _destroy_pa_connection_and_unregister_focus(sound_stream_info_s *stream_h)
                if (stream_h->stream_conf_info.avail_out_devices[i]) {
                        free(stream_h->stream_conf_info.avail_out_devices[i]);
                }
-               if (stream_h->manual_route_info.route_in_devices[i]) {
-                       free (stream_h->manual_route_info.route_in_devices[i]);
-               }
-               if (stream_h->manual_route_info.route_out_devices[i]) {
-                       free (stream_h->manual_route_info.route_out_devices[i]);
-               }
        }
        for (i = 0; i < AVAIL_FRAMEWORKS_MAX; i++) {
                if (stream_h->stream_conf_info.avail_frameworks[i]) {
index 7b338315792192c6017f7f71049e5b1e8e56befc..a64b95a62b3b3bc629dac4d1dc77f6a39c8c7bdd 100644 (file)
@@ -515,11 +515,11 @@ static void displaymenu()
        }
        else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING)
        {
-               g_print("*** input device type to add (0:built-in spk, 1:built-in rcv, 2:audio-jack, 3:bt)\n");
+               g_print("*** input device type to add (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt)\n");
        }
        else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING)
        {
-               g_print("*** input device type to remove (0:built-in spk, 1:built-in rcv, 2:audio-jack, 3:bt)\n");
+               g_print("*** input device type to remove (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt)\n");
        }
        else if (g_menu_state == CURRENT_STATUS_APPLY_STREAM_ROUTING)
        {
@@ -1232,16 +1232,19 @@ static void interpret (char *cmd)
                        bool need_to_go = false;
                        device_type = atoi(cmd);
                        switch(device_type) {
-                       case 0: /* built-in spk */
+                       case 0: /* built-in mic */
+                               selected_type = SOUND_DEVICE_BUILTIN_MIC;
+                               break;
+                       case 1: /* built-in spk */
                                selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
                                break;
-                       case 1: /* built-in rcv */
+                       case 2: /* built-in rcv */
                                selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
                                break;
-                       case 2: /* audio-jack */
+                       case 3: /* audio-jack */
                                selected_type = SOUND_DEVICE_AUDIO_JACK;
                                break;
-                       case 3: /* bt */
+                       case 4: /* bt */
                                selected_type = SOUND_DEVICE_BLUETOOTH;
                                break;
                        default:
@@ -1288,16 +1291,19 @@ static void interpret (char *cmd)
                        bool need_to_go = false;
                        device_type = atoi(cmd);
                        switch(device_type) {
-                       case 0: /* built-in spk */
+                       case 0: /* built-in mic */
+                               selected_type = SOUND_DEVICE_BUILTIN_MIC;
+                               break;
+                       case 1: /* built-in spk */
                                selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
                                break;
-                       case 1: /* built-in rcv */
+                       case 2: /* built-in rcv */
                                selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
                                break;
-                       case 2: /* audio-jack */
+                       case 3: /* audio-jack */
                                selected_type = SOUND_DEVICE_AUDIO_JACK;
                                break;
-                       case 3: /* bt */
+                       case 4: /* bt */
                                selected_type = SOUND_DEVICE_BLUETOOTH;
                                break;
                        default: