chromium: fix launcher for halibut
[AGL/meta-agl-devel.git] / meta-pipewire / recipes-multimedia / pipewire / pipewire / 0002-pipewire-cli-add-support-for-printing-endpoint-info-.patch
1 From e76140c534dde71424eb9abd1dde69cf14152da5 Mon Sep 17 00:00:00 2001
2 From: George Kiagiadakis <george.kiagiadakis@collabora.com>
3 Date: Tue, 28 May 2019 11:46:36 +0300
4 Subject: [PATCH 2/2] pipewire-cli: add support for printing endpoint info &
5  params
6
7 Note that you have to run:
8   load-module libpipewire-module-endpoint
9 before trying to query any endpoints
10 ---
11  src/tools/pipewire-cli.c | 78 +++++++++++++++++++++++++++++++++++++++-
12  1 file changed, 77 insertions(+), 1 deletion(-)
13
14 diff --git a/src/tools/pipewire-cli.c b/src/tools/pipewire-cli.c
15 index 521739f6..9511db82 100644
16 --- a/src/tools/pipewire-cli.c
17 +++ b/src/tools/pipewire-cli.c
18 @@ -38,6 +38,8 @@
19  #include <pipewire/type.h>
20  #include <pipewire/permission.h>
21  
22 +#include <extensions/endpoint.h>
23 +
24  static const char WHITESPACE[] = " \t";
25  
26  struct remote_data;
27 @@ -176,8 +178,12 @@ static void print_params(struct spa_param_info *params, uint32_t n_params, char
28                 return;
29         }
30         for (i = 0; i < n_params; i++) {
31 +               const struct spa_type_info *type_info = spa_type_param;
32 +               if (params[i].id >= PW_ENDPOINT_PARAM_EnumControl)
33 +                       type_info = endpoint_param_type_info;
34 +
35                 fprintf(stdout, "%c\t  %d (%s) %c%c\n", mark, params[i].id,
36 -                       spa_debug_type_find_name(spa_type_param, params[i].id),
37 +                       spa_debug_type_find_name(type_info, params[i].id),
38                         params[i].flags & SPA_PARAM_INFO_READ ? 'r' : '-',
39                         params[i].flags & SPA_PARAM_INFO_WRITE ? 'w' : '-');
40         }
41 @@ -641,6 +647,16 @@ static void info_device(struct proxy_data *pd)
42         info->change_mask = 0;
43  }
44  
45 +static void info_endpoint(struct proxy_data *pd)
46 +{
47 +       struct pw_endpoint_info *info = pd->info;
48 +
49 +       info_global(pd);
50 +       print_properties(info->props, MARK_CHANGE(1), true);
51 +       print_params(info->params, info->n_params, MARK_CHANGE(0), true);
52 +       info->change_mask = 0;
53 +}
54 +
55  static void core_event_info(void *object, const struct pw_core_info *info)
56  {
57         struct proxy_data *pd = object;
58 @@ -708,6 +724,9 @@ static void event_param(void *object, int seq, uint32_t id,
59  
60         if (spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Format))
61                 spa_debug_format(2, NULL, param);
62 +       else if (spa_pod_is_object_type(param, PW_ENDPOINT_OBJECT_ParamControl) ||
63 +                spa_pod_is_object_type(param, PW_ENDPOINT_OBJECT_ParamStream))
64 +               spa_debug_pod(2, endpoint_param_object_type_info, param);
65         else
66                 spa_debug_pod(2, NULL, param);
67  }
68 @@ -842,6 +861,53 @@ static const struct pw_device_proxy_events device_events = {
69         .param = event_param
70  };
71  
72 +static void endpoint_info_free(struct pw_endpoint_info *info)
73 +{
74 +       free(info->params);
75 +       if (info->props)
76 +               pw_properties_free ((struct pw_properties *)info->props);
77 +       free(info);
78 +}
79 +
80 +static void endpoint_event_info(void *object,
81 +                               const struct pw_endpoint_info *update)
82 +{
83 +       struct proxy_data *pd = object;
84 +       struct remote_data *rd = pd->rd;
85 +       struct pw_endpoint_info *info = pd->info;
86 +
87 +       if (!info) {
88 +               info = pd->info = calloc(1, sizeof(*info));
89 +               info->id = update->id;
90 +       }
91 +       if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PARAMS) {
92 +               info->n_params = update->n_params;
93 +               free(info->params);
94 +               info->params = malloc(info->n_params * sizeof(struct spa_param_info));
95 +               memcpy(info->params, update->params,
96 +                       info->n_params * sizeof(struct spa_param_info));
97 +       }
98 +       if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) {
99 +               if (info->props)
100 +                       pw_properties_free ((struct pw_properties *)info->props);
101 +               info->props =
102 +                       (struct spa_dict *) pw_properties_new_dict (update->props);
103 +       }
104 +
105 +       if (pd->global == NULL)
106 +               pd->global = pw_map_lookup(&rd->globals, info->id);
107 +       if (pd->global && pd->global->info_pending) {
108 +               info_endpoint(pd);
109 +               pd->global->info_pending = false;
110 +       }
111 +}
112 +
113 +static const struct pw_endpoint_proxy_events endpoint_events = {
114 +       PW_VERSION_ENDPOINT_PROXY_EVENTS,
115 +       .info = endpoint_event_info,
116 +       .param = event_param
117 +};
118 +
119  static void
120  destroy_proxy (void *data)
121  {
122 @@ -928,6 +994,12 @@ static bool bind_global(struct remote_data *rd, struct global *global, char **er
123                 destroy = (pw_destroy_t) pw_link_info_free;
124                 info_func = info_link;
125                 break;
126 +       case PW_TYPE_INTERFACE_Endpoint:
127 +               events = &endpoint_events;
128 +               client_version = PW_VERSION_ENDPOINT;
129 +               destroy = (pw_destroy_t) endpoint_info_free;
130 +               info_func = info_endpoint;
131 +               break;
132         default:
133                 asprintf(error, "unsupported type %s", spa_debug_type_find_name(pw_type_info(), global->type));
134                 return false;
135 @@ -1201,6 +1273,10 @@ static bool do_enum_params(struct data *data, const char *cmd, char *args, char
136                 pw_device_proxy_enum_params((struct pw_device_proxy*)global->proxy, 0,
137                         param_id, 0, 0, NULL);
138                 break;
139 +       case PW_TYPE_INTERFACE_Endpoint:
140 +               pw_endpoint_proxy_enum_params((struct pw_endpoint_proxy*)global->proxy, 0,
141 +                       param_id, 0, 0, NULL);
142 +               break;
143         default:
144                 asprintf(error, "enum-params not implemented on object %d", atoi(a[0]));
145                 return false;
146 -- 
147 2.20.1
148