device: implement subscribe_params

Also add subscribe params for the device, like for Node and Port.
This commit is contained in:
Wim Taymans 2020-02-12 16:05:08 +01:00
parent df65e0bcd3
commit 495dc7c3af
6 changed files with 160 additions and 11 deletions

View file

@ -905,6 +905,38 @@ static int device_demarshal_param(void *object, const struct pw_protocol_native_
seq, id, index, next, param);
}
static int device_marshal_subscribe_params(void *object, uint32_t *ids, uint32_t n_ids)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_proxy(proxy, PW_DEVICE_METHOD_SUBSCRIBE_PARAMS, NULL);
spa_pod_builder_add_struct(b,
SPA_POD_Array(sizeof(uint32_t), SPA_TYPE_Id, n_ids, ids));
return pw_protocol_native_end_proxy(proxy, b);
}
static int device_demarshal_subscribe_params(void *object, const struct pw_protocol_native_message *msg)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
uint32_t csize, ctype, n_ids;
uint32_t *ids;
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Array(&csize, &ctype, &n_ids, &ids)) < 0)
return -EINVAL;
if (ctype != SPA_TYPE_Id)
return -EINVAL;
return pw_resource_notify(resource, struct pw_device_methods, subscribe_params, 0,
ids, n_ids);
}
static int device_marshal_enum_params(void *object, int seq,
uint32_t id, uint32_t index, uint32_t num, const struct spa_pod *filter)
{
@ -2067,6 +2099,7 @@ const struct pw_protocol_marshal pw_protocol_native_factory_marshal = {
static const struct pw_device_methods pw_protocol_native_device_method_marshal = {
PW_VERSION_DEVICE_METHODS,
.add_listener = &device_method_marshal_add_listener,
.subscribe_params = &device_marshal_subscribe_params,
.enum_params = &device_marshal_enum_params,
.set_param = &device_marshal_set_param,
};
@ -2074,6 +2107,7 @@ static const struct pw_device_methods pw_protocol_native_device_method_marshal =
static const struct pw_protocol_native_demarshal
pw_protocol_native_device_method_demarshal[PW_DEVICE_METHOD_NUM] = {
[PW_DEVICE_METHOD_ADD_LISTENER] = { NULL, 0, },
[PW_DEVICE_METHOD_SUBSCRIBE_PARAMS] = { &device_demarshal_subscribe_params, 0, },
[PW_DEVICE_METHOD_ENUM_PARAMS] = { &device_demarshal_enum_params, 0, },
[PW_DEVICE_METHOD_SET_PARAM] = { &device_demarshal_set_param, PW_PERM_W, },
};