From a7ffc2bfa35c21679a078fb9845b6031dbe32b5f Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 14 Feb 2019 01:30:43 +0100 Subject: [PATCH] Fix build of new code on old systems and mac/win Signed-off-by: falkTX --- source/backend/engine/CarlaEngineInternal.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/source/backend/engine/CarlaEngineInternal.cpp b/source/backend/engine/CarlaEngineInternal.cpp index 09fabec79..b71f9ea2f 100644 --- a/source/backend/engine/CarlaEngineInternal.cpp +++ b/source/backend/engine/CarlaEngineInternal.cpp @@ -642,10 +642,21 @@ void CarlaEngine::ProtectedData::doNextPluginAction() noexcept static int64_t getTimeInMicroseconds() noexcept { - struct timespec t; - clock_gettime(CLOCK_MONOTONIC_RAW, &t); +#if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN) + struct timeval tv; + gettimeofday(&tv, nullptr); - return (t.tv_sec * 1000000) + (t.tv_nsec / 1000); + return (tv.tv_sec * 1000000) + tv.tv_usec; +#else + struct timespec ts; +# ifdef CLOCK_MONOTONIC_RAW + clock_gettime(CLOCK_MONOTONIC_RAW, &ts); +# else + clock_gettime(CLOCK_MONOTONIC, &ts); +# endif + + return (ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); +#endif } PendingRtEventsRunner::PendingRtEventsRunner(CarlaEngine* const engine, @@ -676,7 +687,7 @@ PendingRtEventsRunner::~PendingRtEventsRunner() noexcept if (dspLoad > pData->dspLoad) pData->dspLoad = std::min(100.0f, dspLoad); else - pData->dspLoad *= static_cast(1.0 - maxTime); + pData->dspLoad *= static_cast(1.0 - maxTime) + 1e-12f; } #endif }