summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-05-16 14:53:45 +0100
committerLeah Rowe <leah@libreboot.org>2023-05-16 23:11:35 +0100
commit25241ae22242eb7d178f4a76f2761987a5022d36 (patch)
tree09fbb973777eaca84f1b42f8341676401f8421e5
parent01fdfa3ab67ebe6124acd38dcf789cb86bee77b5 (diff)
util/spkmodem_recv: Add -u flag (no line buffer)
printf outputs to stdout, which is line buffered by default. Adding a -u option to disable buffering. Exit when a non-support flag is given, but adhere to current behaviour when no flag is given. Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--util/spkmodem_recv/spkmodem-recv.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c
index b4179d80..efc690ba 100644
--- a/util/spkmodem_recv/spkmodem-recv.c
+++ b/util/spkmodem_recv/spkmodem-recv.c
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
/* Compilation: gcc -o spkmodem-recv spkmodem-recv */
/* Usage: parec --channels=1 --rate=48000 --format=s16le | ./spkmodem-recv */
@@ -33,7 +34,17 @@ void fetch_sample(void);
int
main(int argc, char *argv[])
{
- (void)argc; (void)argv;
+ int c;
+
+ while ((c = getopt(argc, argv, "u")) != -1) {
+ switch (c) {
+ case 'u':
+ setvbuf(stdout, NULL, _IONBF, 0);
+ break;
+ default:
+ err(errno = EINVAL, NULL);
+ }
+ }
while (!feof(stdin))
handle_audio();