Get BT SCO device for call-video stream 05/108405/4 accepted/tizen/3.0/common/20170109.195800 accepted/tizen/3.0/ivi/20170109.003425 accepted/tizen/3.0/mobile/20170109.003332 accepted/tizen/3.0/tv/20170109.003359 accepted/tizen/3.0/wearable/20170109.003409 submit/tizen_3.0/20170106.062231
authorHyunseok Lee <hs7388.lee@samsung.com>
Wed, 4 Jan 2017 07:57:07 +0000 (16:57 +0900)
committerHyunseok Lee <hs7388.lee@samsung.com>
Thu, 5 Jan 2017 08:30:06 +0000 (17:30 +0900)
[Version] 5.0.122
[Profile] Common
[Issue Type] Bug

Change-Id: Ica5d3c3534c192b0bd0cca07e6d9babc9bdf2249

packaging/pulseaudio-modules-tizen.spec
src/module-tizenaudio-policy.c
src/stream-manager.c
src/stream-manager.h

index f416ce9..4cf6cfb 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          5.0.121
+Version:          5.0.122
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index a6b0bc2..f1b6dc3 100644 (file)
@@ -448,8 +448,8 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre
      * some targets use several pcm card as per their purpose.
      * e.g) using a specific pcm card during voice call. */
     if (data->occupying_role) {
-        if (pa_streq(data->occupying_role, STREAM_ROLE_CALL_VOICE)) {
-            data->device_role = DEVICE_ROLE_CALL_VOICE;
+        if (IS_ROLE_COMMUNICATION(data->occupying_role)) {
+            CONVERT_TO_DEVICE_ROLE(data->occupying_role, data->device_role);
             pa_log_info("[SELECT] current occupying stream role is [%s], set deivce role to [%s]", data->occupying_role, data->device_role);
         }
     }
@@ -919,7 +919,7 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
                 if ((device = pa_device_manager_get_device_by_id(u->device_manager, *device_id))) {
                     /* FIXME : This is temparary code, until App could give
                      * proper BT-SCO device for call-voice */
-                    if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(device->type, DEVICE_TYPE_BT_SCO)) {
+                    if (IS_ROLE_COMMUNICATION(route_info.role) && pa_streq(device->type, DEVICE_TYPE_BT_SCO)) {
                         pa_tz_device *sco_device;
                         if ((sco_device = _get_sco_connected_device(u->device_manager)) == NULL) {
                             pa_log_error("  ** could not find BT SCO");
@@ -936,7 +936,7 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
                         pa_log_debug("  ** found a matched device: type[%-16s], direction[0x%x]",
                                      dm_device_type, dm_device_direction);
                         /* Check for BT SCO in case of call routing */
-                        if (pa_streq(route_info.role, STREAM_ROLE_CALL_VOICE) && pa_streq(dm_device_type, DEVICE_TYPE_BT_SCO)) {
+                        if (IS_ROLE_COMMUNICATION(route_info.role) && pa_streq(dm_device_type, DEVICE_TYPE_BT_SCO)) {
                             /* update BT SCO: open */
                             if (update_bt_sco_state(u->device_manager, true)) {
                                 pa_log_error("  ** could not open BT SCO");
@@ -988,19 +988,22 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
     /* move stream(s) to a proper sink/source if needed */
     if (device && data->stream && data->origins_from_new_data) {
 
-        if (pa_streq(data->stream_role, STREAM_ROLE_CALL_VOICE)) {
+        if (IS_ROLE_COMMUNICATION(data->stream_role)) {
+            const char *device_role;
+
+            CONVERT_TO_DEVICE_ROLE(data->stream_role, device_role);
             if (data->stream_type == STREAM_SINK_INPUT) {
                 if (!(sink = pa_tz_device_get_sink(device, DEVICE_ROLE_NORMAL)) ||
-                    !(dst_sink = pa_tz_device_get_sink(device, DEVICE_ROLE_CALL_VOICE)) ||
+                    !(dst_sink = pa_tz_device_get_sink(device, device_role)) ||
                     sink == dst_sink)
-                    pa_log_info("[ROUTE][CALL-VOICE] no need to move streams, sink(%p), dst_sink(%p)", sink, dst_sink);
+                    pa_log_info("[ROUTE][%s] no need to move streams, sink(%p), dst_sink(%p)", data->stream_role, sink, dst_sink);
                 else
                     streams = sink->inputs;
             } else if (data->stream_type == STREAM_SOURCE_OUTPUT) {
                 if (!(source = pa_tz_device_get_source(device, DEVICE_ROLE_NORMAL)) ||
-                    !(dst_source = pa_tz_device_get_source(device, DEVICE_ROLE_CALL_VOICE)) ||
+                    !(dst_source = pa_tz_device_get_source(device, device_role)) ||
                     source == dst_source)
-                    pa_log_info("[ROUTE][CALL-VOICE] no need to move streams, source(%p), dst_source(%p)", source, dst_source);
+                    pa_log_info("[ROUTE][%s] no need to move streams, source(%p), dst_source(%p)", data->stream_role, source, dst_source);
                 else
                     streams = source->outputs;
             }
@@ -1009,12 +1012,12 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
                 PA_IDXSET_FOREACH(s, streams, idx) {
                     if (data->stream_type == STREAM_SINK_INPUT) {
                         pa_sink_input_move_to(s, dst_sink, false);
-                        pa_log_info("[ROUTE][CALL-VOICE] *** sink-input(%p,%u) moves to sink(%p,%s)",
-                                     s, ((pa_sink_input*)s)->index, dst_sink, dst_sink->name);
+                        pa_log_info("[ROUTE][%s] *** sink-input(%p,%u) moves to sink(%p,%s)",
+                                     data->stream_role, s, ((pa_sink_input*)s)->index, dst_sink, dst_sink->name);
                     } else if (data->stream_type == STREAM_SOURCE_OUTPUT) {
                         pa_source_output_move_to(s, dst_source, false);
-                        pa_log_info("[ROUTE][CALL-VOICE] *** source-output(%p,%u) moves to source(%p,%s)",
-                                     s, ((pa_source_output*)s)->index, dst_source, dst_source->name);
+                        pa_log_info("[ROUTE][%s] *** source-output(%p,%u) moves to source(%p,%s)",
+                                     data->stream_role, s, ((pa_source_output*)s)->index, dst_source, dst_source->name);
                     }
                 }
                 /* make sure the previous device is closed */
index e1ac154..e90097d 100644 (file)
@@ -470,18 +470,6 @@ typedef struct _stream_route_option {
 #define CONVERT_TO_DEVICE_DIRECTION(stream_type) \
     ((stream_type == STREAM_SINK_INPUT) ? DM_DEVICE_DIRECTION_OUT : DM_DEVICE_DIRECTION_IN)
 
-#define CONVERT_TO_DEVICE_ROLE(x_stream_role, x_device_role) { \
-    pa_assert(x_stream_role); \
-    if (pa_streq(x_stream_role, STREAM_ROLE_CALL_VOICE)) \
-        x_device_role = DEVICE_ROLE_CALL_VOICE; \
-    else if (pa_streq(x_stream_role, STREAM_ROLE_CALL_VIDEO)) \
-        x_device_role = DEVICE_ROLE_CALL_VIDEO; \
-    else if (pa_streq(x_stream_role, STREAM_ROLE_VOIP)) \
-        x_device_role = DEVICE_ROLE_VOIP; \
-    else \
-        x_device_role = DEVICE_ROLE_NORMAL; \
-} \
-
 static void do_notify(pa_stream_manager *m, notify_command_type_t command, stream_type_t type, bool is_new_data, void *user_data);
 static process_stream_result_t process_stream(pa_stream_manager *m, void *stream, stream_type_t type, process_command_type_t command, bool is_new_data);
 
@@ -495,12 +483,7 @@ static bool stream_is_call_family(pa_object *stream) {
         prop = PA_SOURCE_OUTPUT(stream)->proplist;
 
     stream_role = pa_proplist_gets(prop, PA_PROP_MEDIA_ROLE);
-
-    if (pa_safe_streq(stream_role, STREAM_ROLE_CALL_VOICE))
-        return true;
-    else if (pa_safe_streq(stream_role, STREAM_ROLE_CALL_VIDEO))
-        return true;
-    else if (pa_safe_streq(stream_role, STREAM_ROLE_VOIP))
+    if (stream_role && IS_ROLE_COMMUNICATION(stream_role))
         return true;
 
     return false;
index 5eb5fab..306b844 100644 (file)
 #define IS_ROUTE_TYPE_FOR_AUTO_LAST_CONN(route_type_str, route_type) \
       (route_type_str && !pa_atoi(route_type_str, (int32_t*)&route_type) && (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))
 
+#define IS_ROLE_COMMUNICATION(stream_role) \
+      (pa_streq(stream_role, STREAM_ROLE_CALL_VOICE) || pa_streq(stream_role, STREAM_ROLE_CALL_VIDEO) || pa_streq(stream_role, STREAM_ROLE_VOIP))
+
+#define CONVERT_TO_DEVICE_ROLE(x_stream_role, x_device_role) \
+do { \
+    pa_assert(x_stream_role); \
+    if (pa_streq(x_stream_role, STREAM_ROLE_CALL_VOICE)) \
+        x_device_role = DEVICE_ROLE_CALL_VOICE; \
+    else if (pa_streq(x_stream_role, STREAM_ROLE_CALL_VIDEO)) \
+        x_device_role = DEVICE_ROLE_CALL_VIDEO; \
+    else if (pa_streq(x_stream_role, STREAM_ROLE_VOIP)) \
+        x_device_role = DEVICE_ROLE_VOIP; \
+    else \
+        x_device_role = DEVICE_ROLE_NORMAL; \
+} while (0)
+
 #define GET_STREAM_NEW_PROPLIST(stream, type) \
       (type == STREAM_SINK_INPUT ? ((pa_sink_input_new_data*)stream)->proplist : ((pa_source_output_new_data*)stream)->proplist)