mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pw-link: Improve error message if ports are not found
In a scenario where pw-link is called without a session manager running, the output port on a node will not exist. In such a case, we broke out of the for loop with all_links_exist set to true and returning EEXIST. The return of EEXIST gives a confusing error message. Fix this.
This commit is contained in:
		
							parent
							
								
									4574678424
								
							
						
					
					
						commit
						05a133f5b5
					
				
					 1 changed files with 13 additions and 2 deletions
				
			
		| 
						 | 
					@ -400,8 +400,16 @@ static int do_link_ports(struct data *data)
 | 
				
			||||||
			struct object *port_out = find_node_port(data, out_node, PW_DIRECTION_OUTPUT, port_id);
 | 
								struct object *port_out = find_node_port(data, out_node, PW_DIRECTION_OUTPUT, port_id);
 | 
				
			||||||
			struct object *port_in = find_node_port(data, in_node, PW_DIRECTION_INPUT, port_id);
 | 
								struct object *port_in = find_node_port(data, in_node, PW_DIRECTION_INPUT, port_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (!port_out || !port_in)
 | 
								if (!port_out && !port_in) {
 | 
				
			||||||
				break;
 | 
									fprintf(stderr, "Input & output port do not exist\n");
 | 
				
			||||||
 | 
									goto no_port;
 | 
				
			||||||
 | 
								} else if (!port_in) {
 | 
				
			||||||
 | 
									fprintf(stderr, "Input port does not exist\n");
 | 
				
			||||||
 | 
									goto no_port;
 | 
				
			||||||
 | 
								} else if (!port_out) {
 | 
				
			||||||
 | 
									fprintf(stderr, "Output port does not exist\n");
 | 
				
			||||||
 | 
									goto no_port;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			pw_properties_setf(data->props, PW_KEY_LINK_OUTPUT_PORT, "%u", port_out->id);
 | 
								pw_properties_setf(data->props, PW_KEY_LINK_OUTPUT_PORT, "%u", port_out->id);
 | 
				
			||||||
			pw_properties_setf(data->props, PW_KEY_LINK_INPUT_PORT, "%u", port_in->id);
 | 
								pw_properties_setf(data->props, PW_KEY_LINK_INPUT_PORT, "%u", port_in->id);
 | 
				
			||||||
| 
						 | 
					@ -422,6 +430,9 @@ static int do_link_ports(struct data *data)
 | 
				
			||||||
	pw_properties_setf(data->props, PW_KEY_LINK_INPUT_PORT, "%u", in_port);
 | 
						pw_properties_setf(data->props, PW_KEY_LINK_INPUT_PORT, "%u", in_port);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return create_link(data);
 | 
						return create_link(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					no_port:
 | 
				
			||||||
 | 
						return -ENOENT;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int do_unlink_ports(struct data *data)
 | 
					static int do_unlink_ports(struct data *data)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue