mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 00:45:41 +01:00
aplay: Show usage if no parameter is passed
When aplay/arecord are called without any argument the application hangs forever. Instead of hanging, print the usage and exit. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
f282607273
commit
c6614dbdab
1 changed files with 8 additions and 0 deletions
|
@ -493,6 +493,7 @@ int main(int argc, char *argv[])
|
||||||
int tmp, err, c;
|
int tmp, err, c;
|
||||||
int do_device_list = 0, do_pcm_list = 0;
|
int do_device_list = 0, do_pcm_list = 0;
|
||||||
snd_pcm_info_t *info;
|
snd_pcm_info_t *info;
|
||||||
|
FILE *direction;
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
@ -511,14 +512,21 @@ int main(int argc, char *argv[])
|
||||||
file_type = FORMAT_WAVE;
|
file_type = FORMAT_WAVE;
|
||||||
command = "arecord";
|
command = "arecord";
|
||||||
start_delay = 1;
|
start_delay = 1;
|
||||||
|
direction = stdout;
|
||||||
} else if (strstr(argv[0], "aplay")) {
|
} else if (strstr(argv[0], "aplay")) {
|
||||||
stream = SND_PCM_STREAM_PLAYBACK;
|
stream = SND_PCM_STREAM_PLAYBACK;
|
||||||
command = "aplay";
|
command = "aplay";
|
||||||
|
direction = stdin;
|
||||||
} else {
|
} else {
|
||||||
error(_("command should be named either arecord or aplay"));
|
error(_("command should be named either arecord or aplay"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isatty(fileno(direction)) && (argc == 1)) {
|
||||||
|
usage(command);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
chunk_size = -1;
|
chunk_size = -1;
|
||||||
rhwparams.format = DEFAULT_FORMAT;
|
rhwparams.format = DEFAULT_FORMAT;
|
||||||
rhwparams.rate = DEFAULT_SPEED;
|
rhwparams.rate = DEFAULT_SPEED;
|
||||||
|
|
Loading…
Reference in a new issue