mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
acp: add per device port list
Add the list of possible ports for a device. Pass the allowed devices in the routes. Store the active port in the device. Fixes enumeration of ports on devices with UCM.
This commit is contained in:
parent
5d90fe26f3
commit
374210c890
9 changed files with 64 additions and 22 deletions
|
|
@ -154,6 +154,7 @@ enum spa_param_route {
|
|||
* String : value)*)) */
|
||||
SPA_PARAM_ROUTE_profiles, /**< associated profile indexes (Array of Int) */
|
||||
SPA_PARAM_ROUTE_props, /**< properties SPA_TYPE_OBJECT_Props */
|
||||
SPA_PARAM_ROUTE_devices, /**< associated device indexes (Array of Int) */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -335,6 +335,7 @@ static const struct spa_type_info spa_type_param_route[] = {
|
|||
{ SPA_PARAM_ROUTE_info, SPA_TYPE_Struct, SPA_TYPE_INFO_PARAM_ROUTE_BASE "info", NULL, },
|
||||
{ SPA_PARAM_ROUTE_profiles, SPA_TYPE_Array, SPA_TYPE_INFO_PARAM_ROUTE_BASE "profiles", NULL, },
|
||||
{ SPA_PARAM_ROUTE_props, SPA_TYPE_Object, SPA_TYPE_INFO_PARAM_ROUTE_BASE "props", NULL, },
|
||||
{ SPA_PARAM_ROUTE_devices, SPA_TYPE_Array, SPA_TYPE_INFO_PARAM_ROUTE_BASE "devices", NULL, },
|
||||
{ 0, 0, NULL, NULL },
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -167,12 +167,6 @@ static void add_profiles(pa_card *impl)
|
|||
pa_hashmap_put(impl->profiles, cp->name, cp);
|
||||
}
|
||||
|
||||
PA_DYNARRAY_FOREACH(dev, &impl->out.devices, idx) {
|
||||
PA_HASHMAP_FOREACH(dp, dev->ports, state)
|
||||
pa_dynarray_append(&dev->port_array, dp);
|
||||
dev->device.ports = dev->port_array.array.data;
|
||||
dev->device.n_ports = pa_dynarray_size(&dev->port_array);
|
||||
}
|
||||
pa_dynarray_init(&impl->out.ports, NULL);
|
||||
n_ports = 0;
|
||||
PA_HASHMAP_FOREACH(dp, impl->ports, state) {
|
||||
|
|
@ -180,6 +174,7 @@ static void add_profiles(pa_card *impl)
|
|||
dp->card = impl;
|
||||
dp->port.index = n_ports++;
|
||||
pa_dynarray_init(&dp->prof, NULL);
|
||||
pa_dynarray_init(&dp->devices, NULL);
|
||||
n_profiles = 0;
|
||||
PA_HASHMAP_FOREACH(cp, dp->profiles, state2) {
|
||||
pa_dynarray_append(&dp->prof, cp);
|
||||
|
|
@ -192,6 +187,18 @@ static void add_profiles(pa_card *impl)
|
|||
pa_proplist_as_dict(dp->proplist, &dp->port.props);
|
||||
pa_dynarray_append(&impl->out.ports, dp);
|
||||
}
|
||||
PA_DYNARRAY_FOREACH(dev, &impl->out.devices, idx) {
|
||||
PA_HASHMAP_FOREACH(dp, dev->ports, state) {
|
||||
pa_dynarray_append(&dev->port_array, dp);
|
||||
pa_dynarray_append(&dp->devices, dev);
|
||||
}
|
||||
dev->device.ports = dev->port_array.array.data;
|
||||
dev->device.n_ports = pa_dynarray_size(&dev->port_array);
|
||||
}
|
||||
PA_HASHMAP_FOREACH(dp, impl->ports, state) {
|
||||
dp->port.devices = dp->devices.array.data;
|
||||
dp->port.n_devices = pa_dynarray_size(&dp->devices);
|
||||
}
|
||||
|
||||
pa_hashmap_sort(impl->profiles, compare_profile);
|
||||
|
||||
|
|
|
|||
|
|
@ -153,6 +153,9 @@ struct acp_port {
|
|||
|
||||
uint32_t n_profiles;
|
||||
struct acp_card_profile **profiles;
|
||||
|
||||
uint32_t n_devices;
|
||||
struct acp_device **devices;
|
||||
};
|
||||
|
||||
struct acp_device {
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ struct pa_device_port {
|
|||
pa_hashmap *profiles;
|
||||
pa_dynarray prof;
|
||||
|
||||
pa_dynarray devices;
|
||||
|
||||
void (*impl_free)(struct pa_device_port *port);
|
||||
void *user_data;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -380,6 +380,11 @@ static struct spa_pod *build_route(struct spa_pod_builder *b, uint32_t id,
|
|||
|
||||
spa_pod_builder_pop(b, &f[1]);
|
||||
}
|
||||
spa_pod_builder_prop(b, SPA_PARAM_ROUTE_devices, 0);
|
||||
spa_pod_builder_push_array(b, &f[1]);
|
||||
for (i = 0; i < p->n_devices; i++)
|
||||
spa_pod_builder_int(b, p->devices[i]->index);
|
||||
spa_pod_builder_pop(b, &f[1]);
|
||||
return spa_pod_builder_pop(b, &f[0]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue