From: Sangchul Lee Date: Fri, 4 Aug 2017 02:08:35 +0000 (+0900) Subject: Add new API to remove all devices from stream information handle X-Git-Tag: submit/tizen/20170828.011335~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f0895b01974ef01f28f2ec141a76784c8877cac;p=platform%2Fcore%2Fapi%2Fsound-manager.git Add new API to remove all devices from stream information handle [Version] 0.4.18 [Issue Type] New API Change-Id: I3c918cf712e3bcbddb79fe3613cb2e06e0a6e55e Signed-off-by: Sangchul Lee --- diff --git a/include/sound_manager.h b/include/sound_manager.h index db6fa95..9b9ec4e 100644 --- a/include/sound_manager.h +++ b/include/sound_manager.h @@ -662,6 +662,7 @@ int sound_manager_remove_volume_changed_cb(int id); * @see sound_manager_destroy_stream_information() * @see sound_manager_add_device_for_stream_routing() * @see sound_manager_remove_device_for_stream_routing() + * @see sound_manager_remove_all_devices_for_stream_routing() * @see sound_manager_apply_stream_routing() * @see sound_manager_acquire_focus() * @see sound_manager_destroy_focus() @@ -686,6 +687,7 @@ int sound_manager_create_stream_information(sound_stream_type_e stream_type, sou * @see sound_manager_create_stream_information() * @see sound_manager_add_device_for_stream_routing() * @see sound_manager_remove_device_for_stream_routing() + * @see sound_manager_remove_all_devices_for_stream_routing() * @see sound_manager_apply_stream_routing() * @see sound_manager_acquire_focus() * @see sound_manager_destroy_focus() @@ -735,12 +737,13 @@ int sound_manager_get_sound_type(sound_stream_info_h stream_info, sound_type_e * * @see sound_manager_create_stream_information() * @see sound_manager_destroy_stream_information() * @see sound_manager_remove_device_for_stream_routing() + * @see sound_manager_remove_all_devices_for_stream_routing() * @see sound_manager_apply_stream_routing() */ int sound_manager_add_device_for_stream_routing(sound_stream_info_h stream_info, sound_device_h device); /** - * @brief Removes the device to the stream information for the stream routing. + * @brief Removes the device from the stream information for the stream routing. * @since_tizen 3.0 * * @remarks Use sound_manager_get_device_list() and sound_manager_get_next_device() to get the device.\n @@ -756,10 +759,30 @@ int sound_manager_add_device_for_stream_routing(sound_stream_info_h stream_info, * @see sound_manager_create_stream_information() * @see sound_manager_destroy_stream_information() * @see sound_manager_add_device_for_stream_routing() + * @see sound_manager_remove_all_devices_for_stream_routing() * @see sound_manager_apply_stream_routing() */ int sound_manager_remove_device_for_stream_routing(sound_stream_info_h stream_info, sound_device_h device); +/** + * @brief Removes all devices from the stream information for the stream routing. + * @since_tizen 4.0 + * + * @param[in] stream_info The handle of stream information + * @return @c 0 on success, + * otherwise a negative error value + * @retval #SOUND_MANAGER_ERROR_NONE Success + * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy + * @pre Call sound_manager_create_stream_information() before calling this function. + * @see sound_manager_create_stream_information() + * @see sound_manager_destroy_stream_information() + * @see sound_manager_add_device_for_stream_routing() + * @see sound_manager_remove_device_for_stream_routing() + * @see sound_manager_apply_stream_routing() + */ +int sound_manager_remove_all_devices_for_stream_routing(sound_stream_info_h stream_info); + /** * @brief Applies the stream routing. * @since_tizen 3.0 @@ -778,6 +801,7 @@ int sound_manager_remove_device_for_stream_routing(sound_stream_info_h stream_in * @see sound_manager_destroy_stream_information() * @see sound_manager_add_device_for_stream_routing() * @see sound_manager_remove_device_for_stream_routing() + * @see sound_manager_remove_all_devices_for_stream_routing() */ int sound_manager_apply_stream_routing(sound_stream_info_h stream_info); diff --git a/include/sound_manager_internal.h b/include/sound_manager_internal.h index 7d4b494..55c11fd 100644 --- a/include/sound_manager_internal.h +++ b/include/sound_manager_internal.h @@ -176,6 +176,7 @@ int sound_manager_get_master_volume(int *level); * @see sound_manager_destroy_stream_information() * @see sound_manager_add_device_for_stream_routing() * @see sound_manager_remove_device_for_stream_routing() + * @see sound_manager_remove_all_devices_for_stream_routing() * @see sound_manager_apply_stream_routing() * @see sound_manager_acquire_focus() * @see sound_manager_destroy_focus() @@ -275,6 +276,7 @@ int sound_manager_get_index_from_stream_information(sound_stream_info_h stream_i * @see sound_manager_create_stream_information() * @see sound_manager_destroy_stream_information() * @see sound_manager_remove_device_id_for_stream_routing() + * @see sound_manager_remove_all_devices_for_stream_routing() * @see sound_manager_apply_stream_routing() */ int sound_manager_add_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id); @@ -298,6 +300,7 @@ int sound_manager_add_device_id_for_stream_routing(sound_stream_info_h stream_in * @see sound_manager_create_stream_information() * @see sound_manager_destroy_stream_information() * @see sound_manager_add_device_id_for_stream_routing() + * @see sound_manager_remove_all_devices_for_stream_routing() * @see sound_manager_apply_stream_routing() */ int sound_manager_remove_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id); diff --git a/include/sound_manager_internal_tv.h b/include/sound_manager_internal_tv.h index 2d4af1a..c30d891 100644 --- a/include/sound_manager_internal_tv.h +++ b/include/sound_manager_internal_tv.h @@ -131,6 +131,7 @@ typedef enum { * @see sound_manager_destroy_stream_information() * @see sound_manager_add_device_for_stream_routing() * @see sound_manager_remove_device_for_stream_routing() + * @see sound_manager_remove_all_devices_for_stream_routing() * @see sound_manager_apply_stream_routing() * @see sound_manager_acquire_focus() * @see sound_manager_destroy_focus() @@ -230,6 +231,7 @@ int sound_manager_get_index_from_stream_information(sound_stream_info_h stream_i * @see sound_manager_create_stream_information() * @see sound_manager_destroy_stream_information() * @see sound_manager_remove_device_id_for_stream_routing() + * @see sound_manager_remove_all_devices_for_stream_routing() * @see sound_manager_apply_stream_routing() */ int sound_manager_add_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id); @@ -253,6 +255,7 @@ int sound_manager_add_device_id_for_stream_routing(sound_stream_info_h stream_in * @see sound_manager_create_stream_information() * @see sound_manager_destroy_stream_information() * @see sound_manager_add_device_id_for_stream_routing() + * @see sound_manager_remove_all_devices_for_stream_routing() * @see sound_manager_apply_stream_routing() */ int sound_manager_remove_device_id_for_stream_routing(sound_stream_info_h stream_info, int device_id); diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h index 4d0a51b..eb93cf2 100644 --- a/include/sound_manager_private.h +++ b/include/sound_manager_private.h @@ -302,6 +302,8 @@ int _add_device_for_stream_routing(sound_stream_info_s *stream_info, sound_devic int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_device_h device); +int _remove_all_devices_for_stream_routing(sound_stream_info_s *stream_info); + int _add_device_id_for_stream_routing(sound_stream_info_s *stream_info, int device_id); int _remove_device_id_for_stream_routing(sound_stream_info_s *stream_info, int device_id); diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index 840910d..db498c6 100644 --- 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.4.17 +Version: 0.4.18 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager.c b/src/sound_manager.c index 113a2d0..b4c9d64 100644 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -326,6 +326,18 @@ int sound_manager_remove_device_for_stream_routing(sound_stream_info_h stream_in return _convert_sound_manager_error_code(__func__, ret); } +int sound_manager_remove_all_devices_for_stream_routing(sound_stream_info_h stream_info) +{ + int ret = MM_ERROR_NONE; + sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info; + + LOGI(">> enter"); + + ret = _remove_all_devices_for_stream_routing(stream_h); + + return _convert_sound_manager_error_code(__func__, ret); +} + int sound_manager_apply_stream_routing(sound_stream_info_h stream_info) { int ret = MM_ERROR_NONE; diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index 699ee83..207ce5e 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -1888,7 +1888,7 @@ static int __add_device_to_stream_info(sound_stream_info_s *stream_info, int dev return MM_ERROR_NONE; } -static int __remove_device_to_stream_info(sound_stream_info_s *stream_info, int device_id, mm_sound_device_io_direction_e device_direction, char *device_type_str) +static int __remove_device_from_stream_info(sound_stream_info_s *stream_info, int device_id, mm_sound_device_io_direction_e device_direction, char *device_type_str) { int i, j; bool removed_successfully = false; @@ -1997,7 +1997,7 @@ int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_de if ((ret = mm_sound_get_device_io_direction(device, &device_direction))) return ret; - if ((ret = __remove_device_to_stream_info(stream_info, device_id, device_direction, device_type_str))) + if ((ret = __remove_device_from_stream_info(stream_info, device_id, device_direction, device_type_str))) return ret; LOGI("*** removed device[type:%s, id:%d]", device_type_str, device_id); @@ -2005,6 +2005,28 @@ int _remove_device_for_stream_routing(sound_stream_info_s *stream_info, sound_de return MM_ERROR_NONE; } +int _remove_all_devices_for_stream_routing(sound_stream_info_s *stream_info) +{ + int ret = MM_ERROR_NONE; + int i; + + SM_INSTANCE_CHECK_FOR_PRIV(stream_info); + + if ((ret = __check_manual_route_type(stream_info))) + return ret; + + for (i = 0; i < AVAIL_DEVICES_MAX; i++) { + stream_info->manual_route_info.route_in_devices[i] = 0; + stream_info->manual_route_info.route_out_devices[i] = 0; + } + + stream_info->manual_route_info.is_set = false; + + LOGI("*** removed all devices"); + + return MM_ERROR_NONE; +} + int _add_device_id_for_stream_routing(sound_stream_info_s *stream_info, int device_id) { int ret = MM_ERROR_NONE; @@ -2066,7 +2088,7 @@ int _remove_device_id_for_stream_routing(sound_stream_info_s *stream_info, int d if ((ret = mm_sound_get_device_io_direction(device, &device_direction))) goto LEAVE; - if ((ret = __remove_device_to_stream_info(stream_info, device_id, device_direction, device_type_str))) + if ((ret = __remove_device_from_stream_info(stream_info, device_id, device_direction, device_type_str))) goto LEAVE; LOGI("*** removed device by id[type:%s, id:%d]", device_type_str, device_id); diff --git a/test/sound_manager_test.c b/test/sound_manager_test.c index 4399a2c..193f758 100644 --- a/test/sound_manager_test.c +++ b/test/sound_manager_test.c @@ -69,6 +69,7 @@ enum { CURRENT_STATUS_CREATE_STREAM_INFO, CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING, CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING, + CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING, CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING, CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING, CURRENT_STATUS_APPLY_STREAM_ROUTING, @@ -235,6 +236,8 @@ void _interpret_main_menu(char *cmd) g_menu_state = CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING; else if (strncmp(cmd, "rds", 3) == 0) g_menu_state = CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING; + else if (strncmp(cmd, "rad", 3) == 0) + g_menu_state = CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING; else if (strncmp(cmd, "adi", 3) == 0) g_menu_state = CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING; else if (strncmp(cmd, "rdi", 3) == 0) @@ -362,10 +365,11 @@ void display_sub_basic() g_print("dsi. Destroy Stream Info\n"); g_print("gst. Get Sound Type\n"); g_print("ads. Add Device for Stream Routing\t"); - g_print("rds. Remove Device for Stream Routing\t"); - g_print("aps. Apply devices for Stream Routing\n"); + g_print("rds. Remove Device for Stream Routing\n"); g_print("adi. *Add Device ID for Stream Routing\t"); g_print("rdi. *Remove Device ID for Stream Routing\n"); + g_print("aps. Apply devices for Stream Routing\t"); + g_print("rad. Remove all devices for Stream Routing\n"); g_print("afc. Acquire Focus\t"); g_print("rfc. Release Focus\t"); g_print("gfs. Get Focus State\n"); @@ -479,6 +483,8 @@ static void displaymenu() g_print("*** input device type to add (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n"); else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING) g_print("*** input device type to remove (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n"); + else if (g_menu_state == CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING) + g_print("*** press enter to remove all devices in stream info\n"); else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING) g_print("*** input device type to add (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt-a2dp, 5:bt-sco 6:usb)\n"); else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_ID_FOR_STREAM_ROUTING) @@ -1408,6 +1414,15 @@ static void interpret(char *cmd) } break; } + case CURRENT_STATUS_REMOVE_ALL_DEVICES_FOR_STREAM_ROUTING: { + int ret = SOUND_MANAGER_ERROR_NONE; + + if ((ret = sound_manager_remove_all_devices_for_stream_routing(g_stream_info_h))) + g_print("fail to remove all devices for stream routing, ret[0x%x]\n", ret); + + reset_menu_state(); + break; + } case CURRENT_STATUS_ADD_DEVICE_ID_FOR_STREAM_ROUTING: { int ret = SOUND_MANAGER_ERROR_NONE; int device_type = 0;