mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-22 23:06:30 +01:00
alsactl: add -D argument to execute also the UCM defaults section
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
8fb4016a17
commit
b68e854d28
6 changed files with 37 additions and 15 deletions
|
@ -142,6 +142,11 @@ Set the process priority (see 'man nice')
|
|||
\fI\-c, \-\-sched-idle\fP
|
||||
Set the process scheduling policy to idle (SCHED_IDLE).
|
||||
|
||||
.TP
|
||||
\fI\-D, \-\-ucm-defaults\fP
|
||||
Execute also the 'defaults' section from the UCM configuration. The standard
|
||||
behaviour is to execute only 'once' section.
|
||||
|
||||
.SH FILES
|
||||
\fI/var/lib/alsa/asound.state\fP (or whatever file you specify with the
|
||||
\fB\-f\fP flag) is used to store current settings for your
|
||||
|
|
|
@ -96,6 +96,7 @@ static struct arg args[] = {
|
|||
{ 's', "syslog", "use syslog for messages" },
|
||||
{ INTARG | 'n', "nice", "set the process priority (see 'man nice')" },
|
||||
{ 'c', "sched-idle", "set the process scheduling policy to idle (SCHED_IDLE)" },
|
||||
{ 'D', "ucm-defaults", "execute also the UCM 'defaults' section" },
|
||||
{ HEADER, NULL, "Available commands:" },
|
||||
{ CARDCMD, "store", "save current driver setup for one or each soundcards" },
|
||||
{ EMPCMD, NULL, " to configuration file" },
|
||||
|
@ -191,6 +192,7 @@ int main(int argc, char *argv[])
|
|||
int daemoncmd = 0;
|
||||
int use_nice = NO_NICE;
|
||||
int sched_idle = 0;
|
||||
int initflags = 0;
|
||||
struct arg *a;
|
||||
struct option *o;
|
||||
int i, j, k, res;
|
||||
|
@ -263,6 +265,9 @@ int main(int argc, char *argv[])
|
|||
case 'I':
|
||||
init_fallback = 0;
|
||||
break;
|
||||
case 'D':
|
||||
initflags |= FLAG_UCM_DEFAULTS;
|
||||
break;
|
||||
case 'r':
|
||||
statefile = optarg;
|
||||
break;
|
||||
|
@ -357,7 +362,7 @@ int main(int argc, char *argv[])
|
|||
snd_lib_error_set_handler(error_handler);
|
||||
|
||||
if (!strcmp(cmd, "init")) {
|
||||
res = init(initfile, cardname);
|
||||
res = init(initfile, initflags, cardname);
|
||||
snd_config_update_free_global();
|
||||
} else if (!strcmp(cmd, "store")) {
|
||||
res = save_state(cfgfile, cardname);
|
||||
|
@ -366,7 +371,7 @@ int main(int argc, char *argv[])
|
|||
!strcmp(cmd, "nrestore")) {
|
||||
if (removestate)
|
||||
remove(statefile);
|
||||
res = load_state(cfgfile, initfile, cardname, init_fallback);
|
||||
res = load_state(cfgfile, initfile, initflags, cardname, init_fallback);
|
||||
if (!strcmp(cmd, "rdaemon")) {
|
||||
do_nice(use_nice, sched_idle);
|
||||
res = state_daemon(cfgfile, cardname, period, pidfile);
|
||||
|
|
|
@ -25,13 +25,15 @@ 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
|
||||
|
||||
int init(const char *file, const char *cardname);
|
||||
int init_ucm(int cardno);
|
||||
#define FLAG_UCM_DEFAULTS (1<<0)
|
||||
|
||||
int init(const char *file, int flags, const char *cardname);
|
||||
int init_ucm(int flags, int cardno);
|
||||
int state_lock(const char *file, int timeout);
|
||||
int state_unlock(int fd, const char *file);
|
||||
int save_state(const char *file, const char *cardname);
|
||||
int load_state(const char *file, const char *initfile, const char *cardname,
|
||||
int do_init);
|
||||
int load_state(const char *file, const char *initfile, int initflags,
|
||||
const char *cardname, int do_init);
|
||||
int power(const char *argv[], int argc);
|
||||
int monitor(const char *name);
|
||||
int state_daemon(const char *file, const char *cardname, int period,
|
||||
|
|
|
@ -1742,7 +1742,7 @@ static int parse(struct space *space, const char *filename)
|
|||
return err ? err : -abs(space->exit_code);
|
||||
}
|
||||
|
||||
int init(const char *filename, const char *cardname)
|
||||
int init(const char *filename, int flags, const char *cardname)
|
||||
{
|
||||
struct space *space;
|
||||
int err = 0, lasterr = 0, card, first;
|
||||
|
@ -1762,7 +1762,7 @@ int init(const char *filename, const char *cardname)
|
|||
break;
|
||||
}
|
||||
first = 0;
|
||||
err = init_ucm(card);
|
||||
err = init_ucm(flags, card);
|
||||
if (err == 0)
|
||||
continue;
|
||||
err = init_space(&space, card);
|
||||
|
@ -1787,7 +1787,7 @@ int init(const char *filename, const char *cardname)
|
|||
error("Cannot find soundcard '%s'...", cardname);
|
||||
goto error;
|
||||
}
|
||||
err = init_ucm(card);
|
||||
err = init_ucm(flags, card);
|
||||
if (err == 0)
|
||||
return 0;
|
||||
memset(&space, 0, sizeof(space));
|
||||
|
|
|
@ -19,12 +19,14 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "alsactl.h"
|
||||
#include <alsa/use-case.h>
|
||||
|
||||
/*
|
||||
* Keep it as simple as possible. Execute commands from the SectionOnce only.
|
||||
*/
|
||||
int init_ucm(int cardno)
|
||||
int init_ucm(int flags, int cardno)
|
||||
{
|
||||
snd_use_case_mgr_t *uc_mgr;
|
||||
char id[32];
|
||||
|
@ -35,6 +37,14 @@ int init_ucm(int cardno)
|
|||
if (err < 0)
|
||||
return err;
|
||||
err = snd_use_case_set(uc_mgr, "_once", NULL);
|
||||
if (err < 0)
|
||||
goto _error;
|
||||
if ((flags & FLAG_UCM_DEFAULTS) != 0) {
|
||||
err = snd_use_case_set(uc_mgr, "_defaults", NULL);
|
||||
if (err < 0)
|
||||
goto _error;
|
||||
}
|
||||
_error:
|
||||
snd_use_case_mgr_close(uc_mgr);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -1645,8 +1645,8 @@ out:
|
|||
return err;
|
||||
}
|
||||
|
||||
int load_state(const char *file, const char *initfile, const char *cardname,
|
||||
int do_init)
|
||||
int load_state(const char *file, const char *initfile, int initflags,
|
||||
const char *cardname, int do_init)
|
||||
{
|
||||
int err, finalerr = 0;
|
||||
snd_config_t *config;
|
||||
|
@ -1704,7 +1704,7 @@ single:
|
|||
if (!do_init)
|
||||
break;
|
||||
sprintf(cardname1, "%i", card);
|
||||
err = init(initfile, cardname1);
|
||||
err = init(initfile, initflags, cardname1);
|
||||
if (err < 0) {
|
||||
finalerr = err;
|
||||
initfailed(card, "init", err);
|
||||
|
@ -1743,7 +1743,7 @@ single:
|
|||
/* do a check if controls matches state file */
|
||||
if (do_init && set_controls(card, config, 0)) {
|
||||
sprintf(cardname1, "%i", card);
|
||||
err = init(initfile, cardname1);
|
||||
err = init(initfile, initflags, cardname1);
|
||||
if (err < 0) {
|
||||
initfailed(card, "init", err);
|
||||
finalerr = err;
|
||||
|
@ -1766,7 +1766,7 @@ single:
|
|||
}
|
||||
/* do a check if controls matches state file */
|
||||
if (do_init && set_controls(cardno, config, 0)) {
|
||||
err = init(initfile, cardname);
|
||||
err = init(initfile, initflags, cardname);
|
||||
if (err < 0) {
|
||||
initfailed(cardno, "init", err);
|
||||
finalerr = err;
|
||||
|
|
Loading…
Reference in a new issue