acp: add more properties for the card

Use snd_ctl_card_info to set some more card properties such as the
alsa.id, alsa.mixer_name and alsa.components.

alsa.id is interesting because it is possible to use udev rules to set a
custom id, which is handy when you have two identical cards in the
system and want to assign unique ids to them.

See #3912
This commit is contained in:
Wim Taymans 2024-03-18 10:59:23 +01:00
parent 2821b05d0b
commit 37a51533e0
2 changed files with 8 additions and 4 deletions

View file

@ -962,7 +962,7 @@ bool pa_alsa_init_description(pa_proplist *p, pa_card *card) {
}
void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card) {
char *cn, *lcn, *dn;
char *cn, *lcn, *dn, name[64];
pa_assert(p);
pa_assert(card >= 0);
@ -984,6 +984,9 @@ void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card) {
pa_xfree(dn);
}
snprintf(name, sizeof(name), "hw:%d", card);
pa_alsa_init_proplist_ctl(p, name);
#ifdef HAVE_UDEV
pa_udev_get_info(card, p);
#endif
@ -1070,7 +1073,6 @@ void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm) {
pa_alsa_init_proplist_pcm_info(c, p, info);
}
#if 0
void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name) {
int err;
snd_ctl_t *ctl;
@ -1098,9 +1100,13 @@ void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name) {
if ((t = snd_ctl_card_info_get_components(info)) && *t)
pa_proplist_sets(p, "alsa.components", t);
if ((t = snd_ctl_card_info_get_id(info)) && *t)
pa_proplist_sets(p, "alsa.id", t);
snd_ctl_close(ctl);
}
#if 0
int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
snd_pcm_state_t state;
snd_pcm_hw_params_t *hwparams;

View file

@ -131,9 +131,7 @@ void pa_alsa_refcnt_dec(void);
void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info);
void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card);
void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm);
#if 0
void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name);
#endif
bool pa_alsa_init_description(pa_proplist *p, pa_card *card);
#if 0