mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 00:25: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"
|
printf("\n"
|
||||||
"Usage: amixer [-c card] [-d dev] device [vol|L:R] [mute|unmute] [rec|norec]\n\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 [-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 -q ...\t\tQuiet mode\n"
|
||||||
" amixer -h\t\tHelp\n\n"
|
" amixer -h\t\tHelp\n\n"
|
||||||
"Example: amixer line-out 80:50 unmute rec\n\n", rc_file(), rc_file());
|
"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 count = 0;
|
||||||
int flags;
|
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");
|
printf("Mixer values not read\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -93,16 +95,19 @@ void read_config(Mixer * mix, const char *path)
|
||||||
mix->Write(left, right, flags);
|
mix->Write(left, right, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rc != stdin)
|
||||||
fclose(rc);
|
fclose(rc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_config(Mixer * mix)
|
void write_config(Mixer * mix, const char *path)
|
||||||
{
|
{
|
||||||
FILE *rc;
|
FILE *rc;
|
||||||
int32 left, right, flags;
|
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");
|
printf("Mixer values not written\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -113,6 +118,7 @@ void write_config(Mixer * mix)
|
||||||
mix->Read(&left, &right, &flags);
|
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);
|
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);
|
||||||
}
|
}
|
||||||
|
if (rc != stdout)
|
||||||
fclose(rc);
|
fclose(rc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +171,7 @@ int main(int argc, char **argv)
|
||||||
} else if (argv[add][1] == 'w') {
|
} else if (argv[add][1] == 'w') {
|
||||||
the_mixer = new Mixer(card, device);
|
the_mixer = new Mixer(card, device);
|
||||||
if (the_mixer && the_mixer->Init())
|
if (the_mixer && the_mixer->Init())
|
||||||
write_config(the_mixer);
|
write_config(the_mixer, pathind ? argv[pathind] : (const char *) NULL);
|
||||||
delete the_mixer;
|
delete the_mixer;
|
||||||
return 0;
|
return 0;
|
||||||
} else if (argv[add][1] == 'q') {
|
} else if (argv[add][1] == 'q') {
|
||||||
|
|
|
@ -48,10 +48,12 @@ than I do. :)
|
||||||
Help: show syntax.
|
Help: show syntax.
|
||||||
.TP
|
.TP
|
||||||
[\fI-p\fP path] \fI-r\fP
|
[\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
|
.TP
|
||||||
\fI-w\fP
|
[\fI-p\fP path] \fI-w\fP
|
||||||
Write the current mixer settings into $HOME/.amixerrc
|
Write the current mixer settings into $HOME/.amixerrc or optional <path>.
|
||||||
|
If <path> is ``\-'', writes to the standard output.
|
||||||
.TP
|
.TP
|
||||||
\fI-q\fP
|
\fI-q\fP
|
||||||
Quiet mode. Do not show results of changes.
|
Quiet mode. Do not show results of changes.
|
||||||
|
|
Loading…
Reference in a new issue