mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 17:15:43 +01:00
Updates for write path..
This commit is contained in:
parent
20ead97821
commit
69f215efe9
2 changed files with 18 additions and 10 deletions
|
@ -50,7 +50,7 @@ void usage()
|
|||
printf("\n"
|
||||
"Usage: amixer [-c card] [-d dev] device [vol|L:R] [mute|unmute] [rec|norec]\n\n"
|
||||
" amixer [-p path] -r\tRead %s or <path> settings\n"
|
||||
" amixer -w\t\tWrite %s settings\n"
|
||||
" amixer [-p path] -w\tWrite %s or <path> settings\n"
|
||||
" amixer -q ...\t\tQuiet mode\n"
|
||||
" amixer -h\t\tHelp\n\n"
|
||||
"Example: amixer line-out 80:50 unmute rec\n\n", rc_file(), rc_file());
|
||||
|
@ -68,7 +68,9 @@ void read_config(Mixer * mix, const char *path)
|
|||
int count = 0;
|
||||
int flags;
|
||||
|
||||
if ((rc = fopen(path ? path : rc_file(), "r")) == NULL) {
|
||||
if (path && strcmp(path, "-") == 0)
|
||||
rc = stdin;
|
||||
else if ((rc = fopen(path ? path : rc_file(), "r")) == NULL) {
|
||||
printf("Mixer values not read\n");
|
||||
return;
|
||||
}
|
||||
|
@ -93,16 +95,19 @@ void read_config(Mixer * mix, const char *path)
|
|||
mix->Write(left, right, flags);
|
||||
}
|
||||
|
||||
fclose(rc);
|
||||
if (rc != stdin)
|
||||
fclose(rc);
|
||||
return;
|
||||
}
|
||||
|
||||
void write_config(Mixer * mix)
|
||||
void write_config(Mixer * mix, const char *path)
|
||||
{
|
||||
FILE *rc;
|
||||
int32 left, right, flags;
|
||||
|
||||
if ((rc = fopen(rc_file(), "w+")) == NULL) {
|
||||
if (path && strcmp(path, "-") == 0)
|
||||
rc = stdout;
|
||||
else if ((rc = fopen(path ? path : rc_file(), "w+")) == NULL) {
|
||||
printf("Mixer values not written\n");
|
||||
return;
|
||||
}
|
||||
|
@ -113,7 +118,8 @@ void write_config(Mixer * mix)
|
|||
mix->Read(&left, &right, &flags);
|
||||
fprintf(rc, "%d %d:%d %d %d\n", i, mix->Left(), mix->Right(), flags & E_MIXER_MUTE ? 1 : 0, flags & E_MIXER_RECORD ? 1 : 0);
|
||||
}
|
||||
fclose(rc);
|
||||
if (rc != stdout)
|
||||
fclose(rc);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -165,7 +171,7 @@ int main(int argc, char **argv)
|
|||
} else if (argv[add][1] == 'w') {
|
||||
the_mixer = new Mixer(card, device);
|
||||
if (the_mixer && the_mixer->Init())
|
||||
write_config(the_mixer);
|
||||
write_config(the_mixer, pathind ? argv[pathind] : (const char *) NULL);
|
||||
delete the_mixer;
|
||||
return 0;
|
||||
} else if (argv[add][1] == 'q') {
|
||||
|
|
|
@ -48,10 +48,12 @@ than I do. :)
|
|||
Help: show syntax.
|
||||
.TP
|
||||
[\fI-p\fP path] \fI-r\fP
|
||||
Read settings from $HOME/.amixerrc or from optional <path>.
|
||||
Read settings from $HOME/.amixerrc or from optional <path>. If <path>
|
||||
is ``\-'', reads from the standard input.
|
||||
.TP
|
||||
\fI-w\fP
|
||||
Write the current mixer settings into $HOME/.amixerrc
|
||||
[\fI-p\fP path] \fI-w\fP
|
||||
Write the current mixer settings into $HOME/.amixerrc or optional <path>.
|
||||
If <path> is ``\-'', writes to the standard output.
|
||||
.TP
|
||||
\fI-q\fP
|
||||
Quiet mode. Do not show results of changes.
|
||||
|
|
Loading…
Reference in a new issue