From 37a51533e02b8943c606bef53583aaa259f5626d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 18 Mar 2024 10:59:23 +0100 Subject: [PATCH] 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 --- spa/plugins/alsa/acp/alsa-util.c | 10 ++++++++-- spa/plugins/alsa/acp/alsa-util.h | 2 -- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/spa/plugins/alsa/acp/alsa-util.c b/spa/plugins/alsa/acp/alsa-util.c index f6c38b2a9..f1592a884 100644 --- a/spa/plugins/alsa/acp/alsa-util.c +++ b/spa/plugins/alsa/acp/alsa-util.c @@ -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; diff --git a/spa/plugins/alsa/acp/alsa-util.h b/spa/plugins/alsa/acp/alsa-util.h index c97ff3d90..e576dc9bc 100644 --- a/spa/plugins/alsa/acp/alsa-util.h +++ b/spa/plugins/alsa/acp/alsa-util.h @@ -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