From d7bf45edc3c1a08e3cbc852b26f8c2e051723552 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Fri, 2 Oct 2020 06:45:43 +0300 Subject: [PATCH] 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 --- alsactl/alsactl.c | 4 ++++ alsactl/alsactl.h | 3 ++- alsactl/init_parse.c | 16 ++++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c index 6a0a395..20ebac1 100644 --- a/alsactl/alsactl.c +++ b/alsactl/alsactl.c @@ -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; diff --git a/alsactl/alsactl.h b/alsactl/alsactl.h index 2352f4c..c478695 100644 --- a/alsactl/alsactl.h +++ b/alsactl/alsactl.h @@ -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); diff --git a/alsactl/init_parse.c b/alsactl/init_parse.c index 4ece067..ee9cc6d 100644 --- a/alsactl/init_parse.c +++ b/alsactl/init_parse.c @@ -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) {