From: Sangchul Lee Date: Mon, 4 May 2015 01:09:44 +0000 (+0900) Subject: Send device_id list to pulseaudio via dbus when applying devices for manual routing X-Git-Tag: submit/tizen/20150715.092047~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F41107%2F2;p=platform%2Fcore%2Fapi%2Fsound-manager.git Send device_id list to pulseaudio via dbus when applying devices for manual routing Modify sound_manager_test for manual routing Change-Id: Ie8c6c9098c9447cf3c1c00f451549150b1219e5c --- diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h index 09e8ad3..d7c382e 100644 --- a/include/sound_manager_private.h +++ b/include/sound_manager_private.h @@ -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 { diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index 893d9aa..d97ff01 100755 --- a/packaging/capi-media-sound-manager.spec +++ b/packaging/capi-media-sound-manager.spec @@ -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 diff --git a/src/sound_manager.c b/src/sound_manager.c index c2b5733..1dbe830 100644 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -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; } } diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index 61fbc47..d6e5da7 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -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]) { diff --git a/test/sound_manager_test.c b/test/sound_manager_test.c index 7b33831..a64b95a 100644 --- a/test/sound_manager_test.c +++ b/test/sound_manager_test.c @@ -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: