global: add serial number

Add a global serial number for each global object. We can use this
to uniquely define each global.
This commit is contained in:
Wim Taymans 2021-11-08 12:24:48 +01:00
parent dd62b12a1f
commit 59c4975750
2 changed files with 9 additions and 3 deletions

View file

@ -36,6 +36,8 @@
PW_LOG_TOPIC_EXTERN(log_global);
#define PW_LOG_TOPIC_DEFAULT log_global
static uint64_t serial = 0;
/** \cond */
struct impl {
struct pw_global this;
@ -133,10 +135,12 @@ int pw_global_register(struct pw_global *global)
spa_list_append(&context->global_list, &global->link);
global->registered = true;
global->serial = ++serial;
spa_list_for_each(registry, &context->registry_resource_list, link) {
uint32_t permissions = pw_global_get_permissions(global, registry->client);
pw_log_debug("registry %p: global %d %08x", registry, global->id, permissions);
pw_log_debug("registry %p: global %d %08x serial:%"PRIu64,
registry, global->id, permissions, global->serial);
if (PW_PERM_IS_R(permissions))
pw_registry_resource_global(registry,
global->id,
@ -337,8 +341,9 @@ int pw_global_update_permissions(struct pw_global *global, struct pw_impl_client
pw_registry_resource_global_remove(resource, global->id);
}
else if (do_show) {
pw_log_debug("client %p: resource %p show global %d",
client, resource, global->id);
pw_log_debug("client %p: resource %p show global %d serial:%"PRIu64,
client, resource, global->id,
global->serial);
pw_registry_resource_global(resource,
global->id,
new_permissions,

View file

@ -330,6 +330,7 @@ struct pw_global {
pw_global_bind_func_t func; /**< bind function */
void *object; /**< object associated with the interface */
uint64_t serial; /**< increasing serial number */
struct spa_list resource_list; /**< The list of resources of this global */