summaryrefslogtreecommitdiff
path: root/aplay
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2012-11-13 10:05:39 -0200
committerTakashi Iwai <tiwai@suse.de>2012-11-13 14:33:40 +0100
commitc6614dbdab1cbe541e7d6cd29f3922510e0b6981 (patch)
treebba6aebd89a997f5b5760c62f093e09ccb6f5b3e /aplay
parentf2826072732951b1d4e1bacd8115f9e6a98932d5 (diff)
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>
Diffstat (limited to 'aplay')
-rw-r--r--aplay/aplay.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/aplay/aplay.c b/aplay/aplay.c
index 741979a..f35f603 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -493,6 +493,7 @@ int main(int argc, char *argv[])
int tmp, err, c;
int do_device_list = 0, do_pcm_list = 0;
snd_pcm_info_t *info;
+ FILE *direction;
#ifdef ENABLE_NLS
setlocale(LC_ALL, "");
@@ -511,14 +512,21 @@ int main(int argc, char *argv[])
file_type = FORMAT_WAVE;
command = "arecord";
start_delay = 1;
+ direction = stdout;
} else if (strstr(argv[0], "aplay")) {
stream = SND_PCM_STREAM_PLAYBACK;
command = "aplay";
+ direction = stdin;
} else {
error(_("command should be named either arecord or aplay"));
return 1;
}
+ if (isatty(fileno(direction)) && (argc == 1)) {
+ usage(command);
+ return 1;
+ }
+
chunk_size = -1;
rhwparams.format = DEFAULT_FORMAT;
rhwparams.rate = DEFAULT_SPEED;