From 4eedcf3eaa9e3b4eca2d41beaf1ac66e8fa35c7d Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 20 May 2018 22:27:24 +0200 Subject: Remove _WIN32 code from Simul output --- src/dabOutput/dabOutputSimul.cpp | 47 +++++----------------------------------- 1 file 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 #include #include -#ifdef _WIN32 -# include -# ifdef __MINGW32__ -# define FS_DECLARE_CFG_ARRAYS -# include -# endif -# include -#else -# include -# include -# 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; } -- cgit v1.2.3