Skip to contentSkip to conversation

ac3dec: Show usage if no parameter is passed

PATCH Applied Fabio Estevam 2 participants 2 messages Nov 13, 2012

lore
Share & tools
lore
#0 lore raw

PATCH v4 2/2 ac3dec: Show usage if no parameter is passed

When ac3dec is called without any argument the application hangs forever.

Instead of hanging, print the usage and exit.

---
Changes since v3:
- Fix return value
Changes since v2:
- No changes
Changes since v1:
- Also check for isatty, so that 'ac3dec < file.wav' can still work

 ac3dec/ac3dec.c |    5 +++++
 1 file changed, 5 insertions(+)
ac3dec/ac3dec.c +5 -0
index 00c4f1a..ce6c507 100644
@@ -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 1;
+	}
+
 	morehelp = 0;
 	while (1) {
 		int c;
Signature · 1 line
1.7.9.5
Applied
#1 lore raw

At Tue, 13 Nov 2012 10:08:14 -0200,

Quoted 6 lines · Fabio Estevam

When ac3dec is called without any argument the application hangs forever.

Instead of hanging, print the usage and exit.

Thanks, applied.

Takashi

Quoted 30 lines

---
Changes since v3:
- Fix return value
Changes since v2:
- No changes
Changes since v1:
- Also check for isatty, so that 'ac3dec < file.wav' can still work

 ac3dec/ac3dec.c |    5 +++++
 1 file changed, 5 insertions(+)
ac3dec/ac3dec.c +5 -0
index 00c4f1a..ce6c507 100644
@@ -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 1;
+	}
+
 	morehelp = 0;
 	while (1) {
 		int c;
Signature · 1 line
1.7.9.5