mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-05 00:35:39 +00:00
Reduce header footprint of optional C++ API files and export C++ symbols properly.
This commit is contained in:
@ -140,9 +140,8 @@ set_target_properties(projectM PROPERTIES
|
||||
)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(projectM
|
||||
PRIVATE
|
||||
projectM_api_EXPORTS
|
||||
set_source_files_properties(ProjectMCWrapper.cpp PROPERTIES
|
||||
COMPILE_DEFINITIONS projectM_api_EXPORTS
|
||||
)
|
||||
|
||||
target_link_libraries(projectM
|
||||
@ -150,9 +149,8 @@ if(BUILD_SHARED_LIBS)
|
||||
${CMAKE_DL_LIBS}
|
||||
)
|
||||
else()
|
||||
target_compile_definitions(projectM
|
||||
PUBLIC
|
||||
PROJECTM_STATIC_DEFINE
|
||||
set_source_files_properties(ProjectMCWrapper.cpp PROPERTIES
|
||||
COMPILE_DEFINITIONS PROJECTM_STATIC_DEFINE
|
||||
)
|
||||
|
||||
set_target_properties(projectM PROPERTIES
|
||||
@ -172,14 +170,23 @@ install(TARGETS projectM
|
||||
)
|
||||
|
||||
if(ENABLE_CXX_INTERFACE)
|
||||
set_source_files_properties(ProjectM.cpp PCM.cpp PROPERTIES
|
||||
COMPILE_DEFINITIONS projectM_api_EXPORTS
|
||||
)
|
||||
|
||||
install(FILES
|
||||
Common.hpp
|
||||
PCM.hpp
|
||||
fatal.h
|
||||
ProjectM.hpp
|
||||
DESTINATION "${PROJECTM_INCLUDE_DIR}/libprojectM"
|
||||
COMPONENT Devel
|
||||
)
|
||||
else()
|
||||
# Set PROJECTM_STATIC_EXPORT for C++ implementations to use project default visibility
|
||||
# and no dllimport/dllexport.
|
||||
set_source_files_properties(ProjectM.cpp PCM.cpp PROPERTIES
|
||||
COMPILE_DEFINITIONS PROJECTM_STATIC_DEFINE
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
@ -18,14 +18,8 @@
|
||||
* See 'LICENSE.txt' included within this release
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
*/
|
||||
|
||||
#ifndef COMMON_HPP
|
||||
#define COMMON_HPP
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@ -93,5 +87,3 @@ inline auto ParseFilename(const std::string& filename) -> std::string
|
||||
|
||||
return filename.substr(start + 1, filename.length());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -47,6 +47,8 @@ target_include_directories(MilkdropPresetFactory
|
||||
)
|
||||
|
||||
target_link_libraries(MilkdropPresetFactory
|
||||
PRIVATE
|
||||
libprojectM::API # For export header
|
||||
PUBLIC
|
||||
GLM::GLM
|
||||
${PROJECTM_OPENGL_LIBRARIES}
|
||||
|
||||
@ -26,8 +26,9 @@
|
||||
* $Log$
|
||||
*/
|
||||
|
||||
#ifndef _PCM_H
|
||||
#define _PCM_H
|
||||
#pragma once
|
||||
|
||||
#include "libprojectM/projectM_export.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
@ -46,7 +47,7 @@ enum CHANNEL
|
||||
CHANNEL_1 = 1
|
||||
};
|
||||
|
||||
class Pcm
|
||||
PROJECTM_EXPORT class Pcm
|
||||
{
|
||||
public:
|
||||
/* maximum number of sound samples that are actually stored. */
|
||||
@ -155,5 +156,3 @@ private:
|
||||
double m_level{1.f};
|
||||
AutoLevel m_leveler{};
|
||||
};
|
||||
|
||||
#endif /** !_PCM_H */
|
||||
|
||||
@ -30,10 +30,19 @@
|
||||
#include "Renderer/PipelineContext.hpp"
|
||||
#include "TimeKeeper.hpp"
|
||||
|
||||
#if USE_THREADS
|
||||
|
||||
#include "libprojectM/BackgroundWorker.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
ProjectM::ProjectM()
|
||||
: m_pipelineContext(std::make_unique<class PipelineContext>())
|
||||
: m_presetFactoryManager(std::make_unique<PresetFactoryManager>())
|
||||
, m_pipelineContext(std::make_unique<class PipelineContext>())
|
||||
, m_pipelineContext2(std::make_unique<class PipelineContext>())
|
||||
#if USE_THREADS
|
||||
, m_workerSync(std::make_unique<BackgroundWorkerSync>())
|
||||
#endif
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
@ -41,7 +50,7 @@ ProjectM::ProjectM()
|
||||
ProjectM::~ProjectM()
|
||||
{
|
||||
#if USE_THREADS
|
||||
m_workerSync.FinishUp();
|
||||
m_workerSync->FinishUp();
|
||||
m_workerThread.join();
|
||||
#endif
|
||||
}
|
||||
@ -64,7 +73,7 @@ void ProjectM::LoadPresetFile(const std::string& presetFilename, bool smoothTran
|
||||
|
||||
try
|
||||
{
|
||||
StartPresetTransition(m_presetFactoryManager.CreatePresetFromFile(presetFilename), !smoothTransition);
|
||||
StartPresetTransition(m_presetFactoryManager->CreatePresetFromFile(presetFilename), !smoothTransition);
|
||||
}
|
||||
catch (const PresetFactoryException& ex)
|
||||
{
|
||||
@ -82,7 +91,7 @@ void ProjectM::LoadPresetData(std::istream& presetData, bool smoothTransition)
|
||||
|
||||
try
|
||||
{
|
||||
StartPresetTransition(m_presetFactoryManager.CreatePresetFromStream(".milk", presetData), !smoothTransition);
|
||||
StartPresetTransition(m_presetFactoryManager->CreatePresetFromStream(".milk", presetData), !smoothTransition);
|
||||
}
|
||||
catch (const PresetFactoryException& ex)
|
||||
{
|
||||
@ -117,12 +126,12 @@ void ProjectM::ThreadWorker()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (!m_workerSync.WaitForWork())
|
||||
if (!m_workerSync->WaitForWork())
|
||||
{
|
||||
return;
|
||||
}
|
||||
EvaluateSecondPreset();
|
||||
m_workerSync.FinishedWork();
|
||||
m_workerSync->FinishedWork();
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,9 +203,9 @@ auto ProjectM::RenderFrameOnlyPass1(Pipeline* pipeline) -> Pipeline*
|
||||
if (m_timeKeeper->IsSmoothing() && m_transitioningPreset != nullptr)
|
||||
{
|
||||
#if USE_THREADS
|
||||
m_workerSync.WakeUpBackgroundTask();
|
||||
m_workerSync->WakeUpBackgroundTask();
|
||||
// FIXME: Instead of waiting after a single render pass, check every frame if it's done.
|
||||
m_workerSync.WaitForBackgroundTaskToFinish();
|
||||
m_workerSync->WaitForBackgroundTaskToFinish();
|
||||
#endif
|
||||
EvaluateSecondPreset();
|
||||
|
||||
@ -265,7 +274,7 @@ void ProjectM::Reset()
|
||||
{
|
||||
this->m_count = 0;
|
||||
|
||||
m_presetFactoryManager.initialize(m_meshX, m_meshY);
|
||||
m_presetFactoryManager->initialize(m_meshX, m_meshY);
|
||||
|
||||
ResetEngine();
|
||||
}
|
||||
@ -293,7 +302,7 @@ void ProjectM::Initialize()
|
||||
m_beatDetect.get(),
|
||||
m_textureSearchPaths);
|
||||
|
||||
m_presetFactoryManager.initialize(m_meshX, m_meshY);
|
||||
m_presetFactoryManager->initialize(m_meshX, m_meshY);
|
||||
|
||||
/* Set the seed to the current time in seconds */
|
||||
srand(time(nullptr));
|
||||
@ -302,7 +311,7 @@ void ProjectM::Initialize()
|
||||
LoadIdlePreset();
|
||||
|
||||
#if USE_THREADS
|
||||
m_workerSync.Reset();
|
||||
m_workerSync->Reset();
|
||||
m_workerThread = std::thread(&ProjectM::ThreadWorker, this);
|
||||
#endif
|
||||
|
||||
@ -523,7 +532,7 @@ void ProjectM::SetMeshSize(size_t meshResolutionX, size_t meshResolutionY)
|
||||
|
||||
// Update mesh size in all sorts of classes.
|
||||
m_renderer->SetPerPixelMeshSize(m_meshX, m_meshY);
|
||||
m_presetFactoryManager.initialize(m_meshX, m_meshY);
|
||||
m_presetFactoryManager->initialize(m_meshX, m_meshY);
|
||||
|
||||
// Unload all presets and reload idle preset
|
||||
m_activePreset.reset();
|
||||
|
||||
@ -20,10 +20,10 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Common.hpp"
|
||||
#include "PCM.hpp"
|
||||
#include "PresetFactoryManager.hpp"
|
||||
#include "fatal.h"
|
||||
#include "libprojectM/projectM_export.h"
|
||||
|
||||
#include "libprojectM/Common.hpp"
|
||||
#include "libprojectM/PCM.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@ -41,13 +41,13 @@
|
||||
|
||||
#if USE_THREADS
|
||||
|
||||
#include "BackgroundWorker.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#endif
|
||||
|
||||
class BackgroundWorkerSync;
|
||||
|
||||
class BeatDetect;
|
||||
|
||||
class Pcm;
|
||||
@ -64,7 +64,9 @@ class Pipeline;
|
||||
|
||||
class PipelineContext;
|
||||
|
||||
class ProjectM
|
||||
class PresetFactoryManager;
|
||||
|
||||
PROJECTM_EXPORT class ProjectM
|
||||
{
|
||||
public:
|
||||
ProjectM();
|
||||
@ -246,43 +248,43 @@ private:
|
||||
|
||||
class Pcm m_pcm; //!< Audio data buffer and analyzer instance.
|
||||
|
||||
size_t m_meshX{32}; //!< Per-point mesh horizontal resolution.
|
||||
size_t m_meshY{24}; //!< Per-point mesh vertical resolution.
|
||||
size_t m_targetFps{35}; //!< Target frames per second.
|
||||
size_t m_textureSize{512}; //!< Render texture size.
|
||||
size_t m_windowWidth{0}; //!< Render window width. If 0, nothing is rendered.
|
||||
size_t m_windowHeight{0}; //!< Render window height. If 0, nothing is rendered.
|
||||
double m_presetDuration{30.0}; //!< Preset duration in seconds.
|
||||
double m_softCutDuration{3.0}; //!< Soft cut transition time.
|
||||
double m_hardCutDuration{20.0}; //!< Time after which a hard cut can happen at the earliest.
|
||||
bool m_hardCutEnabled{false}; //!< If true, hard cuts based on beat detection are enabled.
|
||||
size_t m_meshX{32}; //!< Per-point mesh horizontal resolution.
|
||||
size_t m_meshY{24}; //!< Per-point mesh vertical resolution.
|
||||
size_t m_targetFps{35}; //!< Target frames per second.
|
||||
size_t m_textureSize{512}; //!< Render texture size.
|
||||
size_t m_windowWidth{0}; //!< Render window width. If 0, nothing is rendered.
|
||||
size_t m_windowHeight{0}; //!< Render window height. If 0, nothing is rendered.
|
||||
double m_presetDuration{30.0}; //!< Preset duration in seconds.
|
||||
double m_softCutDuration{3.0}; //!< Soft cut transition time.
|
||||
double m_hardCutDuration{20.0}; //!< Time after which a hard cut can happen at the earliest.
|
||||
bool m_hardCutEnabled{false}; //!< If true, hard cuts based on beat detection are enabled.
|
||||
float m_hardCutSensitivity{2.0}; //!< Loudness sensitivity value for hard cuts.
|
||||
float m_beatSensitivity{1.0}; //!< General beat sensitivity modifier for presets.
|
||||
bool m_aspectCorrection{true}; //!< If true, corrects aspect ratio for non-rectangular windows.
|
||||
float m_easterEgg{0.0}; //!< Random preset duration modifier. See TimeKeeper class.
|
||||
float m_beatSensitivity{1.0}; //!< General beat sensitivity modifier for presets.
|
||||
bool m_aspectCorrection{true}; //!< If true, corrects aspect ratio for non-rectangular windows.
|
||||
float m_easterEgg{0.0}; //!< Random preset duration modifier. See TimeKeeper class.
|
||||
|
||||
std::vector<std::string> m_textureSearchPaths; ///!< List of paths to search for texture files
|
||||
|
||||
/** Timing information */
|
||||
int m_count{0}; //!< Rendered frame count since start
|
||||
|
||||
bool m_presetLocked{false}; //!< If true, the preset change event will not be sent.
|
||||
bool m_presetLocked{false}; //!< If true, the preset change event will not be sent.
|
||||
bool m_presetChangeNotified{false}; //!< Stores whether the user has been notified that projectM wants to switch the preset.
|
||||
|
||||
PresetFactoryManager m_presetFactoryManager; //!< Provides access to all available preset factories.
|
||||
std::unique_ptr<PresetFactoryManager> m_presetFactoryManager; //!< Provides access to all available preset factories.
|
||||
|
||||
std::unique_ptr<class PipelineContext> m_pipelineContext; //!< Pipeline context for the first/current preset.
|
||||
std::unique_ptr<class PipelineContext> m_pipelineContext2; //!< Pipeline context for the next/transitioning preset.
|
||||
|
||||
std::unique_ptr<Renderer> m_renderer; //!< The Preset renderer.
|
||||
std::unique_ptr<BeatDetect> m_beatDetect; //!< The beat detection class.
|
||||
std::unique_ptr<Preset> m_activePreset; //!< Currently loaded preset.
|
||||
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.
|
||||
std::unique_ptr<Renderer> m_renderer; //!< The Preset renderer.
|
||||
std::unique_ptr<BeatDetect> m_beatDetect; //!< The beat detection class.
|
||||
std::unique_ptr<Preset> m_activePreset; //!< Currently loaded preset.
|
||||
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
|
||||
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.
|
||||
BackgroundWorkerSync m_workerSync; //!< Background work synchronizer.
|
||||
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.
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -55,6 +55,8 @@ target_include_directories(Renderer
|
||||
)
|
||||
|
||||
target_link_libraries(Renderer
|
||||
PRIVATE
|
||||
libprojectM::API # For export header
|
||||
PUBLIC
|
||||
GLM::GLM
|
||||
hlslparser
|
||||
|
||||
Reference in New Issue
Block a user