Support a new stream type that is only for external devices (SOUND_STREAM_TYPE_MEDIA_... 24/49124/5
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 7 Oct 2015 01:52:21 +0000 (10:52 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 2 Nov 2015 10:16:25 +0000 (19:16 +0900)
[Version] Release 0.3.21
[profile] Common
[Issue Type] New Feature

Change-Id: I7395d4c0504043780ac009d73437cfd4940ed105
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/sound_manager.h
include/sound_manager_private.h
packaging/capi-media-sound-manager.spec
src/sound_manager_private.c
test/sound_manager_test.c

index a8b53b3cb513cb79316744c89538aa7d3906c589..e6774b2a2ec95d5aa0bbf7c6b4b648da2820019b 100644 (file)
@@ -103,6 +103,7 @@ typedef enum {
        SOUND_STREAM_TYPE_VOICE_RECOGNITION,  /**< Sound stream type for voice recognition */
        SOUND_STREAM_TYPE_RINGTONE_VOIP,      /**< Sound stream type for ringtone for VoIP */
        SOUND_STREAM_TYPE_VOIP,               /**< Sound stream type for VoIP */
+       SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY,/**< Sound stream type for media only for external devices */
 } sound_stream_type_e;
 
 /**
@@ -110,16 +111,17 @@ typedef enum {
  * @since_tizen 3.0
  */
 typedef enum {
-       SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA,             /**< Changed by the stream type for media */
-       SOUND_STREAM_FOCUS_CHANGED_BY_SYSTEM,            /**< Changed by the stream type for system */
-       SOUND_STREAM_FOCUS_CHANGED_BY_ALARM,             /**< Changed by the stream type for alarm */
-       SOUND_STREAM_FOCUS_CHANGED_BY_NOTIFICATION,      /**< Changed by the stream type for notification */
-       SOUND_STREAM_FOCUS_CHANGED_BY_EMERGENCY,         /**< Changed by the stream type for emergency */
-       SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION, /**< Changed by the stream type for voice information */
-       SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_RECOGNITION, /**< Changed by the stream type for voice recognition */
-       SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE,          /**< Changed by the stream type for ringtone */
-       SOUND_STREAM_FOCUS_CHANGED_BY_VOIP,              /**< Changed by the stream type for VoIP */
-       SOUND_STREAM_FOCUS_CHANGED_BY_CALL,              /**< Changed by the stream type for voice-call or video-call */
+       SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA,              /**< Changed by the stream type for media */
+       SOUND_STREAM_FOCUS_CHANGED_BY_SYSTEM,             /**< Changed by the stream type for system */
+       SOUND_STREAM_FOCUS_CHANGED_BY_ALARM,              /**< Changed by the stream type for alarm */
+       SOUND_STREAM_FOCUS_CHANGED_BY_NOTIFICATION,       /**< Changed by the stream type for notification */
+       SOUND_STREAM_FOCUS_CHANGED_BY_EMERGENCY,          /**< Changed by the stream type for emergency */
+       SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_INFORMATION,  /**< Changed by the stream type for voice information */
+       SOUND_STREAM_FOCUS_CHANGED_BY_VOICE_RECOGNITION,  /**< Changed by the stream type for voice recognition */
+       SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE,           /**< Changed by the stream type for ringtone */
+       SOUND_STREAM_FOCUS_CHANGED_BY_VOIP,               /**< Changed by the stream type for VoIP */
+       SOUND_STREAM_FOCUS_CHANGED_BY_CALL,               /**< Changed by the stream type for voice-call or video-call */
+       SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA_EXTERNAL_ONLY,/**< Changed by the stream type for media only for external devices */
 } sound_stream_focus_change_reason_e;
 
 /**
index 00d20d22e96027055ce81b62a1484953b38f5f75..ff1a218ef7a62ce7106b23031421382288932d0f 100644 (file)
@@ -122,9 +122,10 @@ typedef enum _sound_stream_direction {
 
 /* it should be synchronized with pulseaudio's */
 typedef enum stream_route_type {
-       STREAM_ROUTE_TYPE_AUTO,     /* the policy of decision device(s) is automatic and it's routing path is particular to one device */
-       STREAM_ROUTE_TYPE_AUTO_ALL, /* the policy of decision device(s) is automatic and it's routing path can be several devices */
-       STREAM_ROUTE_TYPE_MANUAL,   /* the policy of decision device(s) is manual */
+       STREAM_ROUTE_TYPE_AUTO,       /* the policy of decision device(s) is automatic and it's routing path is particular to one device */
+       STREAM_ROUTE_TYPE_AUTO_ALL,   /* the policy of decision device(s) is automatic and it's routing path can be several devices */
+       STREAM_ROUTE_TYPE_MANUAL,     /* the policy of decision device(s) is manual */
+       STREAM_ROUTE_TYPE_MANUAL_EXT, /* the policy of decision device(s) is manual and it's routing path is only for external devices */
 } stream_route_type;
 #define AVAIL_DEVICES_MAX 16
 #define AVAIL_FRAMEWORKS_MAX 16
index 29642cd1ee9811ed6dc9831c8fbf4da4cab7dcc7..42241ed857495ff32ee77fe1fb78b1fab112a2de 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.3.20
+Version:    0.3.21
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 617f9942e90352236a14c72be471572a698cbfd7..5a2a73f493685f077299d6c8a61c78bf975db537 100644 (file)
@@ -135,6 +135,9 @@ int _convert_stream_type (sound_stream_type_e stream_type_enum, char **stream_ty
        case SOUND_STREAM_TYPE_VOIP:
                *stream_type = "voip";
                break;
+       case SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY:
+               *stream_type = "ext-media";
+               break;
        default:
                LOGE("could not find the stream_type[%d] in this switch case statement", stream_type_enum);
                ret = MM_ERROR_SOUND_INTERNAL;
@@ -219,6 +222,10 @@ int _convert_stream_type_to_change_reason (const char *stream_type, sound_stream
        } else if (!strncmp(stream_type, "call-voice", SOUND_STREAM_TYPE_LEN) ||
                        !strncmp(stream_type, "call-video", SOUND_STREAM_TYPE_LEN)) {
                *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_CALL;
+
+       } else if (!strncmp(stream_type, "ext-media", SOUND_STREAM_TYPE_LEN)) {
+               *change_reason = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA_EXTERNAL_ONLY;
+
        } else {
                ret = MM_ERROR_INVALID_ARGUMENT;
                LOGE("not supported stream_type(%s), err(0x%08x)", stream_type, ret);
@@ -238,7 +245,8 @@ static int _convert_stream_type_to_interrupt_reason (const char *stream_type, so
                !strncmp(stream_type, "system", SOUND_STREAM_TYPE_LEN) ||
                !strncmp(stream_type, "voice-information", SOUND_STREAM_TYPE_LEN) ||
                !strncmp(stream_type, "voice-recognition", SOUND_STREAM_TYPE_LEN) ||
-               !strncmp(stream_type, "loopback", SOUND_STREAM_TYPE_LEN)) {
+               !strncmp(stream_type, "loopback", SOUND_STREAM_TYPE_LEN) ||
+               !strncmp(stream_type, "ext-media", SOUND_STREAM_TYPE_LEN)) {
                *change_reason = SOUND_SESSION_INTERRUPTED_BY_MEDIA;
 
        } else if (!strncmp(stream_type, "alarm", SOUND_STREAM_TYPE_LEN)) {
@@ -1349,6 +1357,10 @@ int _add_device_for_stream_routing (sound_stream_info_s *stream_info, sound_devi
        int i = 0;
        int j = 0;
        bool added_successfully = false;
+#if 0
+       /* not ready yet. after preparing in libmm-sound, it'll be enabled */
+       bool use_internal_codec = false;
+#endif
        char *device_type_str = NULL;
        int device_id = 0;
        mm_sound_device_type_e device_type;
@@ -1357,7 +1369,19 @@ int _add_device_for_stream_routing (sound_stream_info_s *stream_info, sound_devi
        SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
        SM_NULL_ARG_CHECK_FOR_PRIV(device);
 
-       if (stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL) {
+       if (stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL ||
+                       stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL_EXT) {
+#if 0
+               /* not ready yet. after preparing in libmm-sound, it'll be enabled */
+               if (stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL_EXT) {
+                       ret = mm_sound_get_device_use_internal_codec(device, &use_internal_codec);
+                       if (ret) {
+                               return _convert_sound_manager_error_code(__func__, ret);
+                       }
+                       if (use_internal_codec)
+                               return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
+               }
+#endif
                ret = mm_sound_get_device_id(device, &device_id);
                if (ret) {
                        return _convert_sound_manager_error_code(__func__, ret);
@@ -1439,7 +1463,8 @@ int _remove_device_for_stream_routing (sound_stream_info_s *stream_info, sound_d
        SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
        SM_NULL_ARG_CHECK_FOR_PRIV(device);
 
-       if (stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL) {
+       if (stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL ||
+                       stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL_EXT) {
                ret = mm_sound_get_device_id(device, &device_id);
                if (ret) {
                        return _convert_sound_manager_error_code(__func__, ret);
@@ -1504,7 +1529,8 @@ int _apply_stream_routing (sound_stream_info_s *stream_info)
 
        SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
 
-       if (stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL) {
+       if (stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL ||
+                       stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL_EXT) {
                for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
                        if (stream_info->manual_route_info.route_in_devices[i]) {
                                need_to_apply = true;
@@ -1597,7 +1623,8 @@ int _start_virtual_stream (virtual_sound_stream_info_s *virtual_stream)
        SM_INSTANCE_CHECK_FOR_PRIV(virtual_stream);
        SM_STATE_CHECK_FOR_PRIV(virtual_stream, _VSTREAM_STATE_READY);
 
-       if (virtual_stream->stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL) {
+       if (virtual_stream->stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL ||
+                       virtual_stream->stream_info->stream_conf_info.route_type == STREAM_ROUTE_TYPE_MANUAL_EXT) {
                /* check if the manual route info. is set when it comes to the manual route type */
                if (virtual_stream->stream_info->manual_route_info.is_set == false) {
                        ret = MM_ERROR_SOUND_INVALID_STATE;
index 0a1c3b88935ceb8f93923aba3a60853b5e0317a9..7e209f99cbb5d4780a2bbb2e742bc4173dc06a86 100644 (file)
@@ -499,7 +499,7 @@ static void displaymenu()
        }
        else if (g_menu_state == CURRENT_STATUS_CREATE_STREAM_INFO)
        {
-               g_print("*** input stream type to create stream information (0:media, 1:alarm, 2:notification, 3:ringtone-call, 4:voice-call, 5:voip)\n");
+               g_print("*** input stream type to create stream information (0:media, 1:alarm, 2:notification, 3:ringtone-call, 4:voice-call, 5:voip, 6:media-ext-only)\n");
        }
        else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING)
        {
@@ -1190,6 +1190,9 @@ static void interpret (char *cmd)
                        case 5: /* voip */
                                type = SOUND_STREAM_TYPE_VOIP;
                                break;
+                       case 6: /* media only for external devices */
+                               type = SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY;
+                               break;
                        default:
                                type = SOUND_STREAM_TYPE_MEDIA;
                                break;