mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	acp: handle devices with no ports
Make sure we don't crash when there are no ports on a device. See #321
This commit is contained in:
		
							parent
							
								
									5c048500cc
								
							
						
					
					
						commit
						e7585bd7b8
					
				
					 1 changed files with 8 additions and 3 deletions
				
			
		| 
						 | 
					@ -1025,7 +1025,9 @@ static int device_enable(pa_card *impl, pa_alsa_mapping *mapping, pa_alsa_device
 | 
				
			||||||
	find_mixer(impl, dev, NULL, ignore_dB);
 | 
						find_mixer(impl, dev, NULL, ignore_dB);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port_index = acp_device_find_best_port_index(&dev->device, NULL);
 | 
						port_index = acp_device_find_best_port_index(&dev->device, NULL);
 | 
				
			||||||
 | 
						if (port_index == ACP_INVALID_INDEX)
 | 
				
			||||||
 | 
							dev->active_port = NULL;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
		dev->active_port = (pa_device_port*)impl->card.ports[port_index];
 | 
							dev->active_port = (pa_device_port*)impl->card.ports[port_index];
 | 
				
			||||||
	if (dev->active_port)
 | 
						if (dev->active_port)
 | 
				
			||||||
		dev->active_port->port.flags |= ACP_PORT_ACTIVE;
 | 
							dev->active_port->port.flags |= ACP_PORT_ACTIVE;
 | 
				
			||||||
| 
						 | 
					@ -1382,7 +1384,10 @@ uint32_t acp_device_find_best_port_index(struct acp_device *dev, const char *nam
 | 
				
			||||||
		best = best3;
 | 
							best = best3;
 | 
				
			||||||
	if (best == ACP_INVALID_INDEX)
 | 
						if (best == ACP_INVALID_INDEX)
 | 
				
			||||||
		best = 0;
 | 
							best = 0;
 | 
				
			||||||
 | 
						if (best < dev->n_ports)
 | 
				
			||||||
		return ports[best]->index;
 | 
							return ports[best]->index;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							return ACP_INVALID_INDEX;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int acp_device_set_port(struct acp_device *dev, uint32_t port_index)
 | 
					int acp_device_set_port(struct acp_device *dev, uint32_t port_index)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue