From 855735d720ca3f16c2947e4bef3a578aa95fd6a0 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Tue, 30 Jun 2026 20:07:47 +0200 Subject: [PATCH] Use descriptive description for Pro devices For Pro Audio devices, the description is the card name with "Pro" or Pro 1", "Pro 2", etc. appended. The result is user interfaces showing around half a dozen devices with descriptions that don't help disambiguate devices in the slightest. Append the underlying PCM names instead of the "Pro N" string, so that devices can be recognised at a glance. Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/work_items/3982 --- spa/plugins/alsa/acp/acp.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/spa/plugins/alsa/acp/acp.c b/spa/plugins/alsa/acp/acp.c index 57a31d288..e358a82e4 100644 --- a/spa/plugins/alsa/acp/acp.c +++ b/spa/plugins/alsa/acp/acp.c @@ -330,6 +330,22 @@ static const char *find_best_verb(pa_card *impl) return res; } +static void get_pro_description(char *desc, size_t size, + snd_pcm_info_t *pcminfo, int dev, int count) +{ + const char *sub_name = snd_pcm_info_get_subdevice_name(pcminfo); + const char *pcm_name = snd_pcm_info_get_name(pcminfo); + + if (sub_name && *sub_name && !pa_startswith(sub_name, "subdevice #")) + snprintf(desc, size, "%s", sub_name); + else if (pcm_name && *pcm_name) + snprintf(desc, size, "%s", pcm_name); + else if (count == 0) + snprintf(desc, size, "Pro"); + else + snprintf(desc, size, "Pro %d", dev); +} + static int add_pro_profile(pa_card *impl, uint32_t index) { snd_ctl_t *ctl_hndl; @@ -398,10 +414,7 @@ static int add_pro_profile(pa_card *impl, uint32_t index) snd_pcm_info_set_subdevice(pcminfo, 0); snprintf(devstr, sizeof(devstr), "hw:%d,%d", index, dev); - if (count++ == 0) - snprintf(desc, sizeof(desc), "Pro"); - else - snprintf(desc, sizeof(desc), "Pro %d", dev); + count++; snd_pcm_info_set_stream(pcminfo, SND_PCM_STREAM_PLAYBACK); if ((err = snd_ctl_pcm_info(ctl_hndl, pcminfo)) < 0) { @@ -416,6 +429,7 @@ static int add_pro_profile(pa_card *impl, uint32_t index) m = NULL; } if (m) { + get_pro_description(desc, sizeof(desc), pcminfo, dev, count); m->description = pa_xstrdup(desc); m->device_strings = pa_split_spaces_strv(devstr); @@ -452,6 +466,7 @@ static int add_pro_profile(pa_card *impl, uint32_t index) m = NULL; } if (m) { + get_pro_description(desc, sizeof(desc), pcminfo, dev, count); m->description = pa_xstrdup(desc); m->device_strings = pa_split_spaces_strv(devstr);