mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	link: implement passive links again
Check if a driver is only connected to other nodes with passive links, if that's the case, set the driver and all followers in IDLE.
This commit is contained in:
		
							parent
							
								
									2a11e66417
								
							
						
					
					
						commit
						16d61e98e8
					
				
					 3 changed files with 16 additions and 4 deletions
				
			
		| 
						 | 
					@ -798,6 +798,7 @@ static int collect_nodes(struct pw_impl_node *driver)
 | 
				
			||||||
	spa_list_init(&queue);
 | 
						spa_list_init(&queue);
 | 
				
			||||||
	spa_list_append(&queue, &driver->sort_link);
 | 
						spa_list_append(&queue, &driver->sort_link);
 | 
				
			||||||
	driver->visited = true;
 | 
						driver->visited = true;
 | 
				
			||||||
 | 
						driver->passive = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_list_consume(n, &queue, sort_link) {
 | 
						spa_list_consume(n, &queue, sort_link) {
 | 
				
			||||||
		spa_list_remove(&n->sort_link);
 | 
							spa_list_remove(&n->sort_link);
 | 
				
			||||||
| 
						 | 
					@ -806,6 +807,8 @@ static int collect_nodes(struct pw_impl_node *driver)
 | 
				
			||||||
		spa_list_for_each(p, &n->input_ports, link) {
 | 
							spa_list_for_each(p, &n->input_ports, link) {
 | 
				
			||||||
			spa_list_for_each(l, &p->links, input_link) {
 | 
								spa_list_for_each(l, &p->links, input_link) {
 | 
				
			||||||
				t = l->output->node;
 | 
									t = l->output->node;
 | 
				
			||||||
 | 
									if (!l->passive)
 | 
				
			||||||
 | 
										driver->passive = false;
 | 
				
			||||||
				if (l->prepared && !t->visited && t->active) {
 | 
									if (l->prepared && !t->visited && t->active) {
 | 
				
			||||||
					t->visited = true;
 | 
										t->visited = true;
 | 
				
			||||||
					spa_list_append(&queue, &t->sort_link);
 | 
										spa_list_append(&queue, &t->sort_link);
 | 
				
			||||||
| 
						 | 
					@ -815,6 +818,8 @@ static int collect_nodes(struct pw_impl_node *driver)
 | 
				
			||||||
		spa_list_for_each(p, &n->output_ports, link) {
 | 
							spa_list_for_each(p, &n->output_ports, link) {
 | 
				
			||||||
			spa_list_for_each(l, &p->links, output_link) {
 | 
								spa_list_for_each(l, &p->links, output_link) {
 | 
				
			||||||
				t = l->input->node;
 | 
									t = l->input->node;
 | 
				
			||||||
 | 
									if (!l->passive)
 | 
				
			||||||
 | 
										driver->passive = false;
 | 
				
			||||||
				if (l->prepared && !t->visited && t->active) {
 | 
									if (l->prepared && !t->visited && t->active) {
 | 
				
			||||||
					t->visited = true;
 | 
										t->visited = true;
 | 
				
			||||||
					spa_list_append(&queue, &t->sort_link);
 | 
										spa_list_append(&queue, &t->sort_link);
 | 
				
			||||||
| 
						 | 
					@ -852,7 +857,7 @@ int pw_context_recalc_graph(struct pw_context *context, const char *reason)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* from now on we are only interested in active master nodes.
 | 
							/* from now on we are only interested in active master nodes.
 | 
				
			||||||
		 * We're going to see if there are active followers. */
 | 
							 * We're going to see if there are active followers. */
 | 
				
			||||||
		if (!n->master || !n->active)
 | 
							if (!n->master || !n->active || n->passive)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* first active master node is fallback */
 | 
							/* first active master node is fallback */
 | 
				
			||||||
| 
						 | 
					@ -912,7 +917,7 @@ int pw_context_recalc_graph(struct pw_context *context, const char *reason)
 | 
				
			||||||
			if (s == n)
 | 
								if (s == n)
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			if (s->active)
 | 
								if (s->active)
 | 
				
			||||||
				running = true;
 | 
									running = !n->passive;
 | 
				
			||||||
			if (s->quantum_size > 0) {
 | 
								if (s->quantum_size > 0) {
 | 
				
			||||||
				if (min_quantum == 0 || s->quantum_size < min_quantum)
 | 
									if (min_quantum == 0 || s->quantum_size < min_quantum)
 | 
				
			||||||
					min_quantum = s->quantum_size;
 | 
										min_quantum = s->quantum_size;
 | 
				
			||||||
| 
						 | 
					@ -935,8 +940,8 @@ int pw_context_recalc_graph(struct pw_context *context, const char *reason)
 | 
				
			||||||
			n->rt.position->clock.duration = quantum;
 | 
								n->rt.position->clock.duration = quantum;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		pw_log_debug(NAME" %p: master %p running:%d quantum:%u '%s'", context, n,
 | 
							pw_log_debug(NAME" %p: master %p running:%d passive:%d quantum:%u '%s'", context, n,
 | 
				
			||||||
				running, quantum, n->name);
 | 
									running, n->passive, quantum, n->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		spa_list_for_each(s, &n->follower_list, follower_link) {
 | 
							spa_list_for_each(s, &n->follower_list, follower_link) {
 | 
				
			||||||
			if (s == n)
 | 
								if (s == n)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -995,6 +995,7 @@ struct pw_impl_link *pw_context_create_link(struct pw_context *context,
 | 
				
			||||||
	struct impl *impl;
 | 
						struct impl *impl;
 | 
				
			||||||
	struct pw_impl_link *this;
 | 
						struct pw_impl_link *this;
 | 
				
			||||||
	struct pw_impl_node *input_node, *output_node;
 | 
						struct pw_impl_node *input_node, *output_node;
 | 
				
			||||||
 | 
						const char *str;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (output == input)
 | 
						if (output == input)
 | 
				
			||||||
| 
						 | 
					@ -1038,6 +1039,10 @@ struct pw_impl_link *pw_context_create_link(struct pw_context *context,
 | 
				
			||||||
	this->output = output;
 | 
						this->output = output;
 | 
				
			||||||
	this->input = input;
 | 
						this->input = input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* passive means that this link does not make the nodes active */
 | 
				
			||||||
 | 
						if ((str = pw_properties_get(properties, PW_KEY_LINK_PASSIVE)) != NULL)
 | 
				
			||||||
 | 
							this->passive = pw_properties_parse_bool(str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_hook_list_init(&this->listener_list);
 | 
						spa_hook_list_init(&this->listener_list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	impl->format_filter = format_filter;
 | 
						impl->format_filter = format_filter;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -548,6 +548,7 @@ struct pw_impl_node {
 | 
				
			||||||
					  *  is selected to drive the graph */
 | 
										  *  is selected to drive the graph */
 | 
				
			||||||
	unsigned int visited:1;		/**< for sorting */
 | 
						unsigned int visited:1;		/**< for sorting */
 | 
				
			||||||
	unsigned int want_driver:1;	/**< this node wants to be assigned to a driver */
 | 
						unsigned int want_driver:1;	/**< this node wants to be assigned to a driver */
 | 
				
			||||||
 | 
						unsigned int passive:1;		/**< driver graph only has passive links */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint32_t port_user_data_size;	/**< extra size for port user data */
 | 
						uint32_t port_user_data_size;	/**< extra size for port user data */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -753,6 +754,7 @@ struct pw_impl_link {
 | 
				
			||||||
	unsigned int feedback:1;
 | 
						unsigned int feedback:1;
 | 
				
			||||||
	unsigned int preparing:1;
 | 
						unsigned int preparing:1;
 | 
				
			||||||
	unsigned int prepared:1;
 | 
						unsigned int prepared:1;
 | 
				
			||||||
 | 
						unsigned int passive:1;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define pw_resource_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_resource_events, m, v, ##__VA_ARGS__)
 | 
					#define pw_resource_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_resource_events, m, v, ##__VA_ARGS__)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue