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