protocol-native: emit bound_id and bound_props from protocol

Emit both the bound_id and bound_props events from the protocol on
the core_resource.

Doing the dispatching of the bound_id/bound_props in the core to the
proxy doesn't handle the case where the client has a listener directly
on the core_resource.

Fixes #3109
This commit is contained in:
Wim Taymans 2023-03-22 10:20:14 +01:00
parent fb8709716c
commit 5af265ed22
2 changed files with 19 additions and 15 deletions

View file

@ -385,6 +385,7 @@ static int core_event_demarshal_bound_id(void *data, const struct pw_protocol_na
struct pw_proxy *proxy = data;
struct spa_pod_parser prs;
uint32_t id, global_id;
struct spa_dict props = SPA_DICT_INIT(NULL, 0);
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_get_struct(&prs,
@ -392,7 +393,10 @@ static int core_event_demarshal_bound_id(void *data, const struct pw_protocol_na
SPA_POD_Int(&global_id)) < 0)
return -EINVAL;
return pw_proxy_notify(proxy, struct pw_core_events, bound_id, 0, id, global_id);
/* old client / old/new server -> bound_id
* new client / old server -> bound_id + bound_props (in case it's using bound_props only) */
pw_proxy_notify(proxy, struct pw_core_events, bound_id, 0, id, global_id);
return pw_proxy_notify(proxy, struct pw_core_events, bound_props, 1, id, global_id, &props);
}
static int core_event_demarshal_bound_props(void *data, const struct pw_protocol_native_message *msg)
@ -413,6 +417,8 @@ static int core_event_demarshal_bound_props(void *data, const struct pw_protocol
parse_dict_struct(&prs, &f[1], &props);
/* new client / new server -> bound_props + bound_id (in case it's not using bound_props yet) */
pw_proxy_notify(proxy, struct pw_core_events, bound_id, 0, id, global_id);
return pw_proxy_notify(proxy, struct pw_core_events, bound_props, 1, id, global_id, &props);
}

View file

@ -63,26 +63,14 @@ static void core_event_remove_id(void *data, uint32_t id)
pw_proxy_remove(proxy);
}
static void bound_props(void *data, uint32_t id, uint32_t global_id, const struct spa_dict *props)
static void core_event_bound_id(void *data, uint32_t id, uint32_t global_id)
{
struct pw_core *this = data;
struct pw_proxy *proxy;
pw_log_debug("%p: proxy id %u bound %u", this, id, global_id);
if ((proxy = pw_map_lookup(&this->objects, id)) != NULL) {
if ((proxy = pw_map_lookup(&this->objects, id)) != NULL)
pw_proxy_set_bound_id(proxy, global_id);
pw_proxy_emit_bound_props(proxy, global_id, props);
}
}
static void core_event_bound_props(void *data, uint32_t id, uint32_t global_id, const struct spa_dict *props)
{
bound_props(data, id, global_id, props);
}
static void core_event_bound_id(void *data, uint32_t id, uint32_t global_id)
{
bound_props(data, id, global_id, NULL);
}
static void core_event_add_mem(void *data, uint32_t id, uint32_t type, int fd, uint32_t flags)
@ -101,6 +89,16 @@ static void core_event_add_mem(void *data, uint32_t id, uint32_t type, int fd, u
}
}
static void core_event_bound_props(void *data, uint32_t id, uint32_t global_id, const struct spa_dict *props)
{
struct pw_core *this = data;
struct pw_proxy *proxy;
pw_log_debug("%p: proxy id %u bound %u", this, id, global_id);
if ((proxy = pw_map_lookup(&this->objects, id)) != NULL)
pw_proxy_emit_bound_props(proxy, global_id, props);
}
static void core_event_remove_mem(void *data, uint32_t id)
{
struct pw_core *this = data;