mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04: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,8 +1025,10 @@ static int device_enable(pa_card *impl, pa_alsa_mapping *mapping, pa_alsa_device
|
|||
find_mixer(impl, dev, NULL, ignore_dB);
|
||||
|
||||
port_index = acp_device_find_best_port_index(&dev->device, NULL);
|
||||
|
||||
dev->active_port = (pa_device_port*)impl->card.ports[port_index];
|
||||
if (port_index == ACP_INVALID_INDEX)
|
||||
dev->active_port = NULL;
|
||||
else
|
||||
dev->active_port = (pa_device_port*)impl->card.ports[port_index];
|
||||
if (dev->active_port)
|
||||
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;
|
||||
if (best == ACP_INVALID_INDEX)
|
||||
best = 0;
|
||||
return ports[best]->index;
|
||||
if (best < dev->n_ports)
|
||||
return ports[best]->index;
|
||||
else
|
||||
return ACP_INVALID_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