diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-03-23 00:03:29 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-03-23 00:03:29 +0100 |
commit | 2cf0eaffddab2457fc81d672599c0f58eb6950f9 (patch) | |
tree | f1964cdc4d9a4f7ff8ffa15b2a359cdad55a58d8 /src/fl2k_file.c | |
parent | eb11e68412b49b0945ab6bb332ac9486f1ebeb9e (diff) | |
parent | df33203db5007218384e6724748be52a1d4fdb25 (diff) | |
download | osmo-fl2k-2cf0eaffddab2457fc81d672599c0f58eb6950f9.tar.gz osmo-fl2k-2cf0eaffddab2457fc81d672599c0f58eb6950f9.tar.bz2 osmo-fl2k-2cf0eaffddab2457fc81d672599c0f58eb6950f9.zip |
Merge remote-tracking branch 'upstream/master' into interleaved_rg
Diffstat (limited to 'src/fl2k_file.c')
-rw-r--r-- | src/fl2k_file.c | 26 |
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); |