]> git.alsa-project.org Git - alsa-utils.git/commitdiff
aplay: Show usage if no parameter is passed
authorFabio Estevam <fabio.estevam@freescale.com>
Tue, 13 Nov 2012 12:05:39 +0000 (10:05 -0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 13 Nov 2012 13:33:40 +0000 (14:33 +0100)
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>
aplay/aplay.c

index 741979a441987278e26fdfca2a82ff93cc26b646..f35f603a7507154d9ad38922da92e5f0135fee1e 100644 (file)
@@ -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;