mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	node: pass struct to info callback to make it more extensible
This commit is contained in:
		
							parent
							
								
									bb2b15a5fb
								
							
						
					
					
						commit
						04f1046113
					
				
					 9 changed files with 78 additions and 18 deletions
				
			
		| 
						 | 
					@ -41,6 +41,21 @@ struct spa_node;
 | 
				
			||||||
#include <spa/node/event.h>
 | 
					#include <spa/node/event.h>
 | 
				
			||||||
#include <spa/node/command.h>
 | 
					#include <spa/node/command.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Node information structure
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Contains the basic node information.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					struct spa_node_info {
 | 
				
			||||||
 | 
					#define SPA_VERSION_NODE_INFO 0
 | 
				
			||||||
 | 
						uint32_t version;
 | 
				
			||||||
 | 
					#define SPA_NODE_CHANGE_MASK_PROPS		(1<<0)
 | 
				
			||||||
 | 
						uint64_t change_mask;
 | 
				
			||||||
 | 
						struct spa_dict *props;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define SPA_NODE_INFO_INIT()	(struct spa_node_info) { SPA_VERSION_NODE_INFO, }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Port information structure
 | 
					 * Port information structure
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -72,7 +87,7 @@ struct spa_node_callbacks {
 | 
				
			||||||
	uint32_t version;	/**< version of this structure */
 | 
						uint32_t version;	/**< version of this structure */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Emited when info changes */
 | 
						/** Emited when info changes */
 | 
				
			||||||
	void (*info) (void *data, const struct spa_dict *info);
 | 
						void (*info) (void *data, const struct spa_node_info *info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Emited when an async operation completed.
 | 
						/** Emited when an async operation completed.
 | 
				
			||||||
	 *
 | 
						 *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -257,8 +257,15 @@ impl_node_set_callbacks(struct spa_node *node,
 | 
				
			||||||
	this->callbacks_data = data;
 | 
						this->callbacks_data = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (callbacks) {
 | 
						if (callbacks) {
 | 
				
			||||||
		if (callbacks->info)
 | 
							if (callbacks->info) {
 | 
				
			||||||
			callbacks->info(data, &SPA_DICT_INIT_ARRAY(node_info_items));
 | 
								struct spa_node_info info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								info = SPA_NODE_INFO_INIT();
 | 
				
			||||||
 | 
								info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
 | 
				
			||||||
 | 
								info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								callbacks->info(data, &info);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -258,8 +258,15 @@ impl_node_set_callbacks(struct spa_node *node,
 | 
				
			||||||
	this->callbacks_data = data;
 | 
						this->callbacks_data = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (callbacks) {
 | 
						if (callbacks) {
 | 
				
			||||||
		if (callbacks->info)
 | 
							if (callbacks->info) {
 | 
				
			||||||
			callbacks->info(data, &SPA_DICT_INIT_ARRAY(node_info_items));
 | 
								struct spa_node_info info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								info = SPA_NODE_INFO_INIT();
 | 
				
			||||||
 | 
								info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
 | 
				
			||||||
 | 
								info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								callbacks->info(data, &info);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -463,8 +463,15 @@ impl_node_set_callbacks(struct spa_node *node,
 | 
				
			||||||
	this->callbacks_data = data;
 | 
						this->callbacks_data = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (callbacks) {
 | 
						if (callbacks) {
 | 
				
			||||||
		if (callbacks->info)
 | 
							if (callbacks->info) {
 | 
				
			||||||
			callbacks->info(data, &SPA_DICT_INIT_ARRAY(node_info_items));
 | 
								struct spa_node_info info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								info = SPA_NODE_INFO_INIT();
 | 
				
			||||||
 | 
								info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
 | 
				
			||||||
 | 
								info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								callbacks->info(data, &info);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -861,8 +861,15 @@ impl_node_set_callbacks(struct spa_node *node,
 | 
				
			||||||
	this->callbacks_data = data;
 | 
						this->callbacks_data = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (callbacks) {
 | 
						if (callbacks) {
 | 
				
			||||||
		if (callbacks->info)
 | 
							if (callbacks->info) {
 | 
				
			||||||
			callbacks->info(data, &SPA_DICT_INIT_ARRAY(node_info_items));
 | 
								struct spa_node_info info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								info = SPA_NODE_INFO_INIT();
 | 
				
			||||||
 | 
								info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
 | 
				
			||||||
 | 
								info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								callbacks->info(data, &info);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -346,8 +346,15 @@ static int impl_node_set_callbacks(struct spa_node *node,
 | 
				
			||||||
	this->callbacks_data = data;
 | 
						this->callbacks_data = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (callbacks) {
 | 
						if (callbacks) {
 | 
				
			||||||
		if (callbacks->info)
 | 
							if (callbacks->info) {
 | 
				
			||||||
			callbacks->info(data, &SPA_DICT_INIT_ARRAY(info_items));
 | 
								struct spa_node_info info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								info = SPA_NODE_INFO_INIT();
 | 
				
			||||||
 | 
								info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
 | 
				
			||||||
 | 
								info.props = &SPA_DICT_INIT_ARRAY(info_items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								callbacks->info(data, &info);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -407,8 +407,15 @@ impl_node_set_callbacks(struct spa_node *node,
 | 
				
			||||||
	this->callbacks_data = data;
 | 
						this->callbacks_data = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (callbacks) {
 | 
						if (callbacks) {
 | 
				
			||||||
		if (callbacks->info)
 | 
							if (callbacks->info) {
 | 
				
			||||||
			callbacks->info(data, &SPA_DICT_INIT_ARRAY(node_info_items));
 | 
								struct spa_node_info info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								info = SPA_NODE_INFO_INIT();
 | 
				
			||||||
 | 
								info.change_mask = SPA_NODE_CHANGE_MASK_PROPS;
 | 
				
			||||||
 | 
								info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								callbacks->info(data, &info);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,10 +135,12 @@ inspect_port_params(struct data *data, struct spa_node *node,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void node_info(void *data, const struct spa_dict *info)
 | 
					static void node_info(void *data, const struct spa_node_info *info)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						if (info->change_mask & SPA_NODE_CHANGE_MASK_PROPS) {
 | 
				
			||||||
		printf("node properties:\n");
 | 
							printf("node properties:\n");
 | 
				
			||||||
	spa_debug_dict(2, info);
 | 
							spa_debug_dict(2, info->props);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct spa_node_callbacks node_callbacks =
 | 
					static const struct spa_node_callbacks node_callbacks =
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -874,10 +874,11 @@ int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict)
 | 
				
			||||||
	return changed;
 | 
						return changed;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void node_info(void *data, const struct spa_dict *info)
 | 
					static void node_info(void *data, const struct spa_node_info *info)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct pw_node *node = data;
 | 
						struct pw_node *node = data;
 | 
				
			||||||
	pw_node_update_properties(node, info);
 | 
						if (info->change_mask & SPA_NODE_CHANGE_MASK_PROPS)
 | 
				
			||||||
 | 
							pw_node_update_properties(node, info->props);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void node_done(void *data, int seq, int res)
 | 
					static void node_done(void *data, int seq, int res)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue