From ab5059cd07a463b6f76a7ecb1148513a6e883c27 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 29 Jan 2021 15:27:25 +0100 Subject: [PATCH] alsa: add array of devices in EnumProfile So that we can enumerate the possible Routes per device for this profile as well. --- spa/include/spa/param/param.h | 5 ++++- spa/plugins/alsa/alsa-acp-device.c | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/spa/include/spa/param/param.h b/spa/include/spa/param/param.h index 105d63512..f1b740efe 100644 --- a/spa/include/spa/param/param.h +++ b/spa/include/spa/param/param.h @@ -115,7 +115,10 @@ enum spa_param_profile { * Int : number of items following * Struct( * String : class name (eg. "Audio/Source"), - * Int : number of nodes)*)) */ + * Int : number of nodes + * String : property (eg. "card.profile.devices"), + * Array of Int: device indexes + * )*)) */ }; enum spa_param_port_config_mode { diff --git a/spa/plugins/alsa/alsa-acp-device.c b/spa/plugins/alsa/alsa-acp-device.c index 9606d5777..0db4eae63 100644 --- a/spa/plugins/alsa/alsa-acp-device.c +++ b/spa/plugins/alsa/alsa-acp-device.c @@ -298,21 +298,25 @@ static struct spa_pod *build_profile(struct spa_pod_builder *b, uint32_t id, { struct spa_pod_frame f[2]; uint32_t i, n_classes, n_capture = 0, n_playback = 0; + uint32_t *capture, *playback; + + capture = alloca(sizeof(uint32_t) * pr->n_devices); + playback = alloca(sizeof(uint32_t) * pr->n_devices); for (i = 0; i < pr->n_devices; i++) { - switch (pr->devices[i]->direction) { + struct acp_device *dev = pr->devices[i]; + switch (dev->direction) { case ACP_DIRECTION_PLAYBACK: - n_playback++; + playback[n_playback++] = dev->index; break; case ACP_DIRECTION_CAPTURE: - n_capture++; + capture[n_capture++] = dev->index; break; } } n_classes = n_capture > 0 ? 1 : 0; n_classes += n_playback > 0 ? 1 : 0; - spa_pod_builder_int(b, n_classes); spa_pod_builder_push_object(b, &f[0], SPA_TYPE_OBJECT_ParamProfile, id); spa_pod_builder_add(b, SPA_PARAM_PROFILE_index, SPA_POD_Int(pr->index), @@ -327,12 +331,18 @@ static struct spa_pod *build_profile(struct spa_pod_builder *b, uint32_t id, if (n_capture > 0) { spa_pod_builder_add_struct(b, SPA_POD_String("Audio/Source"), - SPA_POD_Int(n_capture)); + SPA_POD_Int(n_capture), + SPA_POD_String("card.profile.devices"), + SPA_POD_Array(sizeof(uint32_t), SPA_TYPE_Int, + n_capture, capture)); } if (n_playback > 0) { spa_pod_builder_add_struct(b, SPA_POD_String("Audio/Sink"), - SPA_POD_Int(n_playback)); + SPA_POD_Int(n_playback), + SPA_POD_String("card.profile.devices"), + SPA_POD_Array(sizeof(uint32_t), SPA_TYPE_Int, + n_playback, playback)); } spa_pod_builder_pop(b, &f[1]); return spa_pod_builder_pop(b, &f[0]);