aboutsummaryrefslogtreecommitdiffstats
path: root/src/fl2k_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fl2k_file.c')
-rw-r--r--src/fl2k_file.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/fl2k_file.c b/src/fl2k_file.c
index 0da1cbc..2cea6ff 100644
--- a/src/fl2k_file.c
+++ b/src/fl2k_file.c
@@ -28,11 +28,13 @@
#ifndef _WIN32
#include <unistd.h>
+#define sleep_ms(ms) usleep(ms*1000)
#else
#include <windows.h>
#include <io.h>
#include <fcntl.h>
#include "getopt/getopt.h"
+#define sleep_ms(ms) Sleep(ms)
#endif
#include "osmo-fl2k.h"
@@ -156,10 +158,17 @@ int main(int argc, char **argv)
if (dev_index < 0)
exit(1);
- file = fopen(filename, "rb");
- if (!file) {
- fprintf(stderr, "Failed to open %s\n", filename);
- goto out;
+ if (strcmp(filename, "-") == 0) { /* Read samples from stdin */
+ file = stdin;
+#ifdef _WIN32
+ _setmode(_fileno(stdin), _O_BINARY);
+#endif
+ } else {
+ file = fopen(filename, "rb");
+ if (!file) {
+ fprintf(stderr, "Failed to open %s\n", filename);
+ return -ENOENT;
+ }
}
txbuf = malloc(FL2K_BUF_LEN * (interleaved ? 2 : 1));
@@ -195,13 +204,8 @@ int main(int argc, char **argv)
SetConsoleCtrlHandler( (PHANDLER_ROUTINE) sighandler, TRUE );
#endif
- while (!do_exit) {
-#ifndef _WIN32
- usleep(500000);
-#else
- Sleep(0.5);
-#endif
- }
+ while (!do_exit)
+ sleep_ms(500);
fl2k_close(dev);