mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
alsa-ucm: get the mixer names from ucm, don't guess
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
ddd0fdb997
commit
e438382a51
3 changed files with 97 additions and 26 deletions
|
|
@ -1740,20 +1740,31 @@ snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device) {
|
||||
snd_mixer_t *pa_alsa_open_mixer_by_name(const char *dev) {
|
||||
int err;
|
||||
snd_mixer_t *m;
|
||||
snd_pcm_info_t* info;
|
||||
snd_pcm_info_alloca(&info);
|
||||
|
||||
pa_assert(pcm);
|
||||
pa_assert(dev);
|
||||
|
||||
if ((err = snd_mixer_open(&m, 0)) < 0) {
|
||||
pa_log("Error opening mixer: %s", pa_alsa_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Then, try by card index */
|
||||
if (prepare_mixer(m, dev) >= 0)
|
||||
return m;
|
||||
|
||||
snd_mixer_close(m);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device) {
|
||||
snd_mixer_t *m;
|
||||
snd_pcm_info_t* info;
|
||||
snd_pcm_info_alloca(&info);
|
||||
|
||||
pa_assert(pcm);
|
||||
|
||||
if (snd_pcm_info(pcm, info) >= 0) {
|
||||
char *md;
|
||||
int card_idx;
|
||||
|
|
@ -1761,8 +1772,8 @@ snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device) {
|
|||
if ((card_idx = snd_pcm_info_get_card(info)) >= 0) {
|
||||
|
||||
md = pa_sprintf_malloc("hw:%i", card_idx);
|
||||
if (prepare_mixer(m, md) >= 0) {
|
||||
|
||||
m = pa_alsa_open_mixer_by_name(md);
|
||||
if (m) {
|
||||
if (ctl_device)
|
||||
*ctl_device = md;
|
||||
else
|
||||
|
|
@ -1775,7 +1786,6 @@ snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device) {
|
|||
}
|
||||
}
|
||||
|
||||
snd_mixer_close(m);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue