summaryrefslogtreecommitdiff
path: root/src/specgram.cpp
diff options
context:
space:
mode:
authorVasile Vilvoiu <vasi@vilvoiu.ro>2023-05-06 20:40:52 +0300
committerVasile Vilvoiu <vasi@vilvoiu.ro>2023-05-06 20:40:52 +0300
commitf2f4792f824cd64e679cdc859fb008769541257b (patch)
treed2ee924bd8945dbf4112afa365aaa822dfea34bc /src/specgram.cpp
parent2ebb152342283a2237bc7ca2dd96baf3cac0d56e (diff)
Add support for waiting for input.
Introduce -S/--sleep_for_input command line argument. Closes #17.
Diffstat (limited to 'src/specgram.cpp')
-rw-r--r--src/specgram.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/specgram.cpp b/src/specgram.cpp
index 0cd9635..5e5e30c 100644
--- a/src/specgram.cpp
+++ b/src/specgram.cpp
@@ -21,6 +21,8 @@
#include <random>
#include <cstdio>
#include <cassert>
+#include <thread>
+#include <chrono>
/* main loop exit condition */
volatile bool main_loop_running = true;
@@ -237,6 +239,10 @@ main(int argc, char** argv)
auto block = reader->GetBlock();
if (!block) {
/* block not finished yet */
+ if (auto sleep = conf.GetSleepForInput()) {
+ /* sleep for a bit so we don't busywait on sparse input */
+ std::this_thread::sleep_for(std::chrono::duration<size_t, std::milli>(sleep));
+ }
continue;
}