mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: alsa: do not allow setting Route that is not in current profile
When setting Route param, check that the route actually is part of the active profile. Also, check that the device given corresponds to the given route, before setting properties. acp_device_set_port() also checks this, but we shouldn't allow updating properties of Routes in non-active profiles. Setting ports or applying props on devices not part of the profile can do unexpected things e.g. alter mixer settings.
This commit is contained in:
parent
7d8657b7f4
commit
b9e130fd8c
1 changed files with 28 additions and 0 deletions
|
|
@ -761,6 +761,32 @@ static uint32_t find_route_by_name(struct acp_card *card, const char *name)
|
|||
return SPA_ID_INVALID;
|
||||
}
|
||||
|
||||
static bool check_active_profile_port(struct impl *this, uint32_t device, uint32_t port_index)
|
||||
{
|
||||
struct acp_port *p;
|
||||
uint32_t i;
|
||||
|
||||
if (port_index >= this->card->n_ports)
|
||||
return false;
|
||||
p = this->card->ports[port_index];
|
||||
|
||||
/* Port must be in active profile */
|
||||
for (i = 0; i < p->n_profiles; i++)
|
||||
if (p->profiles[i]->index == this->card->active_profile_index)
|
||||
break;
|
||||
if (i == p->n_profiles)
|
||||
return false;
|
||||
|
||||
/* Port must correspond to the device */
|
||||
for (i = 0; i< p->n_devices; i++)
|
||||
if (p->devices[i]->index == device)
|
||||
break;
|
||||
if (i == p->n_devices)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int impl_set_param(void *object,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod *param)
|
||||
|
|
@ -838,6 +864,8 @@ static int impl_set_param(void *object,
|
|||
idx = find_route_by_name(this->card, name);
|
||||
if (idx == SPA_ID_INVALID)
|
||||
return -EINVAL;
|
||||
if (!check_active_profile_port(this, device, idx))
|
||||
return -EINVAL;
|
||||
|
||||
acp_device_set_port(dev, idx, save ? ACP_PORT_SAVE : 0);
|
||||
if (props)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue