[alsa-devel] [PATCH v2 1/2] 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 --- Changes since v1: - Also check for isatty, so that 'aplay < file.wav' can still work
aplay/aplay.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/aplay/aplay.c b/aplay/aplay.c index 741979a..38459e6 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -519,6 +519,11 @@ int main(int argc, char *argv[]) return 1; }
+ if (isatty(fileno(stdin)) && (argc == 1)) { + usage(command); + return 0; + } + chunk_size = -1; rhwparams.format = DEFAULT_FORMAT; rhwparams.rate = DEFAULT_SPEED;
When ac3dec is 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 --- Changes since v1: - Also check for isatty, so that 'ac3dec < file.wav' can still work ac3dec/ac3dec.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/ac3dec/ac3dec.c b/ac3dec/ac3dec.c index 00c4f1a..ce6c507 100644 --- a/ac3dec/ac3dec.c +++ b/ac3dec/ac3dec.c @@ -130,6 +130,11 @@ int main(int argc,char *argv[]) out_config.spdif = SPDIF_NONE; out_config.hdmi = 0;
+ if (isatty(fileno(stdin)) && (argc == 1)) { + help(); + return 0; + } + morehelp = 0; while (1) { int c;
At Tue, 13 Nov 2012 09:06:02 -0200, Fabio Estevam wrote:
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
Changes since v1:
- Also check for isatty, so that 'aplay < file.wav' can still work
aplay/aplay.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/aplay/aplay.c b/aplay/aplay.c index 741979a..38459e6 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -519,6 +519,11 @@ int main(int argc, char *argv[]) return 1; }
- if (isatty(fileno(stdin)) && (argc == 1)) {
usage(command);
return 0;
Do we want to abort the program with the exit code 0 in such a case? I haven't checked exactly how other programs do, but I thought it returns an error (e.g. 1) in most cases.
thanks,
Takashi
Fabio Estevam wrote:
When aplay/arecord are called without any argument the application hangs forever.
- if (isatty(fileno(stdin)) && (argc == 1)) {
And that would be stdout for arecord. :)
Regards, Clemens
participants (3)
-
Clemens Ladisch
-
Fabio Estevam
-
Takashi Iwai