aboutsummaryrefslogtreecommitdiffstats
path: root/src/dabOutput
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-05-20 22:27:24 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-05-20 22:27:24 +0200
commit4eedcf3eaa9e3b4eca2d41beaf1ac66e8fa35c7d (patch)
tree016e02c253364ee027542871b76bb05e0276238c /src/dabOutput
parent8cbf2c99e7df9090e9182c4d7ebf69614ae056c2 (diff)
downloaddabmux-4eedcf3eaa9e3b4eca2d41beaf1ac66e8fa35c7d.tar.gz
dabmux-4eedcf3eaa9e3b4eca2d41beaf1ac66e8fa35c7d.tar.bz2
dabmux-4eedcf3eaa9e3b4eca2d41beaf1ac66e8fa35c7d.zip
Remove _WIN32 code from Simul output
Diffstat (limited to 'src/dabOutput')
-rw-r--r--src/dabOutput/dabOutputSimul.cpp47
1 files changed, 6 insertions, 41 deletions
diff --git a/src/dabOutput/dabOutputSimul.cpp b/src/dabOutput/dabOutputSimul.cpp
index 347b29c..d874603 100644
--- a/src/dabOutput/dabOutputSimul.cpp
+++ b/src/dabOutput/dabOutputSimul.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2016 Matthias P. Braendli
+ Copyright (C) 2018 Matthias P. Braendli
http://mpb.li
SIMUL throttling output. It guarantees correct frame generation rate
@@ -30,63 +30,28 @@
#include <limits.h>
#include <chrono>
#include <thread>
-#ifdef _WIN32
-# include <io.h>
-# ifdef __MINGW32__
-# define FS_DECLARE_CFG_ARRAYS
-# include <winioctl.h>
-# endif
-# include <sdci.h>
-#else
-# include <unistd.h>
-# include <sys/time.h>
-# ifndef O_BINARY
-# define O_BINARY 0
-# endif // O_BINARY
-#endif
int DabOutputSimul::Open(const char* name)
{
-#ifdef _WIN32
- startTime_ = GetTickCount();
-#else
startTime_ = std::chrono::steady_clock::now();
-#endif
-
return 0;
}
int DabOutputSimul::Write(void* buffer, int size)
{
-#ifdef _WIN32
- unsigned long current;
- unsigned long start;
- unsigned long waiting;
- current = GetTickCount();
- start = this->startTime_;
- if (current < start) {
- waiting = start - current + 24;
- Sleep(waiting);
- } else {
- waiting = 24 - (current - start);
- if ((current - start) < 24) {
- Sleep(waiting);
- }
- }
- this->startTime_ += 24;
-#else
auto curTime = std::chrono::steady_clock::now();
+ const auto frameinterval = std::chrono::milliseconds(24);
+
auto diff = curTime - startTime_;
- auto waiting = std::chrono::milliseconds(24) - diff;
+ auto waiting = frameinterval - diff;
- if (diff < std::chrono::milliseconds(24)) {
+ if (diff < frameinterval) {
std::this_thread::sleep_for(waiting);
}
- startTime_ += std::chrono::milliseconds(24);
-#endif
+ startTime_ += frameinterval;
return size;
}