tizenaudio-policy: Take into account the preferred device in case of auto-last-connec... 13/210613/4
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 23 Jul 2019 02:39:42 +0000 (11:39 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 24 Jul 2019 08:47:17 +0000 (17:47 +0900)
[Version] 11.1.63
[Issue type] Improvement

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

index 990bfd6..b01e3f7 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          11.1.62
+Version:          11.1.63
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index c869a1f..a7b8a4b 100644 (file)
@@ -738,6 +738,7 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre
             }
         } else if (data->route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED) {
             pa_tz_device *latest_device = NULL;
+            const char *latest_device_type = NULL;
             pa_usec_t creation_time = 0;
             pa_usec_t latest_creation_time = 0;
 
@@ -759,8 +760,16 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre
                             continue;
 
                         if (!latest_device || (latest_creation_time <= creation_time)) {
+                            if (device_type_is_builtin(dm_device_type) && pa_safe_streq(latest_device_type, dm_device_type)) {
+                                pa_log_info("%s %s", latest_device_type, dm_device_type);
+                                if (data->stream_type == STREAM_SINK_INPUT ?
+                                                                (void*)pa_tz_device_get_sink(latest_device, data->device_role) :
+                                                                (void*)pa_tz_device_get_source(latest_device, data->device_role))
+                                    continue;
+                            }
                             latest_device = device;
                             latest_creation_time = creation_time;
+                            latest_device_type = dm_device_type;
                             pa_log_info("  ** updated the last connected device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction);
                         }
                     }
@@ -1091,7 +1100,6 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
     stream_route_type_t route_type;
     const char *device_type = NULL;
     pa_tz_device *device = NULL;
-    pa_tz_device *latest_device = NULL;
     const char *dm_device_type = NULL;
     dm_device_direction_t dm_device_direction = DM_DEVICE_DIRECTION_NONE;
     pa_sink *sink = NULL;
@@ -1270,6 +1278,8 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
                 }
             }
         } else if (data->route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED) {
+            pa_tz_device *latest_device = NULL;
+            const char *latest_device_type = NULL;
             pa_usec_t creation_time = 0;
             pa_usec_t latest_creation_time = 0;
 
@@ -1296,8 +1306,15 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_
                                 continue;
                         }
                         if (!latest_device || (latest_creation_time <= creation_time)) {
+                            if (device_type_is_builtin(dm_device_type) && pa_safe_streq(latest_device_type, dm_device_type)) {
+                                if (data->stream_type == STREAM_SINK_INPUT ?
+                                                                (void*)pa_tz_device_get_sink(latest_device, data->device_role) :
+                                                                (void*)pa_tz_device_get_source(latest_device, data->device_role))
+                                    continue;
+                            }
                             latest_device = device;
                             latest_creation_time = creation_time;
+                            latest_device_type = dm_device_type;
                             pa_log_info("  ** updated the last connected device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction);
                         }
                     }
index 2b534d0..d8fbbb9 100644 (file)
@@ -2600,8 +2600,10 @@ static void find_next_device_for_auto_route(pa_stream_manager *m, stream_route_t
             }
         }
     } else if (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED) {
+        const char *device_role;
         PA_IDXSET_FOREACH(device_type, devices, idx) {
-            if ((*next_device = pa_device_manager_get_device(m->dm, device_type, NULL))) {
+            device_role = device_type_is_builtin(device_type) ? preferred_device_role : NULL;
+            if ((*next_device = pa_device_manager_get_device(m->dm, device_type, device_role))) {
                 creation_time = pa_tz_device_get_creation_time(*next_device);
                 if (!latest_device || (latest_creation_time <= creation_time)) {
                     latest_device = *next_device;