alsactl: init - add -U option to disable UCM based init

The reason is to use it with internal init extra commands like:
  alsactl -U -E CMD=info init

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Andrew Hlynskyi 2020-10-02 06:45:43 +03:00 committed by Jaroslav Kysela
parent 20f87c14d9
commit d7bf45edc3
3 changed files with 16 additions and 7 deletions

View file

@ -98,6 +98,7 @@ static struct arg args[] = {
{ 'c', "sched-idle", "set the process scheduling policy to idle (SCHED_IDLE)" },
#ifdef HAVE_ALSA_USE_CASE_H
{ 'D', "ucm-defaults", "execute also the UCM 'defaults' section" },
{ 'U', "no-ucm", "don't init with UCM" },
#endif
{ HEADER, NULL, "Available commands:" },
{ CARDCMD, "store", "save current driver setup for one or each soundcards" },
@ -270,6 +271,9 @@ int main(int argc, char *argv[])
case 'D':
initflags |= FLAG_UCM_DEFAULTS;
break;
case 'U':
initflags |= FLAG_UCM_DISABLED;
break;
case 'r':
statefile = optarg;
break;

View file

@ -25,7 +25,8 @@ void error_handler(const char *file, int line, const char *function, int err, co
#define dbg(args...) do { dbg_(__func__, __LINE__, ##args); } while (0)
#endif
#define FLAG_UCM_DEFAULTS (1<<0)
#define FLAG_UCM_DISABLED (1<<0)
#define FLAG_UCM_DEFAULTS (1<<1)
int init(const char *file, int flags, const char *cardname);
int init_ucm(int flags, int cardno);

View file

@ -1762,9 +1762,11 @@ int init(const char *filename, int flags, const char *cardname)
break;
}
first = 0;
err = init_ucm(flags, card);
if (err == 0)
continue;
if (!(flags & FLAG_UCM_DISABLED)) {
err = init_ucm(flags, card);
if (err == 0)
continue;
}
err = init_space(&space, card);
if (err == 0) {
space->rootdir = new_root_dir(filename);
@ -1787,9 +1789,11 @@ int init(const char *filename, int flags, const char *cardname)
error("Cannot find soundcard '%s'...", cardname);
goto error;
}
err = init_ucm(flags, card);
if (err == 0)
return 0;
if (!(flags & FLAG_UCM_DISABLED)) {
err = init_ucm(flags, card);
if (err == 0)
return 0;
}
memset(&space, 0, sizeof(space));
err = init_space(&space, card);
if (err == 0) {