Skip to content

Commit 4bea8fe

Browse files
committed
alsactl: add initial support for UCM init
Signed-off-by: Jaroslav Kysela <[email protected]>
1 parent 598488c commit 4bea8fe

4 files changed

Lines changed: 49 additions & 2 deletions

File tree

‎alsactl/Makefile.am‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ EXTRA_DIST=alsactl.1 alsactl_init.xml
99

1010
AM_CFLAGS = -D_GNU_SOURCE
1111

12-
alsactl_SOURCES=alsactl.c state.c lock.c utils.c init_parse.c daemon.c \
13-
monitor.c
12+
alsactl_SOURCES=alsactl.c state.c lock.c utils.c init_parse.c init_ucm.c \
13+
daemon.c monitor.c
1414

1515
alsactl_CFLAGS=$(AM_CFLAGS) -D__USE_GNU \
1616
-DSYS_ASOUNDRC=\"$(ASOUND_STATE_DIR)/asound.state\" \

‎alsactl/alsactl.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ void dbg_(const char *fcn, long line, const char *fmt, ...);
2525
#endif
2626

2727
int init(const char *file, const char *cardname);
28+
int init_ucm(int cardno);
2829
int state_lock(const char *file, int timeout);
2930
int state_unlock(int fd, const char *file);
3031
int save_state(const char *file, const char *cardname);

‎alsactl/init_parse.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,9 @@ int init(const char *filename, const char *cardname)
17621762
break;
17631763
}
17641764
first = 0;
1765+
err = init_ucm(card);
1766+
if (err == 0)
1767+
continue;
17651768
err = init_space(&space, card);
17661769
if (err == 0) {
17671770
space->rootdir = new_root_dir(filename);
@@ -1784,6 +1787,9 @@ int init(const char *filename, const char *cardname)
17841787
error("Cannot find soundcard '%s'...", cardname);
17851788
goto error;
17861789
}
1790+
err = init_ucm(card);
1791+
if (err == 0)
1792+
return 0;
17871793
memset(&space, 0, sizeof(space));
17881794
err = init_space(&space, card);
17891795
if (err == 0) {

‎alsactl/init_ucm.c‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Advanced Linux Sound Architecture Control Program - UCM Initialization
3+
* Copyright (c) by Jaroslav Kysela <[email protected]>
4+
*
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+
*
20+
*/
21+
22+
#include <alsa/use-case.h>
23+
24+
/*
25+
* Keep it as simple as possible. Execute commands from the SectionOnce only.
26+
*/
27+
int init_ucm(int cardno)
28+
{
29+
snd_use_case_mgr_t *uc_mgr;
30+
char id[32];
31+
int err;
32+
33+
snprintf(id, sizeof(id), "hw:%d", cardno);
34+
err = snd_use_case_mgr_open(&uc_mgr, id);
35+
if (err < 0)
36+
return err;
37+
err = snd_use_case_set(uc_mgr, "_once", NULL);
38+
snd_use_case_mgr_close(uc_mgr);
39+
return err;
40+
}

0 commit comments

Comments
 (0)