diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 38616fcfc..7c7d1fd61 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -29,8 +29,16 @@ endif() ####################################################################################################################### # build options -set(CARLA_USE_JACK TRUE CACHE BOOL "Enable JACK") -set(CARLA_USE_OSC TRUE CACHE BOOL "Enable OSC") +if(MSVC) + set(CARLA_USE_JACK_DEFAULT FALSE) + set(CARLA_USE_OSC_DEFAULT FALSE) +else() + set(CARLA_USE_JACK_DEFAULT TRUE) + set(CARLA_USE_OSC_DEFAULT TRUE) +endif() + +set(CARLA_USE_JACK TRUE CACHE ${CARLA_USE_JACK_DEFAULT} "Enable JACK") +set(CARLA_USE_OSC TRUE CACHE ${CARLA_USE_OSC_DEFAULT} "Enable OSC") ####################################################################################################################### # required dependencies diff --git a/source/backend/engine/CarlaEngineDummy.cpp b/source/backend/engine/CarlaEngineDummy.cpp index d30ff2f97..0d7c8f9a2 100644 --- a/source/backend/engine/CarlaEngineDummy.cpp +++ b/source/backend/engine/CarlaEngineDummy.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2020 Filipe Coelho + * Copyright (C) 2011-2023 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,9 +18,7 @@ #include "CarlaEngineGraph.hpp" #include "CarlaEngineInit.hpp" #include "CarlaEngineInternal.hpp" - -#include -#include +#include "CarlaTimeUtils.hpp" CARLA_BACKEND_START_NAMESPACE @@ -192,25 +190,6 @@ public: // ------------------------------------------------------------------- protected: - static int64_t getTimeInMicroseconds() noexcept - { - #if defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN) - struct timeval tv; - gettimeofday(&tv, nullptr); - - 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 - } - void run() override { const uint32_t bufferSize = pData->bufferSize; @@ -250,7 +229,7 @@ protected: if (delay > 0) carla_sleep(static_cast(delay)); - oldTime = getTimeInMicroseconds(); + oldTime = carla_gettime_us(); const PendingRtEventsRunner prt(this, bufferSize, true); @@ -260,7 +239,7 @@ protected: pData->graph.process(pData, audioIns, audioOuts, bufferSize); - newTime = getTimeInMicroseconds(); + newTime = carla_gettime_us(); CARLA_SAFE_ASSERT_CONTINUE(newTime >= oldTime); const int64_t remainingTime = cycleTime - (newTime - oldTime); diff --git a/source/utils/CarlaLogThread.hpp b/source/utils/CarlaLogThread.hpp index 7b7e9e32d..beb3ae0c8 100644 --- a/source/utils/CarlaLogThread.hpp +++ b/source/utils/CarlaLogThread.hpp @@ -1,6 +1,6 @@ /* * Carla Log Thread - * Copyright (C) 2013-2022 Filipe Coelho + * Copyright (C) 2013-2023 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -24,12 +24,6 @@ #include -#ifdef CARLA_OS_WIN -# include -# define _close(fd) close(fd) -# define _dup2(f1,f2) dup2(f1,f2) -#endif - using CARLA_BACKEND_NAMESPACE::EngineCallbackFunc; // ----------------------------------------------------------------------- @@ -55,7 +49,7 @@ public: std::fflush(stdout); std::fflush(stderr); -#ifdef CARLA_OS_WIN + #ifdef CARLA_OS_WIN // TODO: use process id instead const int randint = std::rand(); @@ -70,7 +64,9 @@ public: CARLA_SAFE_ASSERT_RETURN(fPipe[1] != INVALID_HANDLE_VALUE,); const int pipe1 = _open_osfhandle((INT_PTR)fPipe[1], _O_WRONLY | _O_BINARY); -#else + const int stdout_fileno = _fileno(stdout); + const int stderr_fileno = _fileno(stderr); + #else CARLA_SAFE_ASSERT_RETURN(pipe(fPipe) == 0,); if (fcntl(fPipe[0], F_SETFL, O_NONBLOCK) != 0) @@ -81,13 +77,15 @@ public: } const int pipe1 = fPipe[1]; -#endif + const int stdout_fileno = STDOUT_FILENO; + const int stderr_fileno = STDERR_FILENO; + #endif - fStdOut = dup(STDOUT_FILENO); + fStdOut = dup(stdout_fileno); fStdErr = dup(STDERR_FILENO); - dup2(pipe1, STDOUT_FILENO); - dup2(pipe1, STDERR_FILENO); + dup2(pipe1, stdout_fileno); + dup2(pipe1, stderr_fileno); startThread(); } @@ -102,13 +100,19 @@ public: std::fflush(stdout); std::fflush(stderr); -#ifdef CARLA_OS_WIN + #ifdef CARLA_OS_WIN CloseHandle(fPipe[0]); CloseHandle(fPipe[1]); -#else + + const int stdout_fileno = _fileno(stdout); + const int stderr_fileno = _fileno(stderr); + #else close(fPipe[0]); close(fPipe[1]); -#endif + + const int stdout_fileno = STDOUT_FILENO; + const int stderr_fileno = STDERR_FILENO; + #endif dup2(fStdOut, STDOUT_FILENO); dup2(fStdErr, STDERR_FILENO); @@ -193,11 +197,11 @@ protected: } private: -#ifdef CARLA_OS_WIN + #ifdef CARLA_OS_WIN HANDLE fPipe[2]; -#else + #else int fPipe[2]; -#endif + #endif int fStdOut; int fStdErr; @@ -205,14 +209,14 @@ private: EngineCallbackFunc fCallback; void* fCallbackPtr; -#ifdef CARLA_OS_WIN + #ifdef CARLA_OS_WIN ssize_t read(const HANDLE pipeh, void* const buf, DWORD numBytes) { if (ReadFile(pipeh, buf, numBytes, &numBytes, nullptr) != FALSE) return numBytes; return -1; } -#endif + #endif //CARLA_PREVENT_HEAP_ALLOCATION CARLA_DECLARE_NON_COPYABLE(CarlaLogThread)