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)" }, { 'c', "sched-idle", "set the process scheduling policy to idle (SCHED_IDLE)" },
#ifdef HAVE_ALSA_USE_CASE_H #ifdef HAVE_ALSA_USE_CASE_H
{ 'D', "ucm-defaults", "execute also the UCM 'defaults' section" }, { 'D', "ucm-defaults", "execute also the UCM 'defaults' section" },
{ 'U', "no-ucm", "don't init with UCM" },
#endif #endif
{ HEADER, NULL, "Available commands:" }, { HEADER, NULL, "Available commands:" },
{ CARDCMD, "store", "save current driver setup for one or each soundcards" }, { CARDCMD, "store", "save current driver setup for one or each soundcards" },
@ -270,6 +271,9 @@ int main(int argc, char *argv[])
case 'D': case 'D':
initflags |= FLAG_UCM_DEFAULTS; initflags |= FLAG_UCM_DEFAULTS;
break; break;
case 'U':
initflags |= FLAG_UCM_DISABLED;
break;
case 'r': case 'r':
statefile = optarg; statefile = optarg;
break; 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) #define dbg(args...) do { dbg_(__func__, __LINE__, ##args); } while (0)
#endif #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(const char *file, int flags, const char *cardname);
int init_ucm(int flags, int cardno); int init_ucm(int flags, int cardno);

View file

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