Get device-type as string and convert it 08/41108/2
authorJeongho Mok <jho.mok@samsung.com>
Tue, 28 Apr 2015 04:26:23 +0000 (13:26 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 8 Jul 2015 05:37:50 +0000 (14:37 +0900)
Change-Id: I2b9e8849a387c40b4c41ee498c073f3a3dc28240
Signed-off-by: Jeongho Mok <jho.mok@samsung.com>
include/sound_manager_private.h
packaging/capi-media-sound-manager.spec
src/sound_manager.c
src/sound_manager_private.c

index d7c382e9b7342941386412e6946563dd68ba3d8e..789eda5d91282f5d251029ee1a916b04df24794f 100644 (file)
@@ -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);
index d97ff0142fc004dfb5a64d1febf5e93530ddbe5b..3849e0a721980e084445e17d57ec544264b5f64c 100755 (executable)
@@ -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
index 1dbe830e449274cf7a1fe5c76c2b4dc0763f7a09..dfb5223c2da2e7e45fb313fb6eb9ca42c16d0f80 100644 (file)
@@ -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);
 }
index d6e5da78bd0c98a8fce21542b5303219a7d7a8cb..e241926d04f098f63e0d51e77c85fe7ce0e5b4db 100644 (file)
@@ -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;