mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	filter-chain: support notify to control links as well
If we can't find data ports to link, try to find notify/control ports when making a link. When applying the link, place the output of the notify as the control data.
This commit is contained in:
		
							parent
							
								
									c671c46b87
								
							
						
					
					
						commit
						bddfc8c46e
					
				
					 1 changed files with 29 additions and 9 deletions
				
			
		| 
						 | 
					@ -1603,7 +1603,7 @@ static int parse_link(struct graph *graph, struct spa_json *json)
 | 
				
			||||||
	char output[256] = "";
 | 
						char output[256] = "";
 | 
				
			||||||
	char input[256] = "";
 | 
						char input[256] = "";
 | 
				
			||||||
	const char *val;
 | 
						const char *val;
 | 
				
			||||||
	struct node *def_node;
 | 
						struct node *def_in_node, *def_out_node;
 | 
				
			||||||
	struct port *in_port, *out_port;
 | 
						struct port *in_port, *out_port;
 | 
				
			||||||
	struct link *link;
 | 
						struct link *link;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1628,16 +1628,25 @@ static int parse_link(struct graph *graph, struct spa_json *json)
 | 
				
			||||||
		else if (spa_json_next(json, &val) < 0)
 | 
							else if (spa_json_next(json, &val) < 0)
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	def_node = spa_list_first(&graph->node_list, struct node, link);
 | 
						def_out_node = spa_list_first(&graph->node_list, struct node, link);
 | 
				
			||||||
	if ((out_port = find_port(def_node, output, FC_PORT_OUTPUT)) == NULL) {
 | 
						def_in_node = spa_list_last(&graph->node_list, struct node, link);
 | 
				
			||||||
		pw_log_error("unknown output port %s", output);
 | 
					
 | 
				
			||||||
		return -ENOENT;
 | 
						out_port = find_port(def_out_node, output, FC_PORT_OUTPUT);
 | 
				
			||||||
 | 
						in_port = find_port(def_in_node, input, FC_PORT_INPUT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (out_port == NULL && out_port == NULL) {
 | 
				
			||||||
 | 
							/* try control ports */
 | 
				
			||||||
 | 
							out_port = find_port(def_out_node, output, FC_PORT_OUTPUT | FC_PORT_CONTROL);
 | 
				
			||||||
 | 
							in_port = find_port(def_in_node, input, FC_PORT_INPUT | FC_PORT_CONTROL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	def_node = spa_list_last(&graph->node_list, struct node, link);
 | 
						if (in_port == NULL || out_port == NULL) {
 | 
				
			||||||
	if ((in_port = find_port(def_node, input, FC_PORT_INPUT)) == NULL) {
 | 
							if (out_port == NULL)
 | 
				
			||||||
 | 
								pw_log_error("unknown output port %s", output);
 | 
				
			||||||
 | 
							if (in_port == NULL)
 | 
				
			||||||
			pw_log_error("unknown input port %s", input);
 | 
								pw_log_error("unknown input port %s", input);
 | 
				
			||||||
		return -ENOENT;
 | 
							return -ENOENT;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (in_port->n_links > 0) {
 | 
						if (in_port->n_links > 0) {
 | 
				
			||||||
		pw_log_info("Can't have more than 1 link to %s, use a mixer", input);
 | 
							pw_log_info("Can't have more than 1 link to %s, use a mixer", input);
 | 
				
			||||||
		return -ENOTSUP;
 | 
							return -ENOTSUP;
 | 
				
			||||||
| 
						 | 
					@ -1935,9 +1944,20 @@ static int graph_instantiate(struct graph *graph)
 | 
				
			||||||
			for (j = 0; j < desc->n_control; j++) {
 | 
								for (j = 0; j < desc->n_control; j++) {
 | 
				
			||||||
				port = &node->control_port[j];
 | 
									port = &node->control_port[j];
 | 
				
			||||||
				d->connect_port(node->hndl[i], port->p, &port->control_data);
 | 
									d->connect_port(node->hndl[i], port->p, &port->control_data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									spa_list_for_each(link, &port->link_list, input_link) {
 | 
				
			||||||
 | 
										struct port *peer = link->output;
 | 
				
			||||||
 | 
										pw_log_info("connect control port %s[%d]:%s %p",
 | 
				
			||||||
 | 
												node->name, i, d->ports[port->p].name,
 | 
				
			||||||
 | 
												&peer->control_data);
 | 
				
			||||||
 | 
										d->connect_port(node->hndl[i], port->p, &peer->control_data);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			for (j = 0; j < desc->n_notify; j++) {
 | 
								for (j = 0; j < desc->n_notify; j++) {
 | 
				
			||||||
				port = &node->notify_port[j];
 | 
									port = &node->notify_port[j];
 | 
				
			||||||
 | 
									pw_log_info("connect notify port %s[%d]:%s %p",
 | 
				
			||||||
 | 
											node->name, i, d->ports[port->p].name,
 | 
				
			||||||
 | 
											&port->control_data);
 | 
				
			||||||
				d->connect_port(node->hndl[i], port->p, &port->control_data);
 | 
									d->connect_port(node->hndl[i], port->p, &port->control_data);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (d->activate)
 | 
								if (d->activate)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue