mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	node: allow for setting driver root
The driver root is the graph that should be run when a remote driver starts the graph and can be different from the node itself when it's part of a subgraph like in client-stream.
This commit is contained in:
		
							parent
							
								
									32afd8d228
								
							
						
					
					
						commit
						0bc6ba8559
					
				
					 3 changed files with 11 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -241,7 +241,7 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
 | 
			
		|||
 | 
			
		||||
static int impl_node_set_io(struct spa_node *node, uint32_t id, void *data, size_t size)
 | 
			
		||||
{
 | 
			
		||||
	return -ENOTSUP;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
 | 
			
		||||
| 
						 | 
				
			
			@ -980,7 +980,7 @@ static void client_node_initialized(void *data)
 | 
			
		|||
		exclusive = false;
 | 
			
		||||
 | 
			
		||||
	spa_graph_node_add(impl->client_node->node->rt.driver, &impl->client_node->node->rt.root);
 | 
			
		||||
	impl->client_node->node->driver_node = impl->this.node;
 | 
			
		||||
	impl->client_node->node->driver_root = impl->this.node;
 | 
			
		||||
 | 
			
		||||
	impl->client_port = pw_node_find_port(impl->client_node->node, impl->direction, 0);
 | 
			
		||||
	if (impl->client_port == NULL)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -686,6 +686,7 @@ struct pw_node *pw_node_new(struct pw_core *core,
 | 
			
		|||
	check_properties(this);
 | 
			
		||||
 | 
			
		||||
	this->driver_node = this;
 | 
			
		||||
	this->driver_root = this;
 | 
			
		||||
	spa_list_append(&this->driver_list, &this->driver_link);
 | 
			
		||||
 | 
			
		||||
	return this;
 | 
			
		||||
| 
						 | 
				
			
			@ -777,14 +778,15 @@ static void node_event(void *data, struct spa_event *event)
 | 
			
		|||
 | 
			
		||||
static void node_process(void *data, int status)
 | 
			
		||||
{
 | 
			
		||||
	struct pw_node *node = data, *driver;
 | 
			
		||||
	struct pw_node *node = data, *driver, *root;
 | 
			
		||||
	struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
 | 
			
		||||
	bool is_driving = false;
 | 
			
		||||
 | 
			
		||||
	driver = node->driver_node;
 | 
			
		||||
	root = node->driver_root ? node->driver_root : driver;
 | 
			
		||||
 | 
			
		||||
	pw_log_trace("node %p: process driver:%d exported:%d %p", node,
 | 
			
		||||
			node->driver, node->exported, driver->rt.driver);
 | 
			
		||||
	pw_log_trace("node %p: process driver:%d exported:%d %p %p", node,
 | 
			
		||||
			node->driver, node->exported, driver, driver->rt.driver);
 | 
			
		||||
 | 
			
		||||
	if (node->driver) {
 | 
			
		||||
		if (driver == node)
 | 
			
		||||
| 
						 | 
				
			
			@ -793,11 +795,11 @@ static void node_process(void *data, int status)
 | 
			
		|||
			*node->rt.position = *driver->rt.position;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (is_driving && (driver->rt.driver->state->pending == 0 || !node->remote)) {
 | 
			
		||||
	if (is_driving && (root->rt.driver->state->pending == 0 || !node->remote)) {
 | 
			
		||||
		struct timespec ts;
 | 
			
		||||
		struct spa_io_position *q = node->rt.position;
 | 
			
		||||
 | 
			
		||||
		if (driver->rt.driver->state->pending != 0) {
 | 
			
		||||
		if (root->rt.driver->state->pending != 0) {
 | 
			
		||||
			pw_log_warn("node %p: graph not finished", node);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -812,7 +814,7 @@ static void node_process(void *data, int status)
 | 
			
		|||
				q->clock.nsec, q->clock.rate.num, q->clock.rate.denom,
 | 
			
		||||
				q->clock.position, q->clock.delay, q->size);
 | 
			
		||||
 | 
			
		||||
		spa_graph_run(driver->rt.driver);
 | 
			
		||||
		spa_graph_run(root->rt.driver);
 | 
			
		||||
 | 
			
		||||
		impl->next_position += q->size;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -307,6 +307,7 @@ struct pw_node {
 | 
			
		|||
					  *  is selected to drive the graph */
 | 
			
		||||
 | 
			
		||||
	struct pw_node *driver_node;
 | 
			
		||||
	struct pw_node *driver_root;
 | 
			
		||||
	struct spa_list driver_list;
 | 
			
		||||
	struct spa_list driver_link;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue