Rename USE_THREADS to PROJECTM_USE_THREADS and export it in the package config file.

PROJECTM_USE_THREADS is only exported if ENABLE_CXX_INTERFACE is ON.
This commit is contained in:
Kai Blaschke
2023-01-24 17:56:12 +01:00
parent 97519a81e6
commit bcaf98f2f1
5 changed files with 20 additions and 13 deletions

View File

@ -161,7 +161,7 @@ else()
if(ENABLE_THREADING)
find_package(Threads REQUIRED)
set(USE_THREADS YES)
set(PROJECTM_USE_THREADS YES)
endif()
if(ENABLE_LLVM)

View File

@ -66,8 +66,8 @@
/* Define USE_GLES */
#cmakedefine01 USE_GLES
/* Define USE_THREADS */
#cmakedefine01 USE_THREADS
/* Define PROJECTM_USE_THREADS */
#cmakedefine01 PROJECTM_USE_THREADS
/* Version number of package */
#define VERSION "@PROJECT_VERSION@"

View File

@ -170,6 +170,13 @@ install(TARGETS projectM
)
if(ENABLE_CXX_INTERFACE)
if(ENABLE_THREADING)
target_compile_definitions(projectM
INTERFACE
PROJECTM_USE_THREADS
)
endif()
set_source_files_properties(ProjectM.cpp PCM.cpp PROPERTIES
COMPILE_DEFINITIONS projectM_api_EXPORTS
)

View File

@ -30,7 +30,7 @@
#include "Renderer/PipelineContext.hpp"
#include "TimeKeeper.hpp"
#if USE_THREADS
#if PROJECTM_USE_THREADS
#include "libprojectM/BackgroundWorker.hpp"
@ -40,7 +40,7 @@ ProjectM::ProjectM()
: m_presetFactoryManager(std::make_unique<PresetFactoryManager>())
, m_pipelineContext(std::make_unique<class PipelineContext>())
, m_pipelineContext2(std::make_unique<class PipelineContext>())
#if USE_THREADS
#if PROJECTM_USE_THREADS
, m_workerSync(std::make_unique<BackgroundWorkerSync>())
#endif
{
@ -49,7 +49,7 @@ ProjectM::ProjectM()
ProjectM::~ProjectM()
{
#if USE_THREADS
#if PROJECTM_USE_THREADS
m_workerSync->FinishUp();
m_workerThread.join();
#endif
@ -120,7 +120,7 @@ void ProjectM::DumpDebugImageOnNextFrame()
m_renderer->writeNextFrameToFile = true;
}
#if USE_THREADS
#if PROJECTM_USE_THREADS
void ProjectM::ThreadWorker()
{
@ -166,7 +166,7 @@ void ProjectM::RenderFrame()
auto ProjectM::RenderFrameOnlyPass1(Pipeline* pipeline) -> Pipeline*
{
#if USE_THREADS
#if PROJECTM_USE_THREADS
std::lock_guard<std::recursive_mutex> guard(m_presetSwitchMutex);
#endif
@ -202,7 +202,7 @@ auto ProjectM::RenderFrameOnlyPass1(Pipeline* pipeline) -> Pipeline*
if (m_timeKeeper->IsSmoothing() && m_transitioningPreset != nullptr)
{
#if USE_THREADS
#if PROJECTM_USE_THREADS
m_workerSync->WakeUpBackgroundTask();
// FIXME: Instead of waiting after a single render pass, check every frame if it's done.
m_workerSync->WaitForBackgroundTaskToFinish();
@ -310,7 +310,7 @@ void ProjectM::Initialize()
ResetEngine();
LoadIdlePreset();
#if USE_THREADS
#if PROJECTM_USE_THREADS
m_workerSync->Reset();
m_workerThread = std::thread(&ProjectM::ThreadWorker, this);
#endif

View File

@ -39,7 +39,7 @@
#include <string>
#include <vector>
#if USE_THREADS
#if PROJECTM_USE_THREADS
#include <mutex>
#include <thread>
@ -240,7 +240,7 @@ private:
void LoadIdlePreset();
#if USE_THREADS
#if PROJECTM_USE_THREADS
void ThreadWorker();
@ -282,7 +282,7 @@ private:
std::unique_ptr<Preset> m_transitioningPreset; //!< Destination preset when smooth preset switching.
std::unique_ptr<TimeKeeper> m_timeKeeper; //!< Keeps the different timers used to render and switch presets.
#if USE_THREADS
#if PROJECTM_USE_THREADS
mutable std::recursive_mutex m_presetSwitchMutex; //!< Mutex for locking preset switching while rendering and vice versa.
std::thread m_workerThread; //!< Background worker for preloading presets.
std::unique_ptr<BackgroundWorkerSync> m_workerSync; //!< Background work synchronizer.