2017-05-23 19:15:33 +02:00
|
|
|
/* PipeWire
|
2017-03-03 19:06:54 +01:00
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* Copyright © 2018 Wim Taymans
|
2017-03-03 19:06:54 +01:00
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2017-03-03 19:06:54 +01:00
|
|
|
*
|
2018-11-05 17:48:52 +01:00
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2017-03-03 19:06:54 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
2017-11-10 13:36:14 +01:00
|
|
|
#include <spa/pod/parser.h>
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2019-01-14 12:58:23 +01:00
|
|
|
#include <pipewire/pipewire.h>
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2019-01-14 12:58:23 +01:00
|
|
|
#include <extensions/protocol-native.h>
|
|
|
|
|
#include <extensions/client-node.h>
|
2017-07-11 12:24:03 +02:00
|
|
|
|
2019-07-11 12:52:55 +02:00
|
|
|
static inline void push_item(struct spa_pod_builder *b, const struct spa_dict_item *item)
|
|
|
|
|
{
|
|
|
|
|
const char *str;
|
|
|
|
|
spa_pod_builder_string(b, item->key);
|
|
|
|
|
str = item->value;
|
|
|
|
|
if (strstr(str, "pointer:") == str)
|
|
|
|
|
str = "";
|
|
|
|
|
spa_pod_builder_string(b, str);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-18 13:22:46 +01:00
|
|
|
static void push_dict(struct spa_pod_builder *b, const struct spa_dict *dict)
|
|
|
|
|
{
|
|
|
|
|
uint32_t i, n_items;
|
|
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
|
|
|
|
|
n_items = dict ? dict->n_items : 0;
|
|
|
|
|
|
|
|
|
|
spa_pod_builder_push_struct(b, &f);
|
|
|
|
|
spa_pod_builder_int(b, n_items);
|
2019-07-11 12:52:55 +02:00
|
|
|
for (i = 0; i < n_items; i++)
|
|
|
|
|
push_item(b, &dict->items[i]);
|
2019-02-18 13:22:46 +01:00
|
|
|
spa_pod_builder_pop(b, &f);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-11 12:52:55 +02:00
|
|
|
static inline int parse_item(struct spa_pod_parser *prs, struct spa_dict_item *item)
|
|
|
|
|
{
|
|
|
|
|
int res;
|
|
|
|
|
if ((res = spa_pod_parser_get(prs,
|
|
|
|
|
SPA_POD_String(&item->key),
|
|
|
|
|
SPA_POD_String(&item->value),
|
|
|
|
|
NULL)) < 0)
|
|
|
|
|
return res;
|
|
|
|
|
if (strstr(item->value, "pointer:") == item->value)
|
|
|
|
|
item->value = "";
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int parse_dict(struct spa_pod_parser *prs, struct spa_dict *dict)
|
|
|
|
|
{
|
|
|
|
|
uint32_t i;
|
|
|
|
|
int res;
|
|
|
|
|
for (i = 0; i < dict->n_items; i++) {
|
|
|
|
|
if ((res = parse_item(prs, (struct spa_dict_item *) &dict->items[i])) < 0)
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-20 16:11:23 +02:00
|
|
|
static int client_node_marshal_add_listener(void *object,
|
|
|
|
|
struct spa_hook *listener,
|
|
|
|
|
const struct pw_client_node_proxy_events *events,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
2019-05-29 10:39:24 +02:00
|
|
|
pw_proxy_add_object_listener(proxy, listener, events, data);
|
2019-05-20 16:11:23 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct pw_node_proxy *
|
|
|
|
|
client_node_marshal_get_node(void *object, uint32_t version, size_t user_data_size)
|
2019-03-15 20:29:34 +01:00
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_builder *b;
|
2019-05-20 16:11:23 +02:00
|
|
|
struct pw_proxy *res;
|
|
|
|
|
uint32_t new_id;
|
|
|
|
|
|
|
|
|
|
res = pw_proxy_new(object, PW_TYPE_INTERFACE_Node, user_data_size);
|
|
|
|
|
if (res == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
new_id = pw_proxy_get_id(res);
|
2019-03-15 20:29:34 +01:00
|
|
|
|
|
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_GET_NODE, NULL);
|
|
|
|
|
|
|
|
|
|
spa_pod_builder_add_struct(b,
|
|
|
|
|
SPA_POD_Int(version),
|
|
|
|
|
SPA_POD_Int(new_id));
|
|
|
|
|
|
2019-05-20 16:11:23 +02:00
|
|
|
pw_protocol_native_end_proxy(proxy, b);
|
|
|
|
|
|
|
|
|
|
return (struct pw_node_proxy *) res;
|
2019-03-15 20:29:34 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int
|
2017-05-26 08:05:01 +02:00
|
|
|
client_node_marshal_update(void *object,
|
|
|
|
|
uint32_t change_mask,
|
2017-11-07 17:39:31 +01:00
|
|
|
uint32_t n_params,
|
2018-06-07 10:23:41 +02:00
|
|
|
const struct spa_pod **params,
|
2019-03-04 12:30:45 +01:00
|
|
|
const struct spa_node_info *info)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2019-03-04 12:30:45 +01:00
|
|
|
struct spa_pod_frame f[2];
|
|
|
|
|
uint32_t i, n_items;
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_UPDATE, NULL);
|
2017-03-14 20:18:31 +01:00
|
|
|
|
2019-03-04 12:30:45 +01:00
|
|
|
spa_pod_builder_push_struct(b, &f[0]);
|
2017-11-07 17:39:31 +01:00
|
|
|
spa_pod_builder_add(b,
|
2019-02-18 13:22:46 +01:00
|
|
|
SPA_POD_Int(change_mask),
|
|
|
|
|
SPA_POD_Int(n_params), NULL);
|
2017-11-07 17:39:31 +01:00
|
|
|
|
|
|
|
|
for (i = 0; i < n_params; i++)
|
2019-01-16 11:05:12 +01:00
|
|
|
spa_pod_builder_add(b, SPA_POD_Pod(params[i]), NULL);
|
2017-11-07 17:39:31 +01:00
|
|
|
|
2019-03-04 12:30:45 +01:00
|
|
|
if (info) {
|
|
|
|
|
uint64_t change_mask = info->change_mask;
|
|
|
|
|
|
|
|
|
|
n_items = info->props ? info->props->n_items : 0;
|
|
|
|
|
|
|
|
|
|
change_mask &= SPA_NODE_CHANGE_MASK_FLAGS |
|
|
|
|
|
SPA_NODE_CHANGE_MASK_PROPS |
|
|
|
|
|
SPA_NODE_CHANGE_MASK_PARAMS;
|
|
|
|
|
|
|
|
|
|
spa_pod_builder_push_struct(b, &f[1]);
|
|
|
|
|
spa_pod_builder_add(b,
|
|
|
|
|
SPA_POD_Int(info->max_input_ports),
|
|
|
|
|
SPA_POD_Int(info->max_output_ports),
|
|
|
|
|
SPA_POD_Long(change_mask),
|
|
|
|
|
SPA_POD_Long(info->flags),
|
|
|
|
|
SPA_POD_Int(n_items), NULL);
|
2019-07-11 12:52:55 +02:00
|
|
|
for (i = 0; i < n_items; i++)
|
|
|
|
|
push_item(b, &info->props->items[i]);
|
2019-03-04 12:30:45 +01:00
|
|
|
spa_pod_builder_add(b,
|
|
|
|
|
SPA_POD_Int(info->n_params), NULL);
|
|
|
|
|
for (i = 0; i < info->n_params; i++) {
|
|
|
|
|
spa_pod_builder_add(b,
|
|
|
|
|
SPA_POD_Id(info->params[i].id),
|
|
|
|
|
SPA_POD_Int(info->params[i].flags), NULL);
|
|
|
|
|
}
|
|
|
|
|
spa_pod_builder_pop(b, &f[1]);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
spa_pod_builder_add(b,
|
|
|
|
|
SPA_POD_Pod(NULL), NULL);
|
|
|
|
|
}
|
|
|
|
|
spa_pod_builder_pop(b, &f[0]);
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_proxy(proxy, b);
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int
|
2017-05-26 08:05:01 +02:00
|
|
|
client_node_marshal_port_update(void *object,
|
|
|
|
|
enum spa_direction direction,
|
|
|
|
|
uint32_t port_id,
|
|
|
|
|
uint32_t change_mask,
|
|
|
|
|
uint32_t n_params,
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod **params,
|
2017-11-07 17:39:31 +01:00
|
|
|
const struct spa_port_info *info)
|
2017-03-06 15:48:04 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2019-01-22 17:38:23 +01:00
|
|
|
struct spa_pod_frame f[2];
|
2019-01-07 15:52:42 +01:00
|
|
|
uint32_t i, n_items;
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_PORT_UPDATE, NULL);
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2019-01-22 17:38:23 +01:00
|
|
|
spa_pod_builder_push_struct(b, &f[0]);
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(direction),
|
|
|
|
|
SPA_POD_Int(port_id),
|
|
|
|
|
SPA_POD_Int(change_mask),
|
|
|
|
|
SPA_POD_Int(n_params), NULL);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
for (i = 0; i < n_params; i++)
|
2019-01-16 11:05:12 +01:00
|
|
|
spa_pod_builder_add(b,
|
|
|
|
|
SPA_POD_Pod(params[i]), NULL);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
if (info) {
|
2019-02-27 16:43:01 +01:00
|
|
|
uint64_t change_mask = info->change_mask;
|
|
|
|
|
|
2018-02-09 18:10:51 +01:00
|
|
|
n_items = info->props ? info->props->n_items : 0;
|
|
|
|
|
|
2019-02-27 16:43:01 +01:00
|
|
|
change_mask &= SPA_PORT_CHANGE_MASK_FLAGS |
|
|
|
|
|
SPA_PORT_CHANGE_MASK_RATE |
|
|
|
|
|
SPA_PORT_CHANGE_MASK_PROPS |
|
|
|
|
|
SPA_PORT_CHANGE_MASK_PARAMS;
|
|
|
|
|
|
2019-01-22 17:38:23 +01:00
|
|
|
spa_pod_builder_push_struct(b, &f[1]);
|
2018-02-09 18:10:51 +01:00
|
|
|
spa_pod_builder_add(b,
|
2019-02-27 16:43:01 +01:00
|
|
|
SPA_POD_Long(change_mask),
|
2019-03-04 12:30:45 +01:00
|
|
|
SPA_POD_Long(info->flags),
|
|
|
|
|
SPA_POD_Int(info->rate.num),
|
|
|
|
|
SPA_POD_Int(info->rate.denom),
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(n_items), NULL);
|
2019-07-11 12:52:55 +02:00
|
|
|
for (i = 0; i < n_items; i++)
|
|
|
|
|
push_item(b, &info->props->items[i]);
|
2019-02-27 16:43:01 +01:00
|
|
|
spa_pod_builder_add(b,
|
|
|
|
|
SPA_POD_Int(info->n_params), NULL);
|
|
|
|
|
for (i = 0; i < info->n_params; i++) {
|
|
|
|
|
spa_pod_builder_add(b,
|
|
|
|
|
SPA_POD_Id(info->params[i].id),
|
|
|
|
|
SPA_POD_Int(info->params[i].flags), NULL);
|
|
|
|
|
}
|
2019-01-22 17:38:23 +01:00
|
|
|
spa_pod_builder_pop(b, &f[1]);
|
2019-02-27 16:43:01 +01:00
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
} else {
|
2019-01-16 11:05:12 +01:00
|
|
|
spa_pod_builder_add(b,
|
|
|
|
|
SPA_POD_Pod(NULL), NULL);
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2019-01-22 17:38:23 +01:00
|
|
|
spa_pod_builder_pop(b, &f[0]);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_proxy(proxy, b);
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int client_node_marshal_set_active(void *object, bool active)
|
2017-10-13 16:18:42 +02:00
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_builder *b;
|
|
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_SET_ACTIVE, NULL);
|
2017-10-13 16:18:42 +02:00
|
|
|
|
2019-01-16 11:05:12 +01:00
|
|
|
spa_pod_builder_add_struct(b,
|
|
|
|
|
SPA_POD_Bool(active));
|
2017-10-13 16:18:42 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_proxy(proxy, b);
|
2017-10-13 16:18:42 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-28 13:51:12 +02:00
|
|
|
static int client_node_marshal_event_method(void *object, const struct spa_event *event)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_EVENT, NULL);
|
2017-03-14 20:18:31 +01:00
|
|
|
|
2019-01-16 11:05:12 +01:00
|
|
|
spa_pod_builder_add_struct(b,
|
|
|
|
|
SPA_POD_Pod(event));
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_proxy(proxy, b);
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_transport(void *object, const struct pw_protocol_native_message *msg)
|
2017-05-30 19:46:51 +02:00
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2019-07-25 12:10:05 +02:00
|
|
|
uint32_t node_id, ridx, widx, mem_id, offset, sz;
|
2017-11-07 17:39:31 +01:00
|
|
|
int readfd, writefd;
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_Int(&node_id),
|
|
|
|
|
SPA_POD_Int(&ridx),
|
2019-07-25 12:10:05 +02:00
|
|
|
SPA_POD_Int(&widx),
|
|
|
|
|
SPA_POD_Int(&mem_id),
|
|
|
|
|
SPA_POD_Int(&offset),
|
|
|
|
|
SPA_POD_Int(&sz)) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-11-07 17:39:31 +01:00
|
|
|
|
|
|
|
|
readfd = pw_protocol_native_get_proxy_fd(proxy, ridx);
|
|
|
|
|
writefd = pw_protocol_native_get_proxy_fd(proxy, widx);
|
|
|
|
|
|
2019-06-20 17:31:29 +02:00
|
|
|
if (readfd < 0 || writefd < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-11-07 17:39:31 +01:00
|
|
|
|
2018-08-01 21:41:25 +02:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, transport, 0, node_id,
|
2019-07-25 12:10:05 +02:00
|
|
|
readfd, writefd, mem_id,
|
|
|
|
|
offset, sz);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-11-07 17:39:31 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_set_param(void *object, const struct pw_protocol_native_message *msg)
|
2017-11-07 17:39:31 +01:00
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_parser prs;
|
2019-02-18 12:31:36 +01:00
|
|
|
uint32_t id, flags;
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod *param = NULL;
|
2017-05-30 19:46:51 +02:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_Id(&id),
|
|
|
|
|
SPA_POD_Int(&flags),
|
|
|
|
|
SPA_POD_PodObject(¶m)) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-30 19:46:51 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_param, 0, id, flags, param);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-05-30 19:46:51 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_event_event(void *object, const struct pw_protocol_native_message *msg)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-05-26 08:05:01 +02:00
|
|
|
const struct spa_event *event;
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_PodObject(&event)) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2018-08-01 21:41:25 +02:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, event, 0, event);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_command(void *object, const struct pw_protocol_native_message *msg)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-11-07 17:39:31 +01:00
|
|
|
const struct spa_command *command;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_PodObject(&command)) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, command, 0, command);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_add_port(void *object, const struct pw_protocol_native_message *msg)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2019-02-18 13:22:46 +01:00
|
|
|
struct spa_pod_frame f[2];
|
2019-02-18 12:31:36 +01:00
|
|
|
int32_t direction, port_id;
|
2019-02-18 13:22:46 +01:00
|
|
|
struct spa_dict props;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-02-18 13:22:46 +01:00
|
|
|
if (spa_pod_parser_push_struct(&prs, &f[0]) < 0)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(&direction),
|
|
|
|
|
SPA_POD_Int(&port_id)) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-02-18 13:22:46 +01:00
|
|
|
if (spa_pod_parser_push_struct(&prs, &f[1]) < 0)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
SPA_POD_Int(&props.n_items), NULL) < 0)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
2019-07-11 12:52:55 +02:00
|
|
|
if (parse_dict(&prs, &props) < 0)
|
|
|
|
|
return -EINVAL;
|
2019-02-18 13:22:46 +01:00
|
|
|
|
|
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_port, 0, direction, port_id,
|
|
|
|
|
props.n_items ? &props : NULL);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_remove_port(void *object, const struct pw_protocol_native_message *msg)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2019-02-18 12:31:36 +01:00
|
|
|
int32_t direction, port_id;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_Int(&direction),
|
|
|
|
|
SPA_POD_Int(&port_id)) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, remove_port, 0, direction, port_id);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_port_set_param(void *object, const struct pw_protocol_native_message *msg)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2019-02-18 12:31:36 +01:00
|
|
|
uint32_t direction, port_id, id, flags;
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod *param = NULL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_Int(&direction),
|
|
|
|
|
SPA_POD_Int(&port_id),
|
|
|
|
|
SPA_POD_Id(&id),
|
|
|
|
|
SPA_POD_Int(&flags),
|
|
|
|
|
SPA_POD_PodObject(¶m)) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2018-08-01 21:41:25 +02:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_param, 0,
|
2019-02-18 12:31:36 +01:00
|
|
|
direction, port_id, id, flags, param);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_port_use_buffers(void *object, const struct pw_protocol_native_message *msg)
|
2017-05-26 08:05:01 +02:00
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2019-01-22 17:38:23 +01:00
|
|
|
struct spa_pod_frame f;
|
2019-02-18 12:31:36 +01:00
|
|
|
uint32_t direction, port_id, mix_id, n_buffers, data_id;
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_client_node_buffer *buffers;
|
2019-01-07 15:52:42 +01:00
|
|
|
uint32_t i, j;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-22 17:38:23 +01:00
|
|
|
if (spa_pod_parser_push_struct(&prs, &f) < 0 ||
|
|
|
|
|
spa_pod_parser_get(&prs,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(&direction),
|
|
|
|
|
SPA_POD_Int(&port_id),
|
|
|
|
|
SPA_POD_Int(&mix_id),
|
|
|
|
|
SPA_POD_Int(&n_buffers), NULL) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
buffers = alloca(sizeof(struct pw_client_node_buffer) * n_buffers);
|
|
|
|
|
for (i = 0; i < n_buffers; i++) {
|
|
|
|
|
struct spa_buffer *buf = buffers[i].buffer = alloca(sizeof(struct spa_buffer));
|
|
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
if (spa_pod_parser_get(&prs,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(&buffers[i].mem_id),
|
|
|
|
|
SPA_POD_Int(&buffers[i].offset),
|
|
|
|
|
SPA_POD_Int(&buffers[i].size),
|
|
|
|
|
SPA_POD_Int(&buf->n_metas), NULL) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
buf->metas = alloca(sizeof(struct spa_meta) * buf->n_metas);
|
|
|
|
|
for (j = 0; j < buf->n_metas; j++) {
|
|
|
|
|
struct spa_meta *m = &buf->metas[j];
|
|
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
if (spa_pod_parser_get(&prs,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Id(&m->type),
|
|
|
|
|
SPA_POD_Int(&m->size), NULL) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
SPA_POD_Int(&buf->n_datas), NULL) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
buf->datas = alloca(sizeof(struct spa_data) * buf->n_datas);
|
|
|
|
|
for (j = 0; j < buf->n_datas; j++) {
|
|
|
|
|
struct spa_data *d = &buf->datas[j];
|
|
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
if (spa_pod_parser_get(&prs,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Id(&d->type),
|
|
|
|
|
SPA_POD_Int(&data_id),
|
|
|
|
|
SPA_POD_Int(&d->flags),
|
|
|
|
|
SPA_POD_Int(&d->mapoffset),
|
|
|
|
|
SPA_POD_Int(&d->maxsize), NULL) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
d->data = SPA_UINT32_TO_PTR(data_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-18 12:31:36 +01:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_use_buffers, 0,
|
2017-07-13 15:21:52 +02:00
|
|
|
direction,
|
|
|
|
|
port_id,
|
2018-03-01 17:39:17 +01:00
|
|
|
mix_id,
|
2017-07-13 15:21:52 +02:00
|
|
|
n_buffers, buffers);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_port_set_io(void *object, const struct pw_protocol_native_message *msg)
|
2017-11-30 16:36:29 +01:00
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_parser prs;
|
2019-02-18 12:31:36 +01:00
|
|
|
uint32_t direction, port_id, mix_id, id, memid, off, sz;
|
2017-11-30 16:36:29 +01:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_Int(&direction),
|
|
|
|
|
SPA_POD_Int(&port_id),
|
|
|
|
|
SPA_POD_Int(&mix_id),
|
|
|
|
|
SPA_POD_Id(&id),
|
|
|
|
|
SPA_POD_Int(&memid),
|
|
|
|
|
SPA_POD_Int(&off),
|
|
|
|
|
SPA_POD_Int(&sz)) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-11-30 16:36:29 +01:00
|
|
|
|
2018-08-01 21:41:25 +02:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_io, 0,
|
2018-03-01 17:39:17 +01:00
|
|
|
direction, port_id, mix_id,
|
2017-11-30 16:36:29 +01:00
|
|
|
id, memid,
|
|
|
|
|
off, sz);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-11-30 16:36:29 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_set_activation(void *object, const struct pw_protocol_native_message *msg)
|
2019-02-12 17:42:33 +01:00
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_parser prs;
|
|
|
|
|
uint32_t node_id, sigidx, memid, off, sz;
|
|
|
|
|
int signalfd;
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-02-12 17:42:33 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_Int(&node_id),
|
|
|
|
|
SPA_POD_Int(&sigidx),
|
|
|
|
|
SPA_POD_Int(&memid),
|
|
|
|
|
SPA_POD_Int(&off),
|
|
|
|
|
SPA_POD_Int(&sz)) < 0)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
signalfd = pw_protocol_native_get_proxy_fd(proxy, sigidx);
|
2019-06-20 17:31:29 +02:00
|
|
|
if (signalfd < 0)
|
2019-02-12 17:42:33 +01:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_activation, 0,
|
|
|
|
|
node_id,
|
|
|
|
|
signalfd,
|
|
|
|
|
memid,
|
|
|
|
|
off, sz);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_set_io(void *object, const struct pw_protocol_native_message *msg)
|
2018-05-11 10:13:37 +02:00
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_parser prs;
|
2018-07-12 15:33:07 +02:00
|
|
|
uint32_t id, memid, off, sz;
|
2018-05-11 10:13:37 +02:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_Id(&id),
|
|
|
|
|
SPA_POD_Int(&memid),
|
|
|
|
|
SPA_POD_Int(&off),
|
|
|
|
|
SPA_POD_Int(&sz)) < 0)
|
2018-05-11 10:13:37 +02:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
2018-08-01 21:41:25 +02:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_io, 0,
|
2018-07-12 15:33:07 +02:00
|
|
|
id, memid, off, sz);
|
2018-05-11 10:13:37 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-25 12:10:05 +02:00
|
|
|
static int client_node_marshal_transport(void *object, uint32_t node_id, int readfd, int writefd,
|
|
|
|
|
uint32_t mem_id, uint32_t offset, uint32_t size)
|
2017-05-26 08:05:01 +02:00
|
|
|
{
|
2019-03-19 16:15:20 +01:00
|
|
|
struct pw_protocol_native_message *msg;
|
2017-11-07 17:39:31 +01:00
|
|
|
struct pw_resource *resource = object;
|
|
|
|
|
struct spa_pod_builder *b;
|
2017-08-07 10:25:02 +02:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_TRANSPORT, &msg);
|
2017-06-09 17:24:18 +02:00
|
|
|
|
2018-09-05 16:41:07 +02:00
|
|
|
spa_pod_builder_add_struct(b,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(node_id),
|
|
|
|
|
SPA_POD_Int(pw_protocol_native_add_resource_fd(resource, readfd)),
|
2019-07-25 12:10:05 +02:00
|
|
|
SPA_POD_Int(pw_protocol_native_add_resource_fd(resource, writefd)),
|
|
|
|
|
SPA_POD_Int(mem_id),
|
|
|
|
|
SPA_POD_Int(offset),
|
|
|
|
|
SPA_POD_Int(size));
|
2017-08-07 10:25:02 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_resource(resource, b);
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int
|
|
|
|
|
client_node_marshal_set_param(void *object, uint32_t id, uint32_t flags,
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod *param)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-06-21 12:11:54 +02:00
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_PARAM, NULL);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2018-09-05 16:41:07 +02:00
|
|
|
spa_pod_builder_add_struct(b,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Id(id),
|
|
|
|
|
SPA_POD_Int(flags),
|
|
|
|
|
SPA_POD_Pod(param));
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int client_node_marshal_event_event(void *object, const struct spa_event *event)
|
2017-06-21 12:11:54 +02:00
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_EVENT, NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-01-16 11:05:12 +01:00
|
|
|
spa_pod_builder_add_struct(b,
|
|
|
|
|
SPA_POD_Pod(event));
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int
|
|
|
|
|
client_node_marshal_command(void *object, const struct spa_command *command)
|
2017-06-21 12:11:54 +02:00
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_COMMAND, NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-01-16 11:05:12 +01:00
|
|
|
spa_pod_builder_add_struct(b,
|
|
|
|
|
SPA_POD_Pod(command));
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int
|
2017-11-07 17:39:31 +01:00
|
|
|
client_node_marshal_add_port(void *object,
|
2019-02-18 13:22:46 +01:00
|
|
|
enum spa_direction direction, uint32_t port_id,
|
|
|
|
|
const struct spa_dict *props)
|
2017-06-21 12:11:54 +02:00
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2019-02-18 13:22:46 +01:00
|
|
|
struct spa_pod_frame f;
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_PORT, NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-18 13:22:46 +01:00
|
|
|
spa_pod_builder_push_struct(b, &f);
|
|
|
|
|
spa_pod_builder_add(b,
|
|
|
|
|
SPA_POD_Int(direction),
|
|
|
|
|
SPA_POD_Int(port_id));
|
|
|
|
|
push_dict(b, props);
|
|
|
|
|
spa_pod_builder_pop(b, &f);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int
|
2017-11-07 17:39:31 +01:00
|
|
|
client_node_marshal_remove_port(void *object,
|
2019-02-18 12:31:36 +01:00
|
|
|
enum spa_direction direction, uint32_t port_id)
|
2017-06-21 12:11:54 +02:00
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_REMOVE_PORT, NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2018-09-05 16:41:07 +02:00
|
|
|
spa_pod_builder_add_struct(b,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(direction),
|
|
|
|
|
SPA_POD_Int(port_id));
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int
|
2017-11-07 17:39:31 +01:00
|
|
|
client_node_marshal_port_set_param(void *object,
|
|
|
|
|
enum spa_direction direction,
|
|
|
|
|
uint32_t port_id,
|
|
|
|
|
uint32_t id,
|
|
|
|
|
uint32_t flags,
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod *param)
|
2017-06-21 12:11:54 +02:00
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_PARAM, NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2018-09-05 16:41:07 +02:00
|
|
|
spa_pod_builder_add_struct(b,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(direction),
|
|
|
|
|
SPA_POD_Int(port_id),
|
|
|
|
|
SPA_POD_Id(id),
|
|
|
|
|
SPA_POD_Int(flags),
|
|
|
|
|
SPA_POD_Pod(param));
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int
|
2017-11-07 17:39:31 +01:00
|
|
|
client_node_marshal_port_use_buffers(void *object,
|
|
|
|
|
enum spa_direction direction,
|
|
|
|
|
uint32_t port_id,
|
2018-03-01 17:39:17 +01:00
|
|
|
uint32_t mix_id,
|
2017-11-07 17:39:31 +01:00
|
|
|
uint32_t n_buffers, struct pw_client_node_buffer *buffers)
|
2017-06-21 12:11:54 +02:00
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2019-01-22 17:38:23 +01:00
|
|
|
struct spa_pod_frame f;
|
2017-06-21 12:11:54 +02:00
|
|
|
uint32_t i, j;
|
|
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_USE_BUFFERS, NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-01-22 17:38:23 +01:00
|
|
|
spa_pod_builder_push_struct(b, &f);
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(direction),
|
|
|
|
|
SPA_POD_Int(port_id),
|
|
|
|
|
SPA_POD_Int(mix_id),
|
|
|
|
|
SPA_POD_Int(n_buffers), NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
|
|
|
|
for (i = 0; i < n_buffers; i++) {
|
|
|
|
|
struct spa_buffer *buf = buffers[i].buffer;
|
|
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(buffers[i].mem_id),
|
|
|
|
|
SPA_POD_Int(buffers[i].offset),
|
|
|
|
|
SPA_POD_Int(buffers[i].size),
|
|
|
|
|
SPA_POD_Int(buf->n_metas), NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
|
|
|
|
for (j = 0; j < buf->n_metas; j++) {
|
|
|
|
|
struct spa_meta *m = &buf->metas[j];
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Id(m->type),
|
|
|
|
|
SPA_POD_Int(m->size), NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
2019-01-16 11:05:12 +01:00
|
|
|
spa_pod_builder_add(b,
|
|
|
|
|
SPA_POD_Int(buf->n_datas), NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
for (j = 0; j < buf->n_datas; j++) {
|
|
|
|
|
struct spa_data *d = &buf->datas[j];
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Id(d->type),
|
|
|
|
|
SPA_POD_Int(SPA_PTR_TO_UINT32(d->data)),
|
|
|
|
|
SPA_POD_Int(d->flags),
|
|
|
|
|
SPA_POD_Int(d->mapoffset),
|
|
|
|
|
SPA_POD_Int(d->maxsize), NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2019-01-22 17:38:23 +01:00
|
|
|
spa_pod_builder_pop(b, &f);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_resource(resource, b);
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int
|
2017-11-30 16:36:29 +01:00
|
|
|
client_node_marshal_port_set_io(void *object,
|
|
|
|
|
uint32_t direction,
|
|
|
|
|
uint32_t port_id,
|
2018-03-01 17:39:17 +01:00
|
|
|
uint32_t mix_id,
|
2017-11-30 16:36:29 +01:00
|
|
|
uint32_t id,
|
|
|
|
|
uint32_t memid,
|
|
|
|
|
uint32_t offset,
|
|
|
|
|
uint32_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
|
|
|
|
struct spa_pod_builder *b;
|
|
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_IO, NULL);
|
2017-11-30 16:36:29 +01:00
|
|
|
|
2018-09-05 16:41:07 +02:00
|
|
|
spa_pod_builder_add_struct(b,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(direction),
|
|
|
|
|
SPA_POD_Int(port_id),
|
|
|
|
|
SPA_POD_Int(mix_id),
|
|
|
|
|
SPA_POD_Id(id),
|
|
|
|
|
SPA_POD_Int(memid),
|
|
|
|
|
SPA_POD_Int(offset),
|
|
|
|
|
SPA_POD_Int(size));
|
2017-11-30 16:36:29 +01:00
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_resource(resource, b);
|
2017-11-30 16:36:29 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int
|
2019-02-12 17:42:33 +01:00
|
|
|
client_node_marshal_set_activation(void *object,
|
|
|
|
|
uint32_t node_id,
|
|
|
|
|
int signalfd,
|
|
|
|
|
uint32_t memid,
|
|
|
|
|
uint32_t offset,
|
|
|
|
|
uint32_t size)
|
|
|
|
|
{
|
2019-03-19 16:15:20 +01:00
|
|
|
struct pw_protocol_native_message *msg;
|
2019-02-12 17:42:33 +01:00
|
|
|
struct pw_resource *resource = object;
|
|
|
|
|
struct spa_pod_builder *b;
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_ACTIVATION, &msg);
|
2019-02-12 17:42:33 +01:00
|
|
|
|
|
|
|
|
spa_pod_builder_add_struct(b,
|
|
|
|
|
SPA_POD_Int(node_id),
|
|
|
|
|
SPA_POD_Int(pw_protocol_native_add_resource_fd(resource, signalfd)),
|
|
|
|
|
SPA_POD_Int(memid),
|
|
|
|
|
SPA_POD_Int(offset),
|
|
|
|
|
SPA_POD_Int(size));
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_resource(resource, b);
|
2019-02-12 17:42:33 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-18 12:31:36 +01:00
|
|
|
static int
|
2018-07-12 15:33:07 +02:00
|
|
|
client_node_marshal_set_io(void *object,
|
|
|
|
|
uint32_t id,
|
|
|
|
|
uint32_t memid,
|
|
|
|
|
uint32_t offset,
|
|
|
|
|
uint32_t size)
|
2018-05-11 10:13:37 +02:00
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
|
|
|
|
struct spa_pod_builder *b;
|
|
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_IO, NULL);
|
2018-09-05 16:41:07 +02:00
|
|
|
spa_pod_builder_add_struct(b,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Id(id),
|
|
|
|
|
SPA_POD_Int(memid),
|
|
|
|
|
SPA_POD_Int(offset),
|
|
|
|
|
SPA_POD_Int(size));
|
2019-02-18 12:31:36 +01:00
|
|
|
return pw_protocol_native_end_resource(resource, b);
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_get_node(void *object, const struct pw_protocol_native_message *msg)
|
2019-03-15 20:29:34 +01:00
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
|
|
|
|
struct spa_pod_parser prs;
|
|
|
|
|
int32_t version, new_id;
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-03-15 20:29:34 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_Int(&version),
|
|
|
|
|
SPA_POD_Int(&new_id)) < 0)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
2019-05-29 10:39:24 +02:00
|
|
|
return pw_resource_notify(resource, struct pw_client_node_proxy_methods, get_node, 0,
|
2019-03-15 20:29:34 +01:00
|
|
|
version, new_id);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_update(void *object, const struct pw_protocol_native_message *msg)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-06-21 12:11:54 +02:00
|
|
|
struct pw_resource *resource = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2019-02-18 13:22:46 +01:00
|
|
|
struct spa_pod_frame f[2];
|
2019-03-04 12:30:45 +01:00
|
|
|
uint32_t change_mask, n_params;
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod **params;
|
2019-03-04 12:30:45 +01:00
|
|
|
struct spa_node_info info = SPA_NODE_INFO_INIT(), *infop = NULL;
|
|
|
|
|
struct spa_pod *ipod;
|
2018-06-07 10:23:41 +02:00
|
|
|
struct spa_dict props;
|
2019-01-07 15:52:42 +01:00
|
|
|
uint32_t i;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-02-18 13:22:46 +01:00
|
|
|
if (spa_pod_parser_push_struct(&prs, &f[0]) < 0 ||
|
2019-01-22 17:38:23 +01:00
|
|
|
spa_pod_parser_get(&prs,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(&change_mask),
|
|
|
|
|
SPA_POD_Int(&n_params), NULL) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-11-13 17:57:38 +01:00
|
|
|
params = alloca(n_params * sizeof(struct spa_pod *));
|
2017-11-07 17:39:31 +01:00
|
|
|
for (i = 0; i < n_params; i++)
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
SPA_POD_PodObject(¶ms[i]), NULL) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-11-07 17:39:31 +01:00
|
|
|
|
2018-06-07 10:23:41 +02:00
|
|
|
if (spa_pod_parser_get(&prs,
|
2019-03-04 12:30:45 +01:00
|
|
|
SPA_POD_PodStruct(&ipod), NULL) < 0)
|
2018-06-07 10:23:41 +02:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
2019-03-04 12:30:45 +01:00
|
|
|
if (ipod) {
|
|
|
|
|
struct spa_pod_parser p2;
|
|
|
|
|
struct spa_pod_frame f2;
|
|
|
|
|
infop = &info;
|
|
|
|
|
|
|
|
|
|
spa_pod_parser_pod(&p2, ipod);
|
|
|
|
|
if (spa_pod_parser_push_struct(&p2, &f2) < 0 ||
|
|
|
|
|
spa_pod_parser_get(&p2,
|
|
|
|
|
SPA_POD_Int(&info.max_input_ports),
|
|
|
|
|
SPA_POD_Int(&info.max_output_ports),
|
|
|
|
|
SPA_POD_Long(&info.change_mask),
|
|
|
|
|
SPA_POD_Long(&info.flags),
|
|
|
|
|
SPA_POD_Int(&props.n_items), NULL) < 0)
|
2018-06-07 10:23:41 +02:00
|
|
|
return -EINVAL;
|
2019-03-04 12:30:45 +01:00
|
|
|
|
|
|
|
|
info.change_mask &= SPA_NODE_CHANGE_MASK_FLAGS |
|
|
|
|
|
SPA_NODE_CHANGE_MASK_PROPS |
|
|
|
|
|
SPA_NODE_CHANGE_MASK_PARAMS;
|
|
|
|
|
|
|
|
|
|
if (props.n_items > 0) {
|
|
|
|
|
info.props = &props;
|
|
|
|
|
|
|
|
|
|
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
2019-07-11 12:52:55 +02:00
|
|
|
if (parse_dict(&p2, &props) < 0)
|
|
|
|
|
return -EINVAL;
|
2019-03-04 12:30:45 +01:00
|
|
|
}
|
|
|
|
|
if (spa_pod_parser_get(&p2,
|
|
|
|
|
SPA_POD_Int(&info.n_params), NULL) < 0)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
if (info.n_params > 0) {
|
|
|
|
|
info.params = alloca(info.n_params * sizeof(struct spa_param_info));
|
|
|
|
|
for (i = 0; i < info.n_params; i++) {
|
|
|
|
|
if (spa_pod_parser_get(&p2,
|
|
|
|
|
SPA_POD_Id(&info.params[i].id),
|
|
|
|
|
SPA_POD_Int(&info.params[i].flags), NULL) < 0)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-07 10:23:41 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-29 10:39:24 +02:00
|
|
|
pw_resource_notify(resource, struct pw_client_node_proxy_methods, update, 0, change_mask,
|
2017-11-07 17:39:31 +01:00
|
|
|
n_params,
|
2019-03-04 12:30:45 +01:00
|
|
|
params, infop);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_port_update(void *object, const struct pw_protocol_native_message *msg)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-06-21 12:11:54 +02:00
|
|
|
struct pw_resource *resource = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2019-01-22 17:38:23 +01:00
|
|
|
struct spa_pod_frame f;
|
2017-11-07 17:39:31 +01:00
|
|
|
uint32_t i, direction, port_id, change_mask, n_params;
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod **params = NULL;
|
2019-02-14 17:08:46 +01:00
|
|
|
struct spa_port_info info = SPA_PORT_INFO_INIT(), *infop = NULL;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod *ipod;
|
2018-02-09 18:10:51 +01:00
|
|
|
struct spa_dict props;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-22 17:38:23 +01:00
|
|
|
if (spa_pod_parser_push_struct(&prs, &f) < 0 ||
|
|
|
|
|
spa_pod_parser_get(&prs,
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(&direction),
|
|
|
|
|
SPA_POD_Int(&port_id),
|
|
|
|
|
SPA_POD_Int(&change_mask),
|
|
|
|
|
SPA_POD_Int(&n_params), NULL) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2017-11-13 17:57:38 +01:00
|
|
|
params = alloca(n_params * sizeof(struct spa_pod *));
|
2017-06-21 12:11:54 +02:00
|
|
|
for (i = 0; i < n_params; i++)
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
SPA_POD_PodObject(¶ms[i]), NULL) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-04-27 17:17:47 +02:00
|
|
|
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
SPA_POD_PodStruct(&ipod), NULL) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-03-14 20:18:31 +01:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
if (ipod) {
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser p2;
|
2019-01-22 17:38:23 +01:00
|
|
|
struct spa_pod_frame f2;
|
2017-06-21 12:11:54 +02:00
|
|
|
infop = &info;
|
|
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_pod(&p2, ipod);
|
2019-01-22 17:38:23 +01:00
|
|
|
if (spa_pod_parser_push_struct(&p2, &f2) < 0 ||
|
|
|
|
|
spa_pod_parser_get(&p2,
|
2019-02-27 16:43:01 +01:00
|
|
|
SPA_POD_Long(&info.change_mask),
|
2019-03-04 12:30:45 +01:00
|
|
|
SPA_POD_Long(&info.flags),
|
|
|
|
|
SPA_POD_Int(&info.rate.num),
|
|
|
|
|
SPA_POD_Int(&info.rate.denom),
|
2019-01-16 11:05:12 +01:00
|
|
|
SPA_POD_Int(&props.n_items), NULL) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2018-02-09 18:10:51 +01:00
|
|
|
|
2019-02-27 16:43:01 +01:00
|
|
|
info.change_mask &= SPA_PORT_CHANGE_MASK_FLAGS |
|
|
|
|
|
SPA_PORT_CHANGE_MASK_RATE |
|
|
|
|
|
SPA_PORT_CHANGE_MASK_PROPS |
|
|
|
|
|
SPA_PORT_CHANGE_MASK_PARAMS;
|
|
|
|
|
|
2018-02-09 18:10:51 +01:00
|
|
|
if (props.n_items > 0) {
|
|
|
|
|
info.props = &props;
|
|
|
|
|
|
|
|
|
|
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
|
2019-07-11 12:52:55 +02:00
|
|
|
if (parse_dict(&p2, &props) < 0)
|
|
|
|
|
return -EINVAL;
|
2018-02-09 18:10:51 +01:00
|
|
|
}
|
2019-02-27 16:43:01 +01:00
|
|
|
if (spa_pod_parser_get(&p2,
|
|
|
|
|
SPA_POD_Int(&info.n_params), NULL) < 0)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
if (info.n_params > 0) {
|
|
|
|
|
info.params = alloca(info.n_params * sizeof(struct spa_param_info));
|
|
|
|
|
for (i = 0; i < info.n_params; i++) {
|
|
|
|
|
if (spa_pod_parser_get(&p2,
|
|
|
|
|
SPA_POD_Id(&info.params[i].id),
|
|
|
|
|
SPA_POD_Int(&info.params[i].flags), NULL) < 0)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2019-05-29 10:39:24 +02:00
|
|
|
pw_resource_notify(resource, struct pw_client_node_proxy_methods, port_update, 0, direction,
|
2017-07-13 15:21:52 +02:00
|
|
|
port_id,
|
|
|
|
|
change_mask,
|
|
|
|
|
n_params,
|
|
|
|
|
params, infop);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_set_active(void *object, const struct pw_protocol_native_message *msg)
|
2017-10-13 16:18:42 +02:00
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
|
|
|
|
struct spa_pod_parser prs;
|
2017-12-18 11:38:30 +01:00
|
|
|
int active;
|
2017-10-13 16:18:42 +02:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_Bool(&active)) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-10-13 16:18:42 +02:00
|
|
|
|
2019-05-29 10:39:24 +02:00
|
|
|
pw_resource_notify(resource, struct pw_client_node_proxy_methods, set_active, 0, active);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-10-13 16:18:42 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
static int client_node_demarshal_event_method(void *object, const struct pw_protocol_native_message *msg)
|
2017-06-21 12:11:54 +02:00
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2019-05-28 13:51:12 +02:00
|
|
|
const struct spa_event *event;
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2019-03-19 16:15:20 +01:00
|
|
|
spa_pod_parser_init(&prs, msg->data, msg->size);
|
2019-01-16 11:05:12 +01:00
|
|
|
if (spa_pod_parser_get_struct(&prs,
|
|
|
|
|
SPA_POD_PodObject(&event)) < 0)
|
2017-12-18 11:38:30 +01:00
|
|
|
return -EINVAL;
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2019-05-29 10:39:24 +02:00
|
|
|
pw_resource_notify(resource, struct pw_client_node_proxy_methods, event, 0, event);
|
2017-12-18 11:38:30 +01:00
|
|
|
return 0;
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
static const struct pw_client_node_proxy_methods pw_protocol_native_client_node_method_marshal = {
|
|
|
|
|
PW_VERSION_CLIENT_NODE_PROXY_METHODS,
|
2019-05-20 16:11:23 +02:00
|
|
|
.add_listener = &client_node_marshal_add_listener,
|
|
|
|
|
.get_node = &client_node_marshal_get_node,
|
|
|
|
|
.update = &client_node_marshal_update,
|
|
|
|
|
.port_update = &client_node_marshal_port_update,
|
|
|
|
|
.set_active = &client_node_marshal_set_active,
|
|
|
|
|
.event = &client_node_marshal_event_method
|
2017-03-03 19:06:54 +01:00
|
|
|
};
|
|
|
|
|
|
2019-05-20 16:11:23 +02:00
|
|
|
static const struct pw_protocol_native_demarshal
|
|
|
|
|
pw_protocol_native_client_node_method_demarshal[PW_CLIENT_NODE_PROXY_METHOD_NUM] =
|
|
|
|
|
{
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_METHOD_ADD_LISTENER] = { NULL, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_METHOD_GET_NODE] = { &client_node_demarshal_get_node, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_METHOD_UPDATE] = { &client_node_demarshal_update, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_METHOD_PORT_UPDATE] = { &client_node_demarshal_port_update, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_METHOD_SET_ACTIVE] = { &client_node_demarshal_set_active, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_METHOD_EVENT] = { &client_node_demarshal_event_method, 0 }
|
2017-03-09 13:00:56 +01:00
|
|
|
};
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
static const struct pw_client_node_proxy_events pw_protocol_native_client_node_event_marshal = {
|
|
|
|
|
PW_VERSION_CLIENT_NODE_PROXY_EVENTS,
|
2019-05-20 16:11:23 +02:00
|
|
|
.transport = &client_node_marshal_transport,
|
|
|
|
|
.set_param = &client_node_marshal_set_param,
|
|
|
|
|
.set_io = &client_node_marshal_set_io,
|
|
|
|
|
.event = &client_node_marshal_event_event,
|
|
|
|
|
.command = &client_node_marshal_command,
|
|
|
|
|
.add_port = &client_node_marshal_add_port,
|
|
|
|
|
.remove_port = &client_node_marshal_remove_port,
|
|
|
|
|
.port_set_param = &client_node_marshal_port_set_param,
|
|
|
|
|
.port_use_buffers = &client_node_marshal_port_use_buffers,
|
|
|
|
|
.port_set_io = &client_node_marshal_port_set_io,
|
|
|
|
|
.set_activation = &client_node_marshal_set_activation,
|
2017-03-03 19:06:54 +01:00
|
|
|
};
|
|
|
|
|
|
2019-05-20 16:11:23 +02:00
|
|
|
static const struct pw_protocol_native_demarshal
|
|
|
|
|
pw_protocol_native_client_node_event_demarshal[PW_CLIENT_NODE_PROXY_EVENT_NUM] =
|
|
|
|
|
{
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_EVENT_TRANSPORT] = { &client_node_demarshal_transport, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_EVENT_SET_PARAM] = { &client_node_demarshal_set_param, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_EVENT_SET_IO] = { &client_node_demarshal_set_io, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_EVENT_EVENT] = { &client_node_demarshal_event_event, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_EVENT_COMMAND] = { &client_node_demarshal_command, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_EVENT_ADD_PORT] = { &client_node_demarshal_add_port, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_EVENT_REMOVE_PORT] = { &client_node_demarshal_remove_port, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_PARAM] = { &client_node_demarshal_port_set_param, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_EVENT_PORT_USE_BUFFERS] = { &client_node_demarshal_port_use_buffers, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_IO] = { &client_node_demarshal_port_set_io, 0 },
|
|
|
|
|
[PW_CLIENT_NODE_PROXY_EVENT_SET_ACTIVATION] = { &client_node_demarshal_set_activation, 0 }
|
2017-07-13 15:21:52 +02:00
|
|
|
};
|
|
|
|
|
|
2017-12-14 18:28:03 +01:00
|
|
|
static const struct pw_protocol_marshal pw_protocol_native_client_node_marshal = {
|
2018-08-27 15:03:11 +02:00
|
|
|
PW_TYPE_INTERFACE_ClientNode,
|
2017-06-21 12:11:54 +02:00
|
|
|
PW_VERSION_CLIENT_NODE,
|
2019-02-08 12:01:50 +01:00
|
|
|
PW_CLIENT_NODE_PROXY_METHOD_NUM,
|
|
|
|
|
PW_CLIENT_NODE_PROXY_EVENT_NUM,
|
2017-07-13 15:21:52 +02:00
|
|
|
&pw_protocol_native_client_node_method_marshal,
|
|
|
|
|
&pw_protocol_native_client_node_method_demarshal,
|
|
|
|
|
&pw_protocol_native_client_node_event_marshal,
|
|
|
|
|
pw_protocol_native_client_node_event_demarshal,
|
2017-03-03 19:06:54 +01:00
|
|
|
};
|
2017-03-09 13:00:56 +01:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_core *core)
|
2017-05-26 08:05:01 +02:00
|
|
|
{
|
2017-06-15 17:54:55 +02:00
|
|
|
struct pw_protocol *protocol;
|
|
|
|
|
|
2019-01-14 12:58:23 +01:00
|
|
|
protocol = pw_core_find_protocol(core, PW_TYPE_INFO_PROTOCOL_Native);
|
2017-06-15 17:54:55 +02:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
if (protocol == NULL)
|
|
|
|
|
return NULL;
|
2017-06-16 10:06:50 +02:00
|
|
|
|
2017-07-13 15:21:52 +02:00
|
|
|
pw_protocol_add_marshal(protocol, &pw_protocol_native_client_node_marshal);
|
2017-06-15 17:54:55 +02:00
|
|
|
|
2017-06-16 10:06:50 +02:00
|
|
|
return protocol;
|
2017-03-09 13:00:56 +01:00
|
|
|
}
|