mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	introspect: add id to info again
The global is created first, with the global id in the info, it's possible to easily link a new object to a global.
This commit is contained in:
		
							parent
							
								
									4bef583b75
								
							
						
					
					
						commit
						d9bae8f38b
					
				
					 8 changed files with 28 additions and 0 deletions
				
			
		| 
						 | 
					@ -188,6 +188,7 @@ static bool core_demarshal_info(void *object, void *data, size_t size)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!spa_pod_iter_struct(&it, data, size) ||
 | 
						if (!spa_pod_iter_struct(&it, data, size) ||
 | 
				
			||||||
	    !spa_pod_iter_get(&it,
 | 
						    !spa_pod_iter_get(&it,
 | 
				
			||||||
 | 
								      SPA_POD_TYPE_INT, &info.id,
 | 
				
			||||||
			      SPA_POD_TYPE_LONG, &info.change_mask,
 | 
								      SPA_POD_TYPE_LONG, &info.change_mask,
 | 
				
			||||||
			      SPA_POD_TYPE_STRING, &info.user_name,
 | 
								      SPA_POD_TYPE_STRING, &info.user_name,
 | 
				
			||||||
			      SPA_POD_TYPE_STRING, &info.host_name,
 | 
								      SPA_POD_TYPE_STRING, &info.host_name,
 | 
				
			||||||
| 
						 | 
					@ -287,6 +288,7 @@ static void core_marshal_info(void *object, struct pw_core_info *info)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_pod_builder_add(b,
 | 
						spa_pod_builder_add(b,
 | 
				
			||||||
			    SPA_POD_TYPE_STRUCT, &f,
 | 
								    SPA_POD_TYPE_STRUCT, &f,
 | 
				
			||||||
 | 
								    SPA_POD_TYPE_INT, info->id,
 | 
				
			||||||
			    SPA_POD_TYPE_LONG, info->change_mask,
 | 
								    SPA_POD_TYPE_LONG, info->change_mask,
 | 
				
			||||||
			    SPA_POD_TYPE_STRING, info->user_name,
 | 
								    SPA_POD_TYPE_STRING, info->user_name,
 | 
				
			||||||
			    SPA_POD_TYPE_STRING, info->host_name,
 | 
								    SPA_POD_TYPE_STRING, info->host_name,
 | 
				
			||||||
| 
						 | 
					@ -585,6 +587,7 @@ static void module_marshal_info(void *object, struct pw_module_info *info)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_pod_builder_add(b,
 | 
						spa_pod_builder_add(b,
 | 
				
			||||||
			    SPA_POD_TYPE_STRUCT, &f,
 | 
								    SPA_POD_TYPE_STRUCT, &f,
 | 
				
			||||||
 | 
								    SPA_POD_TYPE_INT, info->id,
 | 
				
			||||||
			    SPA_POD_TYPE_LONG, info->change_mask,
 | 
								    SPA_POD_TYPE_LONG, info->change_mask,
 | 
				
			||||||
			    SPA_POD_TYPE_STRING, info->name,
 | 
								    SPA_POD_TYPE_STRING, info->name,
 | 
				
			||||||
			    SPA_POD_TYPE_STRING, info->filename,
 | 
								    SPA_POD_TYPE_STRING, info->filename,
 | 
				
			||||||
| 
						 | 
					@ -610,6 +613,7 @@ static bool module_demarshal_info(void *object, void *data, size_t size)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!spa_pod_iter_struct(&it, data, size) ||
 | 
						if (!spa_pod_iter_struct(&it, data, size) ||
 | 
				
			||||||
	    !spa_pod_iter_get(&it,
 | 
						    !spa_pod_iter_get(&it,
 | 
				
			||||||
 | 
								      SPA_POD_TYPE_INT, &info.id,
 | 
				
			||||||
			      SPA_POD_TYPE_LONG, &info.change_mask,
 | 
								      SPA_POD_TYPE_LONG, &info.change_mask,
 | 
				
			||||||
			      SPA_POD_TYPE_STRING, &info.name,
 | 
								      SPA_POD_TYPE_STRING, &info.name,
 | 
				
			||||||
			      SPA_POD_TYPE_STRING, &info.filename,
 | 
								      SPA_POD_TYPE_STRING, &info.filename,
 | 
				
			||||||
| 
						 | 
					@ -639,6 +643,7 @@ static void node_marshal_info(void *object, struct pw_node_info *info)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_pod_builder_add(b,
 | 
						spa_pod_builder_add(b,
 | 
				
			||||||
			    SPA_POD_TYPE_STRUCT, &f,
 | 
								    SPA_POD_TYPE_STRUCT, &f,
 | 
				
			||||||
 | 
								    SPA_POD_TYPE_INT, info->id,
 | 
				
			||||||
			    SPA_POD_TYPE_LONG, info->change_mask,
 | 
								    SPA_POD_TYPE_LONG, info->change_mask,
 | 
				
			||||||
			    SPA_POD_TYPE_STRING, info->name,
 | 
								    SPA_POD_TYPE_STRING, info->name,
 | 
				
			||||||
			    SPA_POD_TYPE_INT, info->max_input_ports,
 | 
								    SPA_POD_TYPE_INT, info->max_input_ports,
 | 
				
			||||||
| 
						 | 
					@ -682,6 +687,7 @@ static bool node_demarshal_info(void *object, void *data, size_t size)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!spa_pod_iter_struct(&it, data, size) ||
 | 
						if (!spa_pod_iter_struct(&it, data, size) ||
 | 
				
			||||||
	    !spa_pod_iter_get(&it,
 | 
						    !spa_pod_iter_get(&it,
 | 
				
			||||||
 | 
								      SPA_POD_TYPE_INT, &info.id,
 | 
				
			||||||
			      SPA_POD_TYPE_LONG, &info.change_mask,
 | 
								      SPA_POD_TYPE_LONG, &info.change_mask,
 | 
				
			||||||
			      SPA_POD_TYPE_STRING, &info.name,
 | 
								      SPA_POD_TYPE_STRING, &info.name,
 | 
				
			||||||
			      SPA_POD_TYPE_INT, &info.max_input_ports,
 | 
								      SPA_POD_TYPE_INT, &info.max_input_ports,
 | 
				
			||||||
| 
						 | 
					@ -736,6 +742,7 @@ static void client_marshal_info(void *object, struct pw_client_info *info)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_pod_builder_add(b,
 | 
						spa_pod_builder_add(b,
 | 
				
			||||||
			    SPA_POD_TYPE_STRUCT, &f,
 | 
								    SPA_POD_TYPE_STRUCT, &f,
 | 
				
			||||||
 | 
								    SPA_POD_TYPE_INT, info->id,
 | 
				
			||||||
			    SPA_POD_TYPE_LONG, info->change_mask,
 | 
								    SPA_POD_TYPE_LONG, info->change_mask,
 | 
				
			||||||
			    SPA_POD_TYPE_INT, n_items, 0);
 | 
								    SPA_POD_TYPE_INT, n_items, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -759,6 +766,7 @@ static bool client_demarshal_info(void *object, void *data, size_t size)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!spa_pod_iter_struct(&it, data, size) ||
 | 
						if (!spa_pod_iter_struct(&it, data, size) ||
 | 
				
			||||||
	    !spa_pod_iter_get(&it,
 | 
						    !spa_pod_iter_get(&it,
 | 
				
			||||||
 | 
								      SPA_POD_TYPE_INT, &info.id,
 | 
				
			||||||
			      SPA_POD_TYPE_LONG, &info.change_mask,
 | 
								      SPA_POD_TYPE_LONG, &info.change_mask,
 | 
				
			||||||
			      SPA_POD_TYPE_INT, &props.n_items, 0))
 | 
								      SPA_POD_TYPE_INT, &props.n_items, 0))
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
| 
						 | 
					@ -788,6 +796,7 @@ static void link_marshal_info(void *object, struct pw_link_info *info)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_pod_builder_add(b,
 | 
						spa_pod_builder_add(b,
 | 
				
			||||||
			    SPA_POD_TYPE_STRUCT, &f,
 | 
								    SPA_POD_TYPE_STRUCT, &f,
 | 
				
			||||||
 | 
								    SPA_POD_TYPE_INT, info->id,
 | 
				
			||||||
			    SPA_POD_TYPE_LONG, info->change_mask,
 | 
								    SPA_POD_TYPE_LONG, info->change_mask,
 | 
				
			||||||
			    SPA_POD_TYPE_INT, info->output_node_id,
 | 
								    SPA_POD_TYPE_INT, info->output_node_id,
 | 
				
			||||||
			    SPA_POD_TYPE_INT, info->output_port_id,
 | 
								    SPA_POD_TYPE_INT, info->output_port_id,
 | 
				
			||||||
| 
						 | 
					@ -816,6 +825,7 @@ static bool link_demarshal_info(void *object, void *data, size_t size)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!spa_pod_iter_struct(&it, data, size) ||
 | 
						if (!spa_pod_iter_struct(&it, data, size) ||
 | 
				
			||||||
	    !spa_pod_iter_get(&it,
 | 
						    !spa_pod_iter_get(&it,
 | 
				
			||||||
 | 
								      SPA_POD_TYPE_INT, &info.id,
 | 
				
			||||||
			      SPA_POD_TYPE_LONG, &info.change_mask,
 | 
								      SPA_POD_TYPE_LONG, &info.change_mask,
 | 
				
			||||||
			      SPA_POD_TYPE_INT, &info.output_node_id,
 | 
								      SPA_POD_TYPE_INT, &info.output_node_id,
 | 
				
			||||||
			      SPA_POD_TYPE_INT, &info.output_port_id,
 | 
								      SPA_POD_TYPE_INT, &info.output_port_id,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -138,6 +138,8 @@ struct pw_client *pw_client_new(struct pw_core *core,
 | 
				
			||||||
	this->global = pw_core_add_global(core, NULL, parent, core->type.client, PW_VERSION_CLIENT,
 | 
						this->global = pw_core_add_global(core, NULL, parent, core->type.client, PW_VERSION_CLIENT,
 | 
				
			||||||
			   client_bind_func, this);
 | 
								   client_bind_func, this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this->info.id = this->global->id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return this;
 | 
						return this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -387,6 +387,8 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro
 | 
				
			||||||
					  PW_VERSION_CORE,
 | 
										  PW_VERSION_CORE,
 | 
				
			||||||
					  core_bind_func,
 | 
										  core_bind_func,
 | 
				
			||||||
					  this);
 | 
										  this);
 | 
				
			||||||
 | 
						this->info.id = this->global->id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return this;
 | 
						return this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      no_mem:
 | 
					      no_mem:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,6 +126,7 @@ struct pw_core_info *pw_core_info_update(struct pw_core_info *info,
 | 
				
			||||||
		if (info == NULL)
 | 
							if (info == NULL)
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						info->id = update->id;
 | 
				
			||||||
	info->change_mask = update->change_mask;
 | 
						info->change_mask = update->change_mask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (update->change_mask & PW_CORE_CHANGE_MASK_USER_NAME) {
 | 
						if (update->change_mask & PW_CORE_CHANGE_MASK_USER_NAME) {
 | 
				
			||||||
| 
						 | 
					@ -186,6 +187,7 @@ struct pw_node_info *pw_node_info_update(struct pw_node_info *info,
 | 
				
			||||||
		if (info == NULL)
 | 
							if (info == NULL)
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						info->id = update->id;
 | 
				
			||||||
	info->change_mask = update->change_mask;
 | 
						info->change_mask = update->change_mask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (update->change_mask & PW_NODE_CHANGE_MASK_NAME) {
 | 
						if (update->change_mask & PW_NODE_CHANGE_MASK_NAME) {
 | 
				
			||||||
| 
						 | 
					@ -282,6 +284,7 @@ struct pw_module_info *pw_module_info_update(struct pw_module_info *info,
 | 
				
			||||||
		if (info == NULL)
 | 
							if (info == NULL)
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						info->id = update->id;
 | 
				
			||||||
	info->change_mask = update->change_mask;
 | 
						info->change_mask = update->change_mask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (update->change_mask & PW_MODULE_CHANGE_MASK_NAME) {
 | 
						if (update->change_mask & PW_MODULE_CHANGE_MASK_NAME) {
 | 
				
			||||||
| 
						 | 
					@ -332,6 +335,7 @@ struct pw_client_info *pw_client_info_update(struct pw_client_info *info,
 | 
				
			||||||
		if (info == NULL)
 | 
							if (info == NULL)
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						info->id = update->id;
 | 
				
			||||||
	info->change_mask = update->change_mask;
 | 
						info->change_mask = update->change_mask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (update->change_mask & PW_CLIENT_CHANGE_MASK_PROPS) {
 | 
						if (update->change_mask & PW_CLIENT_CHANGE_MASK_PROPS) {
 | 
				
			||||||
| 
						 | 
					@ -360,6 +364,7 @@ struct pw_link_info *pw_link_info_update(struct pw_link_info *info,
 | 
				
			||||||
		if (info == NULL)
 | 
							if (info == NULL)
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						info->id = update->id;
 | 
				
			||||||
	info->change_mask = update->change_mask;
 | 
						info->change_mask = update->change_mask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (update->change_mask & PW_LINK_CHANGE_MASK_OUTPUT) {
 | 
						if (update->change_mask & PW_LINK_CHANGE_MASK_OUTPUT) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,6 +74,7 @@ const char * pw_link_state_as_string(enum pw_link_state state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**  The core information. Extra information can be added in later versions \memberof pw_introspect */
 | 
					/**  The core information. Extra information can be added in later versions \memberof pw_introspect */
 | 
				
			||||||
struct pw_core_info {
 | 
					struct pw_core_info {
 | 
				
			||||||
 | 
						uint32_t id;			/**< id of the global */
 | 
				
			||||||
#define PW_CORE_CHANGE_MASK_USER_NAME  (1 << 0)
 | 
					#define PW_CORE_CHANGE_MASK_USER_NAME  (1 << 0)
 | 
				
			||||||
#define PW_CORE_CHANGE_MASK_HOST_NAME  (1 << 1)
 | 
					#define PW_CORE_CHANGE_MASK_HOST_NAME  (1 << 1)
 | 
				
			||||||
#define PW_CORE_CHANGE_MASK_VERSION    (1 << 2)
 | 
					#define PW_CORE_CHANGE_MASK_VERSION    (1 << 2)
 | 
				
			||||||
| 
						 | 
					@ -100,6 +101,7 @@ void pw_core_info_free(struct pw_core_info *info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** The module information. Extra information can be added in later versions \memberof pw_introspect */
 | 
					/** The module information. Extra information can be added in later versions \memberof pw_introspect */
 | 
				
			||||||
struct pw_module_info {
 | 
					struct pw_module_info {
 | 
				
			||||||
 | 
						uint32_t id;		/**< id of the global */
 | 
				
			||||||
#define PW_MODULE_CHANGE_MASK_NAME	(1 << 0)
 | 
					#define PW_MODULE_CHANGE_MASK_NAME	(1 << 0)
 | 
				
			||||||
#define PW_MODULE_CHANGE_MASK_FILENAME	(1 << 1)
 | 
					#define PW_MODULE_CHANGE_MASK_FILENAME	(1 << 1)
 | 
				
			||||||
#define PW_MODULE_CHANGE_MASK_ARGS	(1 << 2)
 | 
					#define PW_MODULE_CHANGE_MASK_ARGS	(1 << 2)
 | 
				
			||||||
| 
						 | 
					@ -121,6 +123,7 @@ void pw_module_info_free(struct pw_module_info *info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** The client information. Extra information can be added in later versions \memberof pw_introspect */
 | 
					/** The client information. Extra information can be added in later versions \memberof pw_introspect */
 | 
				
			||||||
struct pw_client_info {
 | 
					struct pw_client_info {
 | 
				
			||||||
 | 
						uint32_t id;		/**< id of the global */
 | 
				
			||||||
#define PW_CLIENT_CHANGE_MASK_PROPS		(1 << 0)
 | 
					#define PW_CLIENT_CHANGE_MASK_PROPS		(1 << 0)
 | 
				
			||||||
	uint64_t change_mask;	/**< bitfield of changed fields since last call */
 | 
						uint64_t change_mask;	/**< bitfield of changed fields since last call */
 | 
				
			||||||
	struct spa_dict *props;	/**< extra properties */
 | 
						struct spa_dict *props;	/**< extra properties */
 | 
				
			||||||
| 
						 | 
					@ -137,6 +140,7 @@ void pw_client_info_free(struct pw_client_info *info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** The node information. Extra information can be added in later versions \memberof pw_introspect */
 | 
					/** The node information. Extra information can be added in later versions \memberof pw_introspect */
 | 
				
			||||||
struct pw_node_info {
 | 
					struct pw_node_info {
 | 
				
			||||||
 | 
						uint32_t id;				/**< id of the global */
 | 
				
			||||||
#define PW_NODE_CHANGE_MASK_NAME		(1 << 0)
 | 
					#define PW_NODE_CHANGE_MASK_NAME		(1 << 0)
 | 
				
			||||||
#define PW_NODE_CHANGE_MASK_INPUT_PORTS		(1 << 1)
 | 
					#define PW_NODE_CHANGE_MASK_INPUT_PORTS		(1 << 1)
 | 
				
			||||||
#define PW_NODE_CHANGE_MASK_INPUT_FORMATS	(1 << 2)
 | 
					#define PW_NODE_CHANGE_MASK_INPUT_FORMATS	(1 << 2)
 | 
				
			||||||
| 
						 | 
					@ -169,6 +173,7 @@ pw_node_info_free(struct pw_node_info *info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** The link information. Extra information can be added in later versions \memberof pw_introspect */
 | 
					/** The link information. Extra information can be added in later versions \memberof pw_introspect */
 | 
				
			||||||
struct pw_link_info {
 | 
					struct pw_link_info {
 | 
				
			||||||
 | 
						uint32_t id;			/**< id of the global */
 | 
				
			||||||
#define PW_LINK_CHANGE_MASK_OUTPUT		(1 << 0)
 | 
					#define PW_LINK_CHANGE_MASK_OUTPUT		(1 << 0)
 | 
				
			||||||
#define PW_LINK_CHANGE_MASK_INPUT		(1 << 1)
 | 
					#define PW_LINK_CHANGE_MASK_INPUT		(1 << 1)
 | 
				
			||||||
#define PW_LINK_CHANGE_MASK_FORMAT		(1 << 2)
 | 
					#define PW_LINK_CHANGE_MASK_FORMAT		(1 << 2)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1152,6 +1152,7 @@ struct pw_link *pw_link_new(struct pw_core *core,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->global = pw_core_add_global(core, NULL, parent, core->type.link, PW_VERSION_LINK,
 | 
						this->global = pw_core_add_global(core, NULL, parent, core->type.link, PW_VERSION_LINK,
 | 
				
			||||||
			   link_bind_func, this);
 | 
								   link_bind_func, this);
 | 
				
			||||||
 | 
						this->info.id = this->global->id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return this;
 | 
						return this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -222,6 +222,8 @@ struct pw_module *pw_module_load(struct pw_core *core, const char *name, const c
 | 
				
			||||||
					  core->type.module, PW_VERSION_MODULE,
 | 
										  core->type.module, PW_VERSION_MODULE,
 | 
				
			||||||
					  module_bind_func, this);
 | 
										  module_bind_func, this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this->info.id = this->global->id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!init_func(this, (char *) args))
 | 
						if (!init_func(this, (char *) args))
 | 
				
			||||||
		goto init_failed;
 | 
							goto init_failed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -353,6 +353,7 @@ void pw_node_register(struct pw_node *this)
 | 
				
			||||||
					  core->type.node, PW_VERSION_NODE,
 | 
										  core->type.node, PW_VERSION_NODE,
 | 
				
			||||||
					  node_bind_func, this);
 | 
										  node_bind_func, this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this->info.id = this->global->id;
 | 
				
			||||||
	impl->registered = true;
 | 
						impl->registered = true;
 | 
				
			||||||
	spa_hook_list_call(&this->listener_list, struct pw_node_events, initialized);
 | 
						spa_hook_list_call(&this->listener_list, struct pw_node_events, initialized);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue