spa: acp: indicate ALSA UCM profile errors in UIs

Add "[ALSA UCM error]" to the end of card description, to indicate
something is wrong.
This commit is contained in:
Pauli Virtanen 2025-03-13 19:23:32 +02:00 committed by Wim Taymans
parent 4338189f76
commit bd3a8b594f
3 changed files with 29 additions and 1 deletions

View file

@ -498,6 +498,7 @@ static void add_profiles(pa_card *impl)
int n_profiles, n_ports, n_devices; int n_profiles, n_ports, n_devices;
uint32_t idx; uint32_t idx;
const char *arr; const char *arr;
bool broken_ucm = false;
n_devices = 0; n_devices = 0;
pa_dynarray_init(&impl->out.devices, device_free); pa_dynarray_init(&impl->out.devices, device_free);
@ -541,6 +542,9 @@ static void add_profiles(pa_card *impl)
dev->ports, NULL); dev->ports, NULL);
pa_dynarray_append(&ap->out.devices, dev); pa_dynarray_append(&ap->out.devices, dev);
if (m->split && m->split->broken)
broken_ucm = true;
} }
} }
@ -564,6 +568,9 @@ static void add_profiles(pa_card *impl)
dev->ports, NULL); dev->ports, NULL);
pa_dynarray_append(&ap->out.devices, dev); pa_dynarray_append(&ap->out.devices, dev);
if (m->split && m->split->broken)
broken_ucm = true;
} }
} }
cp->n_devices = pa_dynarray_size(&ap->out.devices); cp->n_devices = pa_dynarray_size(&ap->out.devices);
@ -571,6 +578,22 @@ static void add_profiles(pa_card *impl)
pa_hashmap_put(impl->profiles, ap->name, cp); pa_hashmap_put(impl->profiles, ap->name, cp);
} }
/* Add a conspicuous notice if there are errors in the UCM profile */
if (broken_ucm) {
const char *desc;
char *new_desc = NULL;
desc = pa_proplist_gets(impl->proplist, PA_PROP_DEVICE_DESCRIPTION);
if (!desc)
desc = "";
new_desc = spa_aprintf(_("%s [ALSA UCM error]"), desc);
pa_log_notice("Errors in ALSA UCM profile for card %s", desc);
if (new_desc)
pa_proplist_sets(impl->proplist, PA_PROP_DEVICE_DESCRIPTION, new_desc);
free(new_desc);
}
pa_dynarray_init(&impl->out.ports, NULL); pa_dynarray_init(&impl->out.ports, NULL);
n_ports = 0; n_ports = 0;
PA_HASHMAP_FOREACH(dp, impl->ports, state) { PA_HASHMAP_FOREACH(dp, impl->ports, state) {

View file

@ -381,9 +381,11 @@ static pa_alsa_ucm_split *ucm_get_split_channels(pa_alsa_ucm_device *device, snd
if (pa_atou(value, &idx) < 0) if (pa_atou(value, &idx) < 0)
break; break;
if (idx >= hw_channels) if (idx >= hw_channels) {
pa_log_notice("Error in ALSA UCM profile for %s (%s): %sChannel%d=%d >= %sChannels=%d", pa_log_notice("Error in ALSA UCM profile for %s (%s): %sChannel%d=%d >= %sChannels=%d",
pcm_name, device_name, prefix, i, idx, prefix, hw_channels); pcm_name, device_name, prefix, i, idx, prefix, hw_channels);
split->broken = true;
}
value = ucm_get_string(uc_mgr, "%sChannelPos%d/%s", prefix, i, device_name); value = ucm_get_string(uc_mgr, "%sChannelPos%d/%s", prefix, i, device_name);
if (!value) { if (!value) {
@ -2453,10 +2455,12 @@ static snd_pcm_t* mapping_open_pcm(pa_alsa_ucm_config *ucm, pa_alsa_mapping *m,
/* Just accept whatever we got... Some of the routings won't get connected /* Just accept whatever we got... Some of the routings won't get connected
* anywhere */ * anywhere */
m->split->hw_channels = try_map.channels; m->split->hw_channels = try_map.channels;
m->split->broken = true;
} else if (try_map.channels > m->split->hw_channels) { } else if (try_map.channels > m->split->hw_channels) {
pa_log_notice("Error in ALSA UCM profile for %s (%s): %sChannels=%d < avail %d", pa_log_notice("Error in ALSA UCM profile for %s (%s): %sChannels=%d < avail %d",
m->device_strings[0], m->name, mode_name, m->split->hw_channels, try_map.channels); m->device_strings[0], m->name, mode_name, m->split->hw_channels, try_map.channels);
m->split->hw_channels = try_map.channels; m->split->hw_channels = try_map.channels;
m->split->broken = true;
} }
} else if (!exact_channels) { } else if (!exact_channels) {
m->channel_map = try_map; m->channel_map = try_map;

View file

@ -185,6 +185,7 @@ struct pa_alsa_ucm_split {
int channels; int channels;
int idx[PA_CHANNELS_MAX]; int idx[PA_CHANNELS_MAX];
enum snd_pcm_chmap_position pos[PA_CHANNELS_MAX]; enum snd_pcm_chmap_position pos[PA_CHANNELS_MAX];
bool broken;
}; };
struct pa_alsa_ucm_device { struct pa_alsa_ucm_device {