mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
proxy: add pw_proxy_set_bound_id
Add method to set bound_id and emit the signal. Rename resource_bound_id -> resource_set_bound_id and add resource_get_bound_id.
This commit is contained in:
parent
030d2a075b
commit
5a2ad084e8
18 changed files with 50 additions and 15 deletions
|
|
@ -104,7 +104,7 @@ static void device_initialized(void *data)
|
|||
struct pw_global *global = pw_device_get_global(device);
|
||||
|
||||
pw_log_debug("client-device %p: initialized global:%d", impl, global->id);
|
||||
pw_resource_bound_id(impl->resource, global->id);
|
||||
pw_resource_set_bound_id(impl->resource, global->id);
|
||||
}
|
||||
|
||||
static const struct pw_device_events device_events = {
|
||||
|
|
|
|||
|
|
@ -1228,7 +1228,7 @@ void pw_client_node_registered(struct pw_client_node *this, struct pw_global *gl
|
|||
if (this->resource == NULL)
|
||||
return;
|
||||
|
||||
pw_resource_bound_id(this->resource, node_id);
|
||||
pw_resource_set_bound_id(this->resource, node_id);
|
||||
|
||||
pw_client_node_resource_transport(this->resource,
|
||||
impl->other_fds[0],
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ int endpoint_init(struct endpoint *this,
|
|||
this->info.id = this->global->id;
|
||||
this->info.props = &this->props->dict;
|
||||
|
||||
pw_resource_bound_id(client_ep->resource, this->global->id);
|
||||
pw_resource_set_bound_id(client_ep->resource, this->global->id);
|
||||
|
||||
return pw_global_register(this->global);
|
||||
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ int session_init(struct session *this,
|
|||
this->info.id = this->global->id;
|
||||
this->info.props = &this->props->dict;
|
||||
|
||||
pw_resource_bound_id(client_sess->resource, this->global->id);
|
||||
pw_resource_set_bound_id(client_sess->resource, this->global->id);
|
||||
|
||||
return pw_global_register(this->global);
|
||||
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
|||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||
|
||||
spa_list_append(&global->resource_list, &resource->link);
|
||||
pw_resource_bound_id(resource, global->id);
|
||||
pw_resource_set_bound_id(resource, global->id);
|
||||
|
||||
if (resource->id == 1)
|
||||
client->client_resource = resource;
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ static void core_event_bound_id(void *data, uint32_t id, uint32_t global_id)
|
|||
|
||||
pw_log_debug(NAME" %p: proxy %u bound %u", this, id, global_id);
|
||||
if ((proxy = pw_map_lookup(&this->objects, id)) != NULL) {
|
||||
pw_proxy_emit_bound(proxy, global_id);
|
||||
pw_proxy_set_bound_id(proxy, global_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ global_bind(void *_data,
|
|||
&core_methods, resource);
|
||||
|
||||
spa_list_append(&global->resource_list, &resource->link);
|
||||
pw_resource_bound_id(resource, global->id);
|
||||
pw_resource_set_bound_id(resource, global->id);
|
||||
|
||||
if (resource->id == 0)
|
||||
client->core_resource = resource;
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
|||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||
|
||||
spa_list_append(&global->resource_list, &resource->link);
|
||||
pw_resource_bound_id(resource, global->id);
|
||||
pw_resource_set_bound_id(resource, global->id);
|
||||
|
||||
this->info.change_mask = PW_DEVICE_CHANGE_MASK_ALL;
|
||||
pw_device_resource_info(resource, &this->info);
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
|||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||
|
||||
spa_list_append(&global->resource_list, &resource->link);
|
||||
pw_resource_bound_id(resource, global->id);
|
||||
pw_resource_set_bound_id(resource, global->id);
|
||||
|
||||
this->info.change_mask = ~0;
|
||||
pw_factory_resource_info(resource, &this->info);
|
||||
|
|
|
|||
|
|
@ -824,7 +824,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
|||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||
|
||||
spa_list_append(&global->resource_list, &resource->link);
|
||||
pw_resource_bound_id(resource, global->id);
|
||||
pw_resource_set_bound_id(resource, global->id);
|
||||
|
||||
this->info.change_mask = ~0;
|
||||
pw_link_resource_info(resource, &this->info);
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
|||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||
|
||||
spa_list_append(&global->resource_list, &resource->link);
|
||||
pw_resource_bound_id(resource, global->id);
|
||||
pw_resource_set_bound_id(resource, global->id);
|
||||
|
||||
this->info.change_mask = ~0;
|
||||
pw_module_resource_info(resource, &this->info);
|
||||
|
|
|
|||
|
|
@ -522,7 +522,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
|||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||
|
||||
spa_list_append(&global->resource_list, &resource->link);
|
||||
pw_resource_bound_id(resource, global->id);
|
||||
pw_resource_set_bound_id(resource, global->id);
|
||||
|
||||
this->info.change_mask = PW_NODE_CHANGE_MASK_ALL;
|
||||
pw_node_resource_info(resource, &this->info);
|
||||
|
|
|
|||
|
|
@ -752,7 +752,7 @@ global_bind(void *_data, struct pw_client *client, uint32_t permissions,
|
|||
pw_log_debug(NAME" %p: bound to %d", this, resource->id);
|
||||
|
||||
spa_list_append(&global->resource_list, &resource->link);
|
||||
pw_resource_bound_id(resource, global->id);
|
||||
pw_resource_set_bound_id(resource, global->id);
|
||||
|
||||
this->info.change_mask = PW_PORT_CHANGE_MASK_ALL;
|
||||
pw_port_resource_info(resource, &this->info);
|
||||
|
|
|
|||
|
|
@ -692,6 +692,7 @@ struct pw_resource {
|
|||
uint32_t permissions; /**< resource permissions */
|
||||
uint32_t type; /**< type of the client interface */
|
||||
uint32_t version; /**< version of the client interface */
|
||||
uint32_t bound_id; /**< global id we are bound to */
|
||||
|
||||
unsigned int removed:1; /**< resource was removed from server */
|
||||
|
||||
|
|
@ -717,6 +718,7 @@ struct pw_proxy {
|
|||
uint32_t id; /**< client side id */
|
||||
uint32_t type; /**< type of the interface */
|
||||
uint32_t version; /**< client side version */
|
||||
uint32_t bound_id; /**< global id we are bound to */
|
||||
int refcount;
|
||||
unsigned int zombie:1; /**< proxy is removed locally and waiting to
|
||||
* be removed from server */
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ int pw_proxy_init(struct pw_proxy *proxy, uint32_t type, uint32_t version)
|
|||
proxy->refcount = 1;
|
||||
proxy->type = type;
|
||||
proxy->version = version;
|
||||
proxy->bound_id = SPA_ID_INVALID;
|
||||
|
||||
proxy->id = pw_map_insert_new(&proxy->core_proxy->objects, proxy);
|
||||
if (proxy->id == SPA_ID_INVALID) {
|
||||
|
|
@ -151,6 +152,20 @@ uint32_t pw_proxy_get_id(struct pw_proxy *proxy)
|
|||
return proxy->id;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
int pw_proxy_set_bound_id(struct pw_proxy *proxy, uint32_t global_id)
|
||||
{
|
||||
proxy->bound_id = global_id;
|
||||
pw_proxy_emit_bound(proxy, global_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
uint32_t pw_proxy_get_bound_id(struct pw_proxy *proxy)
|
||||
{
|
||||
return proxy->bound_id;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
uint32_t pw_proxy_get_type(struct pw_proxy *proxy, uint32_t *version)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -160,6 +160,13 @@ struct pw_protocol *pw_proxy_get_protocol(struct pw_proxy *proxy);
|
|||
* with the same seq number of the reply. */
|
||||
int pw_proxy_sync(struct pw_proxy *proxy, int seq);
|
||||
|
||||
/** Set the global id this proxy is bound to. This is usually used internally
|
||||
* and will also emit the bound event */
|
||||
int pw_proxy_set_bound_id(struct pw_proxy *proxy, uint32_t global_id);
|
||||
/** Get the global id bound to this proxy of SPA_ID_INVALID when not bound
|
||||
* to a global */
|
||||
uint32_t pw_proxy_get_bound_id(struct pw_proxy *proxy);
|
||||
|
||||
/** Generate an error for a proxy */
|
||||
int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error);
|
||||
int pw_proxy_errorf(struct pw_proxy *proxy, int res, const char *error, ...) SPA_PRINTF_FUNC(3, 4);
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ struct pw_resource *pw_resource_new(struct pw_client *client,
|
|||
this->permissions = permissions;
|
||||
this->type = type;
|
||||
this->version = version;
|
||||
this->bound_id = SPA_ID_INVALID;
|
||||
|
||||
spa_hook_list_init(&this->listener_list);
|
||||
spa_hook_list_init(&this->object_listener_list);
|
||||
|
|
@ -208,10 +209,11 @@ int pw_resource_ping(struct pw_resource *resource, int seq)
|
|||
}
|
||||
|
||||
SPA_EXPORT
|
||||
int pw_resource_bound_id(struct pw_resource *resource, uint32_t global_id)
|
||||
int pw_resource_set_bound_id(struct pw_resource *resource, uint32_t global_id)
|
||||
{
|
||||
struct pw_client *client = resource->client;
|
||||
|
||||
resource->bound_id = global_id;
|
||||
if (client->core_resource != NULL) {
|
||||
pw_log_debug(NAME" %p: %u global_id:%u", resource, resource->id, global_id);
|
||||
pw_core_resource_bound_id(client->core_resource, resource->id, global_id);
|
||||
|
|
@ -219,6 +221,12 @@ int pw_resource_bound_id(struct pw_resource *resource, uint32_t global_id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
uint32_t pw_resource_get_bound_id(struct pw_resource *resource)
|
||||
{
|
||||
return resource->bound_id;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
void pw_resource_errorf(struct pw_resource *resource, int res, const char *error, ...)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -122,7 +122,10 @@ void pw_resource_add_object_listener(struct pw_resource *resource,
|
|||
int pw_resource_ping(struct pw_resource *resource, int seq);
|
||||
|
||||
/** Notify global id this resource is bound to */
|
||||
int pw_resource_bound_id(struct pw_resource *resource, uint32_t global_id);
|
||||
int pw_resource_set_bound_id(struct pw_resource *resource, uint32_t global_id);
|
||||
|
||||
/** Get the global id this resource is bound to or SPA_ID_INVALID when not bound */
|
||||
uint32_t pw_resource_get_bound_id(struct pw_resource *resource);
|
||||
|
||||
/** Generate an error for a resource */
|
||||
void pw_resource_error(struct pw_resource *resource, int res, const char *error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue