From: Jeongho Mok Date: Tue, 28 Apr 2015 04:26:23 +0000 (+0900) Subject: Get device-type as string and convert it X-Git-Tag: submit/tizen/20150715.092047~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b5fcdd7fa71fc2f35b167bd84a19c8d28f420ee;p=platform%2Fcore%2Fapi%2Fsound-manager.git Get device-type as string and convert it Change-Id: I2b9e8849a387c40b4c41ee498c073f3a3dc28240 Signed-off-by: Jeongho Mok --- diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h index d7c382e..789eda5 100644 --- a/include/sound_manager_private.h +++ b/include/sound_manager_private.h @@ -192,6 +192,8 @@ int __convert_device_type (sound_device_type_e device_type_enum, char **device_t int __convert_device_type_to_enum (char *device_type, sound_device_type_e *device_type_enum); +int __convert_device_io_direction (mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *sound_io_direction); + const char* __convert_api_name (native_api_e api_name); int __get_stream_conf_info (const char *stream_type, stream_conf_info_s *info); diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index d97ff01..3849e0a 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.3 +Version: 0.3.4 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager.c b/src/sound_manager.c index 1dbe830..dfb5223 100644 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -193,7 +193,6 @@ int sound_manager_add_device_for_stream_routing (sound_stream_info_h stream_info 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; @@ -207,11 +206,7 @@ int sound_manager_add_device_for_stream_routing (sound_stream_info_h stream_info 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); - } - ret = __convert_device_type(device_type, &device_type_str); + ret = mm_sound_get_device_type(device, &device_type_str); if (ret) { return __convert_sound_manager_error_code(__func__, ret); } @@ -280,7 +275,6 @@ int sound_manager_remove_device_for_stream_routing (sound_stream_info_h stream_i 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; @@ -294,11 +288,7 @@ int sound_manager_remove_device_for_stream_routing (sound_stream_info_h stream_i 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); - } - ret = __convert_device_type(device_type, &device_type_str); + ret = mm_sound_get_device_type(device, &device_type_str); if (ret) { return __convert_sound_manager_error_code(__func__, ret); } @@ -943,7 +933,11 @@ int sound_manager_get_prev_device (sound_device_list_h device_list, sound_device int sound_manager_get_device_type (sound_device_h device, sound_device_type_e *type) { int ret = MM_ERROR_NONE; - ret = mm_sound_get_device_type(device, (mm_sound_device_type_e*)type); + char *device_type = NULL; + ret = mm_sound_get_device_type(device, &device_type); + if (ret == MM_ERROR_NONE) { + ret = __convert_device_type_to_enum(device_type, type); + } return __convert_sound_manager_error_code(__func__, ret); } @@ -951,7 +945,11 @@ int sound_manager_get_device_type (sound_device_h device, sound_device_type_e *t int sound_manager_get_device_io_direction (sound_device_h device, sound_device_io_direction_e *io_direction) { int ret = MM_ERROR_NONE; - ret = mm_sound_get_device_io_direction(device, (mm_sound_device_io_direction_e*)io_direction); + mm_sound_device_io_direction_e mm_sound_io_direction; + ret = mm_sound_get_device_io_direction(device, &mm_sound_io_direction); + if (ret == MM_ERROR_NONE) { + ret = __convert_device_io_direction(mm_sound_io_direction, io_direction); + } return __convert_sound_manager_error_code(__func__, ret); } diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index d6e5da7..e241926 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -314,6 +314,8 @@ int __convert_device_type_to_enum (char *device_type, sound_device_type_e *devic *device_type_enum = SOUND_DEVICE_BLUETOOTH; } else if (!strncmp(device_type, "hdmi", SOUND_DEVICE_TYPE_LEN)) { *device_type_enum = SOUND_DEVICE_HDMI; + } else if (!strncmp(device_type, "forwarding", SOUND_DEVICE_TYPE_LEN)) { + *device_type_enum = SOUND_DEVICE_FORWARDING; } else if (!strncmp(device_type, "usb-audio", SOUND_DEVICE_TYPE_LEN)) { *device_type_enum = SOUND_DEVICE_USB_AUDIO; } else { @@ -324,6 +326,26 @@ int __convert_device_type_to_enum (char *device_type, sound_device_type_e *devic return ret; } +int __convert_device_io_direction (mm_sound_device_io_direction_e io_direction, sound_device_io_direction_e *sound_io_direction) +{ + int ret = MM_ERROR_NONE; + + SM_NULL_ARG_CHECK(sound_io_direction); + + switch (io_direction) { + case MM_SOUND_DEVICE_IO_DIRECTION_IN: + *sound_io_direction = SOUND_DEVICE_IO_DIRECTION_IN; + break; + case MM_SOUND_DEVICE_IO_DIRECTION_OUT: + *sound_io_direction = SOUND_DEVICE_IO_DIRECTION_OUT; + break; + case MM_SOUND_DEVICE_IO_DIRECTION_BOTH: + *sound_io_direction = SOUND_DEVICE_IO_DIRECTION_BOTH; + break; + } + return ret; +} + const char* __convert_api_name (native_api_e api_name) { const char* name = NULL; @@ -812,14 +834,18 @@ int __set_session_mode (_session_mode_e mode) goto ERROR_CASE; } else { while ((w_ret = mm_sound_get_next_device(device_list, &device)) == MM_ERROR_NONE) { - mm_sound_device_type_e type; + char *type = NULL; + sound_device_type_e type_e; ret = mm_sound_get_device_type(device, &type); + if (ret != MM_ERROR_NONE) + goto ERROR_CASE; + ret = __convert_device_type_to_enum(type, &type_e); if (ret != MM_ERROR_NONE) goto ERROR_CASE; switch (mode) { case _SESSION_MODE_VOICE_WITH_AUDIO_JACK: - if (type == MM_SOUND_DEVICE_TYPE_AUDIOJACK) { + if (type_e == SOUND_DEVICE_AUDIO_JACK) { mm_sound_device_io_direction_e io_direction; ret = mm_sound_get_device_io_direction(device, &io_direction); if (ret != MM_ERROR_NONE) @@ -830,7 +856,7 @@ int __set_session_mode (_session_mode_e mode) } break; case _SESSION_MODE_VOICE_WITH_BLUETOOTH: - if (type == MM_SOUND_DEVICE_TYPE_BLUETOOTH) { + if (type_e == SOUND_DEVICE_BLUETOOTH) { mm_sound_device_io_direction_e io_direction; ret = mm_sound_get_device_io_direction(device, &io_direction); if (ret != MM_ERROR_NONE) @@ -892,24 +918,28 @@ int __get_session_mode (_session_mode_e *mode) goto ERROR_CASE; } else { while ((w_ret = mm_sound_get_next_device(device_list, &device)) == MM_ERROR_NONE) { - mm_sound_device_type_e type; + char *type = NULL; + sound_device_type_e type_e; ret = mm_sound_get_device_type(device, &type); if (ret != MM_ERROR_NONE) goto ERROR_CASE; - switch (type) { - case MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER: + ret = __convert_device_type_to_enum(type, &type_e); + if (ret != MM_ERROR_NONE) + goto ERROR_CASE; + switch (type_e) { + case SOUND_DEVICE_BUILTIN_SPEAKER: *mode = _SESSION_MODE_VOICE_WITH_BUILTIN_SPEAKER; need_to_out = true; break; - case MM_SOUND_DEVICE_TYPE_BUILTIN_RECEIVER: + case SOUND_DEVICE_BUILTIN_RECEIVER: *mode = _SESSION_MODE_VOICE_WITH_BUILTIN_RECEIVER; need_to_out = true; break; - case MM_SOUND_DEVICE_TYPE_AUDIOJACK: + case SOUND_DEVICE_AUDIO_JACK: *mode = _SESSION_MODE_VOICE_WITH_AUDIO_JACK; need_to_out = true; break; - case MM_SOUND_DEVICE_TYPE_BLUETOOTH: + case SOUND_DEVICE_BLUETOOTH: *mode = _SESSION_MODE_VOICE_WITH_BLUETOOTH; need_to_out = true; break;