device-manager: Add role parameter to pa_device_manager_get_device() 87/210687/2
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 24 Jul 2019 01:16:10 +0000 (10:16 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 24 Jul 2019 01:24:46 +0000 (10:24 +0900)
The new parameter is for device role. It can be nullable.

[Version] 11.1.61
[Issue Type] API

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

index 3cfa404..496ef6f 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          11.1.60
+Version:          11.1.61
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index e905437..3c80ee6 100644 (file)
@@ -263,7 +263,7 @@ static void find_device_and_set_running(pa_device_manager *dm, const char *type,
 
     pa_log_info("find device [%s]", type);
 
-    if ((device = pa_device_manager_get_device(dm, type))) {
+    if ((device = pa_device_manager_get_device(dm, type, NULL))) {
         if (pa_tz_device_is_use_internal_codec(device))
             pa_tz_device_set_running_and_notify(device, is_running);
         else
@@ -2581,10 +2581,10 @@ pa_idxset* pa_device_manager_get_device_list(pa_device_manager *dm) {
     return dm->device_list;
 }
 
-pa_tz_device* pa_device_manager_get_device(pa_device_manager *dm, const char *type) {
+pa_tz_device* pa_device_manager_get_device(pa_device_manager *dm, const char *type, const char *role) {
     pa_assert(dm);
 
-    return device_list_get_device(dm, type, NULL, NULL);
+    return device_list_get_device(dm, type, role, NULL);
 }
 
 pa_tz_device* pa_device_manager_get_device_by_id(pa_device_manager *dm, uint32_t id) {
index 79d103a..38c01b0 100644 (file)
@@ -35,9 +35,10 @@ void pa_device_manager_unref(pa_device_manager *dm);
 
 /* Get device list, returned pa_idxset contains 'pa_tz_device' */
 pa_idxset* pa_device_manager_get_device_list(pa_device_manager *dm);
-/* Get device which of type is 'device_type'
- * When there is multi-device for that 'device_type', return first one */
-pa_tz_device* pa_device_manager_get_device(pa_device_manager *dm, const char *device_type);
+/* Get device of 'type' and 'role'.
+ * If there are multiple devices for the 'type' and set the 'role' to NULL,
+ * it will return the first one, so-called, default device. */
+pa_tz_device* pa_device_manager_get_device(pa_device_manager *dm, const char *type, const char *role);
 pa_tz_device* pa_device_manager_get_device_by_id(pa_device_manager *dm, uint32_t id);
 
 /* get device with sink or source */
index 1825221..c81d59a 100644 (file)
@@ -695,7 +695,7 @@ static void handle_set_stream_preferred_device(DBusConnection *conn, DBusMessage
             goto finish;
         }
         /* get a device of default role from previous device type */
-        if (!(device = pa_device_manager_get_device(m->dm, sp->preferred_device.types[direction]))) {
+        if (!(device = pa_device_manager_get_device(m->dm, sp->preferred_device.types[direction], NULL))) {
             pa_log_error("could not get device[%s]", sp->preferred_device.types[direction]);
             ret = RET_MSG_ERROR_DEVICE_NOT_FOUND;
             goto finish;
@@ -772,7 +772,7 @@ static void handle_set_stream_preferred_device(DBusConnection *conn, DBusMessage
         } else {
             /* If the request is for a different device type,
              * check the previous device role and move streams to default role if needed. */
-            if ((prev_device = pa_device_manager_get_device(m->dm, prev_device_type)))
+            if ((prev_device = pa_device_manager_get_device(m->dm, prev_device_type, NULL)))
                 new_device = pa_hashmap_first((direction == STREAM_DIRECTION_OUT) ?
                                         prev_device->playback_devices : prev_device->capture_devices);
             if (new_device) {
index 5537ba9..9cf90e3 100644 (file)
@@ -398,7 +398,7 @@ pa_tz_device* get_media_auto_device(pa_stream_manager *m, dm_device_direction_t
     }
 
     PA_IDXSET_FOREACH(device_type, avail_device_types, idx) {
-        device = pa_device_manager_get_device(m->dm, device_type);
+        device = pa_device_manager_get_device(m->dm, device_type, NULL);
         if (!device)
             continue;
         direction = pa_tz_device_get_direction(device);
@@ -435,7 +435,7 @@ pa_tz_device* get_media_last_device(pa_stream_manager *m, dm_device_direction_t
     }
 
     PA_IDXSET_FOREACH(device_type, avail_device_types, idx) {
-        if ((next_device = pa_device_manager_get_device(m->dm, device_type))) {
+        if ((next_device = pa_device_manager_get_device(m->dm, device_type, NULL))) {
             creation_time = pa_tz_device_get_creation_time(next_device);
             direction = pa_tz_device_get_direction(next_device);
             if ((find_direction & direction) == 0)
@@ -2537,7 +2537,7 @@ static void find_next_device_for_auto_route(pa_stream_manager *m, stream_route_t
                 continue;
             }
             if (ret_next) {
-                if ((*next_device = pa_device_manager_get_device(m->dm, device_type))) {
+                if ((*next_device = pa_device_manager_get_device(m->dm, device_type, NULL))) {
                     pa_log_debug("found next device[%s, %p]", device_type, *next_device);
                     break;
                 }
@@ -2545,7 +2545,7 @@ 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) {
         PA_IDXSET_FOREACH(device_type, devices, idx) {
-            if ((*next_device = pa_device_manager_get_device(m->dm, device_type))) {
+            if ((*next_device = pa_device_manager_get_device(m->dm, device_type, NULL))) {
                 creation_time = pa_tz_device_get_creation_time(*next_device);
                 if (!latest_device || (latest_creation_time <= creation_time)) {
                     latest_device = *next_device;
@@ -2685,7 +2685,7 @@ static bool manage_filter_apply_stream(pa_stream_manager *m, pa_sink_input *si,
         const char *stream_role = pa_proplist_gets(si->proplist, PA_PROP_MEDIA_ROLE);
         const char *cur_device_type = pa_proplist_gets(si->proplist, PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV);
         char *device_type = pa_tz_device_get_type(device);
-        pa_tz_device *cur_device = pa_device_manager_get_device(m->dm, cur_device_type);
+        pa_tz_device *cur_device = pa_device_manager_get_device(m->dm, cur_device_type, NULL);
         pa_sink *sink = pa_tz_device_get_sink(device, NULL);
 
         if (is_connected) {