tizenaudio-policy: Check specified stream role to skip selecting in case of usb device 11/178911/4
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 14 May 2018 03:27:36 +0000 (12:27 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 1 Jun 2018 08:39:38 +0000 (17:39 +0900)
[Version] 11.1.9
[Issue Type] New feature

Change-Id: I89f6aba8c6ab9bdf2ccd5aa6cc55c7cf183274b7
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/pulseaudio-modules-tizen.spec
src/module-tizenaudio-policy.c

index 2a6b12e..cff6824 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          11.1.8
+Version:          11.1.9
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 3f9456d..2289438 100644 (file)
@@ -582,6 +582,38 @@ static bool skip_bt_sco_device(struct userdata *u, const char *stream_role, cons
     return false;
 }
 
+static bool is_supported_stream_role_for_usb(const char *role) {
+    pa_assert(role);
+
+    if (pa_streq(STREAM_ROLE_MEDIA, role))
+        return true;
+
+    pa_log_error("not supported role for usb(%s)", role);
+
+    return false;
+}
+
+static bool skip_usb_device(const char *stream_role, pa_tz_device *device) {
+    char *specified_stream_role;
+
+    pa_assert(stream_role);
+    pa_assert(device);
+
+    if (!pa_streq(pa_tz_device_get_type(device), DEVICE_TYPE_USB_AUDIO))
+        return false;
+
+    if (!(specified_stream_role = pa_tz_device_get_specified_stream_role(device)))
+        return false;
+
+    if (is_supported_stream_role_for_usb(specified_stream_role) &&
+        pa_streq(stream_role, specified_stream_role))
+        return false;
+
+    pa_log_info("skip this usb device, stream role(%s), specified stream role(%s)", stream_role, specified_stream_role);
+
+    return true;
+}
+
 static inline bool is_cached_device_connected(const char* device_type, stream_type_t stream_type) {
     if (cached_connected_devices[convert_device_type_str(device_type)][CONVERT_TO_DEVICE_DIRECTION(stream_type)-1] > 0)
         return true;
@@ -668,6 +700,8 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre
                         pa_log_info("  ** found a matched device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction);
                         if (skip_bt_sco_device(u, data->stream_role, dm_device_type))
                             continue;
+                        if (skip_usb_device(data->stream_role, device))
+                            continue;
 
                         if (data->stream_type == STREAM_SINK_INPUT) {
                             if (data->route_type == STREAM_ROUTE_TYPE_AUTO_ALL && u->module_combine_sink) {
@@ -704,6 +738,8 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre
                     if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
                         if (skip_bt_sco_device(u, data->stream_role, dm_device_type))
                             continue;
+                        if (skip_usb_device(data->stream_role, device))
+                            continue;
 
                         if (!latest_device || (latest_creation_time <= creation_time)) {
                             latest_device = device;
@@ -1089,6 +1125,8 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
                                  dm_device_type, dm_device_direction, dm_device_id);
                     if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
                         pa_log_debug("  ** found a matched device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction);
+                        if (skip_usb_device(data->stream_role, device))
+                            continue;
                         use_internal_codec = pa_tz_device_is_use_internal_codec(device);
                         if (use_internal_codec) {
                             /* if it needs to skip it, keep going to next device for proper UCM setting */
@@ -1217,6 +1255,8 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
                     pa_log_debug("  -- type[%-16s], direction[0x%x], id[%u], creation_time[%llu]",
                                  dm_device_type, dm_device_direction, dm_device_id, creation_time);
                     if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
+                        if (skip_usb_device(data->stream_role, device))
+                            continue;
                         use_internal_codec = pa_tz_device_is_use_internal_codec(device);
                         if (use_internal_codec) {
                             /* if it needs to skip it, keep going to next device for proper UCM setting */