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
This commit is contained in:
Hugo Osvaldo Barrera 2026-06-30 20:07:47 +02:00 committed by Wim Taymans
parent 6eddd1080f
commit 855735d720

View file

@ -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);