mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
interfaces: add event to notify of global bound id
Make it possible to know when a proxy is bound to a global id before the global shows up in the registry. This makes it possible to match locally created objects to the one appearing in the registry and possibly avoid a second bind.
This commit is contained in:
parent
b264ef0772
commit
f56e4dbc4d
8 changed files with 81 additions and 3 deletions
|
|
@ -337,6 +337,21 @@ static int core_event_demarshal_remove_id(void *object, const struct pw_protocol
|
|||
return pw_proxy_notify(proxy, struct pw_core_proxy_events, remove_id, 0, id);
|
||||
}
|
||||
|
||||
static int core_event_demarshal_bound_id(void *object, const struct pw_protocol_native_message *msg)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_parser prs;
|
||||
uint32_t id, global_id;
|
||||
|
||||
spa_pod_parser_init(&prs, msg->data, msg->size);
|
||||
if (spa_pod_parser_get_struct(&prs,
|
||||
SPA_POD_Int(&id),
|
||||
SPA_POD_Int(&global_id)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return pw_proxy_notify(proxy, struct pw_core_proxy_events, bound_id, 0, id, global_id);
|
||||
}
|
||||
|
||||
static int core_event_demarshal_add_mem(void *object, const struct pw_protocol_native_message *msg)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
|
|
@ -454,6 +469,20 @@ static void core_event_marshal_remove_id(void *object, uint32_t id)
|
|||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
||||
static void core_event_marshal_bound_id(void *object, uint32_t id, uint32_t global_id)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
struct spa_pod_builder *b;
|
||||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CORE_PROXY_EVENT_BOUND_ID, NULL);
|
||||
|
||||
spa_pod_builder_add_struct(b,
|
||||
SPA_POD_Int(id),
|
||||
SPA_POD_Int(global_id));
|
||||
|
||||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
||||
static void core_event_marshal_add_mem(void *object, uint32_t id, uint32_t type, int fd, uint32_t flags)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
|
|
@ -1894,6 +1923,7 @@ static const struct pw_core_proxy_events pw_protocol_native_core_event_marshal =
|
|||
.ping = &core_event_marshal_ping,
|
||||
.error = &core_event_marshal_error,
|
||||
.remove_id = &core_event_marshal_remove_id,
|
||||
.bound_id = &core_event_marshal_bound_id,
|
||||
.add_mem = &core_event_marshal_add_mem,
|
||||
.remove_mem = &core_event_marshal_remove_mem,
|
||||
};
|
||||
|
|
@ -1906,6 +1936,7 @@ pw_protocol_native_core_event_demarshal[PW_CORE_PROXY_EVENT_NUM] =
|
|||
[PW_CORE_PROXY_EVENT_PING] = { &core_event_demarshal_ping, 0, },
|
||||
[PW_CORE_PROXY_EVENT_ERROR] = { &core_event_demarshal_error, 0, },
|
||||
[PW_CORE_PROXY_EVENT_REMOVE_ID] = { &core_event_demarshal_remove_id, 0, },
|
||||
[PW_CORE_PROXY_EVENT_BOUND_ID] = { &core_event_demarshal_bound_id, 0, },
|
||||
[PW_CORE_PROXY_EVENT_ADD_MEM] = { &core_event_demarshal_add_mem, 0, },
|
||||
[PW_CORE_PROXY_EVENT_REMOVE_MEM] = { &core_event_demarshal_remove_mem, 0, },
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue