stream-manager: Exclude bt-a2dp among available devices of incoming stream during... 60/118560/9
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 13 Mar 2017 06:40:03 +0000 (15:40 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 13 Mar 2017 08:58:01 +0000 (17:58 +0900)
If bt-sco is used by communication stream, other streams can not go with bt-a2dp due to the limitation of bluetooth.
We exclude bt-a2dp device type from available devices of a stream, therefore the stream can be mixed together
by using another device.

[Version] 5.0.138
[Profile] Common
[Issue Type] Exception

Change-Id: I809cf50a7d8c283e5a82b2894f8f2ca70ff0ab4d
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/pulseaudio-modules-tizen.spec
src/stream-manager.c

index 83f46142fe07d5b03ed16840583a65b4858be119..ddd2eccb2e0d07d1e6c5da9acca58550c2586854 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          5.0.137
+Version:          5.0.138
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 9b653ab26a85f813690d6ff644018ea398848f63..2116e29ce5b61777173f911b6ee85027a71b3098 100644 (file)
@@ -2224,18 +2224,16 @@ static bool update_focus_status_of_stream(pa_stream_manager *m, void *stream, st
     else
         p_idx = pa_proplist_gets(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_PARENT_ID);
     if (p_idx && !pa_atou(p_idx, &parent_idx)) {
-        sp = pa_hashmap_get(m->stream_parents, (const void*)parent_idx);
-        if (sp) {
-            if (is_new_data)
-                pa_proplist_setf(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_FOCUS_STATUS, "%u", sp->focus_status);
-            else
-                pa_proplist_setf(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_FOCUS_STATUS, "%u", sp->focus_status);
-
-            pa_log_debug("p_idx(%s), idx(%u), focus_status(0x%x, 0x1:playback 0x2:capture 0x3:both)", p_idx, parent_idx, sp->focus_status);
-        } else {
+        if (!(sp = pa_hashmap_get(m->stream_parents, (const void*)parent_idx))) {
             pa_log_error("could not find matching client for this parent_id(%u)", parent_idx);
             return false;
         }
+        if (is_new_data)
+            pa_proplist_setf(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_FOCUS_STATUS, "%u", sp->focus_status);
+        else
+            pa_proplist_setf(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_FOCUS_STATUS, "%u", sp->focus_status);
+
+        pa_log_debug("p_idx(%s), idx(%u), focus_status(0x%x, 0x1:playback 0x2:capture 0x3:both)", p_idx, parent_idx, sp->focus_status);
     }
 
     /* set focus status regardless of parent id existence */
@@ -2561,6 +2559,28 @@ static void update_buffer_attribute(pa_stream_manager *m, void *new_data, stream
     }
 }
 
+static int exclude_device_filter_func(const void *device_type, const void *exclude_device_type) {
+    pa_assert(device_type);
+    pa_assert(exclude_device_type);
+
+    if (pa_safe_streq((const char*)device_type, (const char*)exclude_device_type)) {
+        pa_log_info("[%s] is excluded", (const char*)device_type);
+        return 0;
+    }
+
+    return 1;
+}
+
+static pa_idxset* get_avail_devices_except_bt_a2dp(pa_idxset *avail_devices) {
+    pa_idxset *filtered_devices;
+
+    pa_assert(avail_devices);
+
+    filtered_devices = pa_idxset_filtered_copy(avail_devices, NULL, exclude_device_filter_func, DEVICE_TYPE_BT_A2DP);
+
+    return filtered_devices;
+}
+
 static void fill_device_info_to_hook_data(pa_stream_manager *m, void *hook_data, notify_command_type_t command, stream_type_t type, void *stream, bool is_new_data) {
     char *device_none = NULL;
     const char *p_idx = NULL;
@@ -2584,7 +2604,6 @@ static void fill_device_info_to_hook_data(pa_stream_manager *m, void *hook_data,
             avail_devices = (type == STREAM_SINK_INPUT) ? si->idx_avail_out_devices : si->idx_avail_in_devices;
             list_len = pa_idxset_size(avail_devices);
             device_none = pa_idxset_get_by_data(avail_devices, "none", NULL);
-
             if (list_len == 0 || device_none) {
                 pa_log_warn("  -- there is no available device, stream_type(%d)", type);
                 break;
@@ -2671,6 +2690,7 @@ static void do_notify(pa_stream_manager *m, notify_command_type_t command, strea
         memset(&hook_call_select_data, 0, sizeof(pa_stream_manager_hook_data_for_select));
         hook_call_select_data.stream = s = user_data;
         if (s) {
+            pa_idxset *filtered_avail_devices = NULL;
             hook_call_select_data.stream_type = type;
             hook_call_select_data.origins_from_new_data = is_new_data;
             if (is_new_data) {
@@ -2679,13 +2699,19 @@ static void do_notify(pa_stream_manager *m, notify_command_type_t command, strea
                 hook_call_select_data.sample_spec = GET_STREAM_NEW_SAMPLE_SPEC(s, type);
                 if (type == STREAM_SINK_INPUT) {
                     hook_call_select_data.occupying_role = m->cur_highest_priority.role_si;
+                    if (IS_ROLE_COMMUNICATION(hook_call_select_data.occupying_role)) {
+                        /* Currently, if bt-sco is used by communication stream, other streams can not go with bt-a2dp.
+                         Here we exclude bt-a2dp device type, therefore this stream can be mixed together by using another device */
+                        filtered_avail_devices = get_avail_devices_except_bt_a2dp(hook_call_select_data.idx_avail_devices);
+                        hook_call_select_data.idx_avail_devices = filtered_avail_devices;
+                    }
                     hook_call_select_data.proper_sink = &(((pa_sink_input_new_data*)s)->sink);
                     /* need to check modifier_gain, because we do not skip a stream that is from module-sound-player */
                     modifier_gain = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(s, type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE);
                     if (((pa_sink_input_new_data*)s)->sink && !modifier_gain) {
                         pa_log_info("  - sink(%s) has been already selected, skip selecting sink",
                                     (((pa_sink_input_new_data*)s)->sink)->name);
-                        break;
+                        goto BREAK_WITH_FREE;
                     }
                 } else if (type == STREAM_SOURCE_OUTPUT) {
                     hook_call_select_data.occupying_role = m->cur_highest_priority.role_so;
@@ -2707,6 +2733,8 @@ static void do_notify(pa_stream_manager *m, notify_command_type_t command, strea
             }
             CONVERT_TO_DEVICE_ROLE(hook_call_select_data.stream_role, hook_call_select_data.device_role);
             pa_hook_fire(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_SELECT_INIT_SINK_OR_SOURCE), &hook_call_select_data);
+BREAK_WITH_FREE:
+            pa_xfree(filtered_avail_devices);
         }
         break;
     }