stream-manager: Pass parent id when calling callback for selecting sink or source 88/255388/6 submit/tizen/20210329.110345
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 17 Mar 2021 04:22:30 +0000 (13:22 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 26 Mar 2021 07:03:33 +0000 (16:03 +0900)
It is also fixed to pass parent_id as unsigned integer to
STREAM CONNECTION CHANGED callback.

[Version] 13.0.58
[Issue Type] Improvement

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

index f01676ee0302f77d2126c72cfb7db713e01d52f7..0b48635ad1a571fec4fbb4a7d13f5d87fb2f9ee6 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          13.0.57
+Version:          13.0.58
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 6aa27786a82715e59d12a50152391d5440b07a9f..c18391cae792246342e5d2f1d2c4de666a44ca02 100644 (file)
@@ -971,8 +971,8 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre
     pa_assert(data);
     pa_assert(u);
 
-    pa_log_info("[SELECT] data(%p), stream_type(%d), stream_role(%s), device_role(%s), route_type(%d)",
-                data, data->stream_type, data->stream_role, data->device_role, data->route_type);
+    pa_log_info("[SELECT] data(%p), stream_type(%d), stream_role(%s), device_role(%s), route_type(%d), parent_id(%d)",
+                data, data->stream_type, data->stream_role, data->device_role, data->route_type, data->parent_id);
 
     null_sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_NULL, PA_NAMEREG_SINK);
     null_source = (pa_source*)pa_namereg_get(u->core, SOURCE_NAME_NULL, PA_NAMEREG_SOURCE);
@@ -1681,7 +1681,7 @@ static pa_hook_result_t stream_connection_changed_hook_cb(pa_core *c, pa_stream_
     pa_assert(data);
     pa_assert(u);
 
-    pa_log_info("[STREAM][%s] stream(%p, type:%d, role:%s, parent_id:%s)",
+    pa_log_info("[STREAM][%s] stream(%p, type:%d, role:%s, parent_id:%d)",
                 data->is_connected ? "connected" : "disconnected",
                 data->stream, data->stream_type, data->stream_role, data->parent_id);
 
index 8dec61584fbfbc332dfce344d432a69437595db0..15c11915d91bc531899910eed80726fc0963419f 100644 (file)
@@ -1718,6 +1718,8 @@ static ret_msg_t prepare_and_invoke_hook_to_select_device(pa_stream_manager *m,
     pa_stream_manager_hook_data_for_select hook_call_select_data;
     pa_idxset *filtered_avail_devices = NULL;
     void *s = NULL;
+    const char *parent_id;
+    uint32_t parent_id_u;
 
     pa_assert(m);
     pa_assert(user_data);
@@ -1760,6 +1762,13 @@ static ret_msg_t prepare_and_invoke_hook_to_select_device(pa_stream_manager *m,
     if (hook_call_select_data.route_type == STREAM_ROUTE_TYPE_MANUAL)
         CONVERT_TO_DEVICE_ROLE(hook_call_select_data.stream_role, hook_call_select_data.device_role);
 
+    parent_id = is_new_data ? pa_proplist_gets(GET_STREAM_NEW_PROPLIST(s, type), PA_PROP_MEDIA_PARENT_ID) :
+                              pa_proplist_gets(GET_STREAM_PROPLIST(s, type), PA_PROP_MEDIA_PARENT_ID);
+    if (parent_id && pa_atou(parent_id, &parent_id_u) == 0)
+        hook_call_select_data.parent_id = parent_id_u;
+    else
+        hook_call_select_data.parent_id = -1;
+
     if (pa_hook_fire(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_SELECT_INIT_SINK_OR_SOURCE), &hook_call_select_data)) {
         ret = RET_MSG_ERROR_INTERNAL;
     } else {
@@ -1820,8 +1829,6 @@ static ret_msg_t prepare_and_invoke_hook_to_change_route(pa_stream_manager *m, n
                 hook_call_route_data.stream = NULL;
             }
         }
-        if (pa_hook_fire(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_CHANGE_ROUTE), &hook_call_route_data))
-            ret = RET_MSG_ERROR_INTERNAL;
 
     } else {
         memset(&hook_call_route_data, 0, sizeof(pa_stream_manager_hook_data_for_route));
@@ -1842,24 +1849,32 @@ static ret_msg_t prepare_and_invoke_hook_to_change_route(pa_stream_manager *m, n
             hook_call_route_data.stream = NULL;
             hook_call_route_data.stream_type = type;
         }
-        if (pa_hook_fire(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_CHANGE_ROUTE), &hook_call_route_data))
-            ret = RET_MSG_ERROR_INTERNAL;
     }
 
+    if (pa_hook_fire(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_CHANGE_ROUTE), &hook_call_route_data))
+        ret = RET_MSG_ERROR_INTERNAL;
+
     return ret;
 }
 
 static ret_msg_t prepare_and_invoke_hook_to_inform_stream_connection(pa_stream_manager *m, bool is_connected,
                                                         stream_type_t type, void *s) {
     pa_stream_manager_hook_data_for_stream hook_call_stream_data;
+    const char *parent_id;
+    uint32_t parent_id_u;
 
     pa_assert(m);
     pa_assert(s);
 
+    memset(&hook_call_stream_data, 0, sizeof(pa_stream_manager_hook_data_for_stream));
     hook_call_stream_data.stream = s;
     hook_call_stream_data.stream_type = type;
     hook_call_stream_data.stream_role = pa_proplist_gets(GET_STREAM_PROPLIST(s, type), PA_PROP_MEDIA_ROLE);
-    hook_call_stream_data.parent_id = pa_proplist_gets(GET_STREAM_PROPLIST(s, type), PA_PROP_MEDIA_PARENT_ID);
+    parent_id = pa_proplist_gets(GET_STREAM_PROPLIST(s, type), PA_PROP_MEDIA_PARENT_ID);
+    if (parent_id && pa_atou(parent_id, &parent_id_u) == 0)
+        hook_call_stream_data.parent_id = parent_id_u;
+    else
+        hook_call_stream_data.parent_id = -1;
     hook_call_stream_data.is_connected = is_connected;
 
     if (pa_hook_fire(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_STREAM_CONNECTION_CHANGED), &hook_call_stream_data))
index ffb9d345d47d9ef6131e5713f8042e8aa7dbd715..96b8fb20a71a7357fea5c8b95ef16cb451c75964 100644 (file)
@@ -119,6 +119,7 @@ typedef struct _hook_call_data_for_select {
     const char *stream_role;
     const char *device_role;
     const char *occupying_role;
+    int32_t parent_id;
     stream_type_t stream_type;
     stream_route_type_t route_type;
     pa_sink **proper_sink;
@@ -149,7 +150,7 @@ typedef struct _hook_call_data_for_route {
 typedef struct _hook_call_data_for_stream {
     void *stream;
     const char *stream_role;
-    const char *parent_id;
+    int32_t parent_id;
     stream_type_t stream_type;
     bool is_connected;
 } pa_stream_manager_hook_data_for_stream;