Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
9c80041
Add CLAP 1.1.3 submodule
messmerd Dec 31, 2023
7b630bd
Add submodule again; Add CLAP to CMake
messmerd Dec 31, 2023
b443722
Remove CLAP submodule from old location
messmerd Dec 31, 2023
c51390c
Locate and init CLAP plugins
messmerd Dec 19, 2022
5e2866e
Add CLAP logo
messmerd Jan 22, 2023
ae61e5c
Update CLAP to version 1.1.6
messmerd Jan 22, 2023
1e17502
Add clap-helpers submodule
messmerd Jan 24, 2023
4992b2a
Refactor ClapManager
messmerd Jan 29, 2023
1617b05
Move ClapFile/ClapPlugin into their own source files
messmerd Jan 29, 2023
b088038
Add PluginIssueHash
messmerd Dec 31, 2023
230c953
Add missing ClapFile.h/cpp; Start implementing ClapPorts
messmerd Jan 29, 2023
2469d9f
Add ClapSubPluginFeatures
messmerd Jan 29, 2023
3de14c1
Add ClapEffect (currently non-functional)
messmerd Jan 29, 2023
ed63855
Improve effect description widget text
messmerd Jan 29, 2023
ee87f4e
Refactor to support plugin instances
messmerd Jan 30, 2023
987c9ff
More refactoring
messmerd Jan 31, 2023
10f48a6
Refactor + fix ownership issues
messmerd Feb 2, 2023
c20c075
Progress
messmerd Feb 13, 2023
1763e5a
Fix audio buffers and plugin state
messmerd Feb 13, 2023
0dd0905
Copy audio buffers; Implement CLAP_EXT_LOG
messmerd Feb 17, 2023
c3821d9
Fix crash when initializing some CLAP plugins
messmerd Feb 17, 2023
ec27096
Allocate audio buffers - some CLAP effects work now
messmerd Feb 17, 2023
4bede10
Fix crash, implement thread check extension, and more
messmerd Feb 24, 2023
35c7dcf
Fix edge case
messmerd Feb 24, 2023
c891ab2
Begin implementing params
messmerd Feb 26, 2023
01e2dd8
Minor changes
messmerd Mar 12, 2023
c1827fa
Progress on params
messmerd Mar 12, 2023
cdfea27
Parameter automation mostly works now
messmerd Mar 12, 2023
961e4f8
Use CheckControl; Minor improvements
messmerd Mar 13, 2023
b5b6ae3
Modify CustomTextKnob to provide "dynamic" text option
messmerd Dec 31, 2023
72e8034
Implement ClapControlBase::reload()
messmerd Apr 30, 2023
2fb00cc
Fix failed assert
messmerd May 1, 2023
cc397ab
Fix build
messmerd Dec 31, 2023
1c2326b
Update CLAP to version 1.1.8
messmerd Aug 28, 2023
7f171e3
Update clap-helpers
messmerd Aug 28, 2023
346595d
Fix crash when loading LSP plugin ports
messmerd Aug 28, 2023
b1923ff
Safer param creation
messmerd Sep 24, 2023
b3cb37e
Style fixes + better memory/thread safety
messmerd Sep 24, 2023
983838d
Fix build
messmerd Sep 25, 2023
a9cc62e
Stop using RTLD_DEEPBIND to allow ASan to work; Modify method names
messmerd Sep 25, 2023
eaf8f77
Fail gracefully when plugin parameter is invalid
messmerd Sep 25, 2023
dc32273
Implement transport event; Better state transitions
messmerd Dec 31, 2023
ca41492
Fix CLAP file deinit; Fix some memory issues; Minor changes
messmerd Sep 28, 2023
fe6166d
Use ArrayVector
messmerd Sep 30, 2023
8c4f78f
Param init improvements; Minor changes
messmerd Sep 30, 2023
084acd6
Add empty latency extension impl to prevent DISTRHO plugin crashes
messmerd Oct 1, 2023
2abc80d
Start implementing CLAP instruments
messmerd Oct 2, 2023
a0dd5fc
Ensure CLAP plugins start on main thread
messmerd Oct 2, 2023
7b38b5e
Fix null pointer dereference when input port doesn't exist
messmerd Oct 2, 2023
c37346a
Use ringbuffer for midi events
messmerd Oct 4, 2023
b782016
Support steady time
messmerd Oct 4, 2023
5e64b1e
Implement transport beats info; Set transport flags correctly
messmerd Oct 5, 2023
03773ba
Add ClapTransport class
messmerd Oct 6, 2023
77975ac
Refactor some window embedding code in preparation for CLAP GUI
messmerd Dec 31, 2023
4a48daf
Fix regression from previous commit
messmerd Oct 8, 2023
6919eef
Begin GUI implementation; Don't set constant_mask
messmerd Oct 10, 2023
63a356a
Implement MIDI key pressure event
messmerd Oct 10, 2023
0e3bbb8
Allow LMMS_CLAP_PATH env var to override all default CLAP search paths
messmerd Oct 11, 2023
1fdbaab
Attempt to fix restart method; Reimplement constant_mask
messmerd Oct 11, 2023
3e96224
Fix restart() and deactivate()
messmerd Oct 12, 2023
1f95248
Improve param value text; Improve extension init
messmerd Oct 22, 2023
70e817d
Implement note ports extension; Refactor log extension
messmerd Nov 2, 2023
8b2b2c2
Fix filesystem includes; Fix value_to_text() buffer size
messmerd Nov 3, 2023
9439574
Fix build
messmerd Nov 3, 2023
e5f2ceb
Fix some build issues
messmerd Nov 5, 2023
5ecfb76
Improve findSearchPaths()
messmerd Dec 4, 2023
bbdc9ae
Better way of ensuring plugins load on main thread
messmerd Dec 4, 2023
2b9e996
Fix some issues
messmerd Dec 4, 2023
599fe47
Fix scripted-checks
messmerd Dec 4, 2023
d872221
Update CLAP to version 1.1.10
messmerd Dec 4, 2023
27b4ea2
Fix instruments that have audio input
messmerd Dec 17, 2023
bbf328c
Use mingw.thread.h
messmerd Dec 17, 2023
5661141
Implement timer support extension
messmerd Dec 21, 2023
076511e
Improve timer support
messmerd Dec 21, 2023
1b18171
Implement thread pool extension
messmerd Dec 22, 2023
71c3095
Enable thread pool extension
messmerd Dec 22, 2023
3b0dea0
Begin refactoring CLAP extensions
messmerd Dec 24, 2023
08ac8cc
Continue refactoring CLAP extensions
messmerd Dec 24, 2023
7d9b581
Implement state extension (WIP)
messmerd Dec 27, 2023
bf7f600
Refactor thread check and params extensions (WIP)
messmerd Dec 29, 2023
f5dbc3b
Refactor gui extension
messmerd Dec 29, 2023
2c7e10f
Fix mistake in thread check extension
messmerd Dec 31, 2023
88386ec
Workaround for std::experimental::filesystem
messmerd Dec 31, 2023
6e83350
Refactor log extension
messmerd Jan 1, 2024
ba29c87
Fix build; Remove thread pool extension (needs more work)
messmerd Jan 2, 2024
337e5ca
Try to fix filesystem issues
messmerd Jan 2, 2024
80c5643
Try to fix builds
messmerd Jan 2, 2024
90a5b15
Clean up includes
messmerd Jan 3, 2024
189e142
More refactoring
messmerd Jan 3, 2024
5972559
Fix MSVC build
messmerd Jan 16, 2024
f654a1d
Cleanup; Use CLAP state when cloning tracks (WIP)
messmerd Jan 22, 2024
a5c4097
Fix state extension implementation and plugin cloning
messmerd Jan 23, 2024
e50d007
Update CLAP to version 1.2.0
messmerd Jan 26, 2024
f04a5bb
Add support for CLAP compatibility IDs; revert parameter value change
messmerd Jan 27, 2024
5af3d4d
Add hashCombine function
messmerd Feb 9, 2024
ad7bd3e
Begin work on presets (WIP)
messmerd Feb 11, 2024
60374db
More work on presets
messmerd Feb 12, 2024
73e3fde
Fix small timer support bug
messmerd Feb 12, 2024
dfe8ac4
Fix some issues in ClapPresetLoader::load()
messmerd Feb 13, 2024
63ef03d
More work on CLAP presets (WIP)
messmerd Feb 20, 2024
21d9168
Remember to deinit preset database
messmerd Feb 20, 2024
698d1c9
CLAP presets (WIP)
messmerd Mar 3, 2024
e502ad3
More progress on presets (WIP)
messmerd Mar 4, 2024
3c54c31
Try to fix build
messmerd Mar 7, 2024
bf85afe
Implement state context extension
messmerd Mar 7, 2024
763d69a
Presets and parameters (WIP)
messmerd Mar 9, 2024
575dd78
Presets bug fixes and refactoring (WIP)
messmerd Mar 16, 2024
148f5fc
Fix external presets
messmerd Mar 17, 2024
7e6dd39
Fix PresetSelector
messmerd Mar 17, 2024
c1662aa
Add preset load/save buttons; cleanup
messmerd Mar 18, 2024
feee422
Allow extension initialization within plugin.init() call
messmerd Mar 21, 2024
5b6bb75
Merge branch 'LMMS:master' into clap-host-dev
messmerd Mar 21, 2024
6063cdf
Fix ClapState::save() bug
messmerd Mar 23, 2024
1aac7a9
Add CLAP filter to EffectSelectDialog
messmerd Mar 24, 2024
f29e8ca
Minor changes
messmerd Mar 24, 2024
cb09644
New way of handling mono plugins (WIP)
messmerd Mar 26, 2024
92ebcf7
Remove LinkedModelGroup usage
messmerd Mar 27, 2024
3e5b433
Improve PluginPortConfig
messmerd Mar 28, 2024
d17a1d8
Add PluginPortConfigSelector
messmerd Mar 28, 2024
090bf82
Replace QComboBox with ComboBox
messmerd Mar 28, 2024
2b8e8d8
Fix Windows builds
messmerd Mar 28, 2024
f896536
Delay full extension init until after plugin.init()
messmerd Mar 29, 2024
b660556
Fix automation load/save regression
messmerd Apr 6, 2024
52b1214
Merge branch 'master' of https://github.com/messmerd/lmms into clap-h…
messmerd Apr 7, 2024
da893e2
Fix build
messmerd Apr 7, 2024
2b23635
Fix CLAP loading on macOS
messmerd Apr 18, 2024
1808474
Merge branch 'master' into clap-host-dev
messmerd May 28, 2024
4201279
Use std::filesystem; fix UTF-8 issues
messmerd May 29, 2024
0a3cb05
Fix build
messmerd May 29, 2024
b7ed5a0
Merge branch 'master' into clap-host-dev
messmerd Nov 7, 2024
0dec314
Fix build
messmerd Nov 7, 2024
1b3b091
Fix more build errors
messmerd Nov 7, 2024
5470871
Merge branch 'master' into clap-host-dev
messmerd Jul 6, 2025
0ca27e2
Fix C++20 upgrade issues
messmerd Jul 6, 2025
5f3f699
Fix MSVC build
messmerd Jul 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Stop using RTLD_DEEPBIND to allow ASan to work; Modify method names
  • Loading branch information
messmerd committed Jan 27, 2024
commit a9cc62e9e83b4ebc4e9cc153689669ffd8ddbaf3
36 changes: 18 additions & 18 deletions include/ClapFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ClapFile
{
public:
//! Loads plugin info but does not activate
ClapPluginInfo(const clap_plugin_factory* factory, uint32_t index);
ClapPluginInfo(const clap_plugin_factory* factory, std::uint32_t index);
ClapPluginInfo(const ClapPluginInfo&) = delete;
ClapPluginInfo(ClapPluginInfo&& other) noexcept;
ClapPluginInfo& operator=(const ClapPluginInfo&) = delete;
Expand All @@ -73,34 +73,34 @@ class ClapFile
auto isValid() const -> bool { return m_valid; }
void invalidate() const { m_valid = false; }

auto getFactory() const -> const clap_plugin_factory* { return m_factory; };
auto getIndex() const -> uint32_t { return m_index; }
auto getType() const -> Plugin::Type { return m_type; }
auto getDescriptor() const -> const clap_plugin_descriptor* { return m_descriptor; }
auto factory() const -> const clap_plugin_factory* { return m_factory; };
auto index() const -> std::uint32_t { return m_index; }
auto type() const -> Plugin::Type { return m_type; }
auto descriptor() const -> const clap_plugin_descriptor* { return m_descriptor; }

private:

// Are set when the .clap file is loaded:
const clap_plugin_factory* m_factory;
uint32_t m_index; //!< Plugin index within the .clap file
const clap_plugin_descriptor* m_descriptor;
Plugin::Type m_type{Plugin::Type::Undefined};
mutable bool m_valid{false};
std::uint32_t m_index; //!< Plugin index within the .clap file
const clap_plugin_descriptor* m_descriptor = nullptr;
Plugin::Type m_type = Plugin::Type::Undefined;
mutable bool m_valid = false;
std::unordered_set<PluginIssue, PluginIssueHash> m_issues;
};

//! Call after creating ClapFile to load the .clap file
auto load() -> bool;

auto getParent() const -> const ClapManager* { return m_parent; }
auto getFilename() const -> const std::filesystem::path& { return m_filename; }
auto getFactory() const -> const clap_plugin_factory* { return m_factory; }
auto parent() const -> const ClapManager* { return m_parent; }
auto filename() const -> const std::filesystem::path& { return m_filename; }
auto factory() const -> const clap_plugin_factory* { return m_factory; }

//! Only includes plugins that successfully loaded
auto pluginInfo() const -> const std::vector<std::shared_ptr<const ClapPluginInfo>>& { return m_pluginInfo; }

//! Includes plugins that failed to load
auto getPluginCount() const -> uint32_t { return m_pluginCount; }
auto pluginCount() const -> std::uint32_t { return m_pluginCount; }
auto isValid() const -> bool { return m_valid; }

//! Removes any invalid plugin info objects - be careful when using
Expand All @@ -111,14 +111,14 @@ class ClapFile
void unload();

// Are set when the .clap file is loaded:
const ClapManager* m_parent; //!< Always valid, so storing it is okay
const ClapManager* m_parent = nullptr; //!< Always valid, so storing it is okay
std::filesystem::path m_filename;
std::unique_ptr<QLibrary> m_library;
const clap_plugin_entry* m_entry{nullptr};
const clap_plugin_factory* m_factory{nullptr};
const clap_plugin_entry* m_entry = nullptr;
const clap_plugin_factory* m_factory = nullptr;
std::vector<std::shared_ptr<const ClapPluginInfo>> m_pluginInfo; //!< Only includes info for plugins that successfully loaded
uint32_t m_pluginCount{0}; //!< Includes plugins that failed to load
bool m_valid{false};
std::uint32_t m_pluginCount = 0; //!< Includes plugins that failed to load
bool m_valid = false;
};

using ClapPluginInfo = ClapFile::ClapPluginInfo;
Expand Down
37 changes: 18 additions & 19 deletions include/ClapInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ class ClapInstance final : public LinkedModelGroup
auto isMonoInput() const -> bool { return m_monoInput; } //!< Can call after pluginInit()
auto isMonoOutput() const -> bool { return m_monoOutput; } //!< Can call after pluginInit()

auto getHost() const -> const clap_host* { return &m_host; }
auto getPlugin() const -> const clap_plugin* { return m_plugin; }
auto getInfo() const -> const ClapPluginInfo& { return *m_pluginInfo; }
auto getParams() const -> const std::vector<ClapParam*>& { return m_params; }
auto host() const -> const clap_host* { return &m_host; }
auto plugin() const -> const clap_plugin* { return m_plugin; }
auto info() const -> const ClapPluginInfo& { return *m_pluginInfo; }
auto params() const -> const std::vector<ClapParam*>& { return m_params; }

/////////////////////////////////////////
// Host
Expand All @@ -178,7 +178,7 @@ class ClapInstance final : public LinkedModelGroup
// Plugin
/////////////////////////////////////////

auto getPluginState() const -> PluginState { return m_pluginState; };
auto pluginState() const -> PluginState { return m_pluginState; };

auto pluginStart() -> bool; //!< Loads, inits, and activates in that order
auto pluginRestart() -> bool;
Expand All @@ -189,9 +189,9 @@ class ClapInstance final : public LinkedModelGroup
auto pluginActivate() -> bool;
auto pluginDeactivate() -> bool;

auto pluginProcessBegin(uint32_t frames) -> bool;
auto pluginProcess(uint32_t frames) -> bool;
auto pluginProcessEnd(uint32_t frames) -> bool;
auto pluginProcessBegin(std::uint32_t frames) -> bool;
auto pluginProcess(std::uint32_t frames) -> bool;
auto pluginProcessEnd(std::uint32_t frames) -> bool;

void paramFlushOnMainThread();
void handlePluginOutputEvents();
Expand Down Expand Up @@ -227,20 +227,20 @@ class ClapInstance final : public LinkedModelGroup
static void hostExtLogLog([[maybe_unused]] const clap_host_t* host, clap_log_severity severity, const char* msg);
static auto hostExtThreadCheckIsMainThread(const clap_host_t* host) -> bool;
static auto hostExtThreadCheckIsAudioThread(const clap_host_t* host) -> bool;
static void hostExtParamsRescan(const clap_host* host, uint32_t flags);
static void hostExtParamsRescan(const clap_host* host, std::uint32_t flags);
static void hostExtParamsClear(const clap_host* host, clap_id param_id, clap_param_clear_flags flags);
static void hostExtParamsRequestFlush(const clap_host* host);

auto canUsePluginParams() const noexcept -> bool;
//bool canUsePluginGui() const noexcept;
//static const char* getCurrentClapGuiApi();
//static const char* currentClapGuiApi();

void setParamValueByHost(ClapParam& param, double value);
void setParamModulationByHost(ClapParam& param, double value);
void checkValidParamValue(const ClapParam& param, double value);
auto getParamValue(const clap_param_info& info) const -> double;
static auto clapParamsRescanMayValueChange(uint32_t flags) -> bool { return flags & (CLAP_PARAM_RESCAN_ALL | CLAP_PARAM_RESCAN_VALUES); }
static auto clapParamsRescanMayInfoChange(uint32_t flags) -> bool { return flags & (CLAP_PARAM_RESCAN_ALL | CLAP_PARAM_RESCAN_INFO); }
static auto clapParamsRescanMayValueChange(std::uint32_t flags) -> bool { return flags & (CLAP_PARAM_RESCAN_ALL | CLAP_PARAM_RESCAN_VALUES); }
static auto clapParamsRescanMayInfoChange(std::uint32_t flags) -> bool { return flags & (CLAP_PARAM_RESCAN_ALL | CLAP_PARAM_RESCAN_INFO); }

clap_host m_host;
std::queue<std::function<bool()>> m_idleQueue;
Expand Down Expand Up @@ -289,11 +289,11 @@ class ClapInstance final : public LinkedModelGroup
class AudioBuffer
{
public:
AudioBuffer(uint32_t channels, uint32_t frames)
AudioBuffer(std::uint32_t channels, std::uint32_t frames)
: m_channels(channels), m_frames(frames)
{
m_data = new float*[m_channels]();
for (uint32_t channel = 0; channel < m_channels; ++channel)
for (std::uint32_t channel = 0; channel < m_channels; ++channel)
{
m_data[channel] = new float[m_frames]();
}
Expand Down Expand Up @@ -334,15 +334,15 @@ class ClapInstance final : public LinkedModelGroup
void free() noexcept
{
if (!m_data) { return; }
for (uint32_t channel = 0; channel < m_channels; ++channel)
for (std::uint32_t channel = 0; channel < m_channels; ++channel)
{
if (m_data[channel]) { delete[] m_data[channel]; }
}
delete[] m_data;
}

uint32_t m_channels;
uint32_t m_frames;
std::uint32_t m_channels;
std::uint32_t m_frames;
float** m_data = nullptr;
};

Expand Down Expand Up @@ -418,7 +418,7 @@ class ClapInstance final : public LinkedModelGroup
struct AudioPort
{
clap_audio_port_info info{};
uint32_t index = 0; //!< Index on plugin side, not m_audioPorts***
std::uint32_t index = 0; //!< Index on plugin side, not m_audioPorts***
bool is_input = false;
AudioPortType type = AudioPortType::Unsupported;
bool used = false; //!< In use by LMMS
Expand Down Expand Up @@ -458,7 +458,6 @@ class ClapInstance final : public LinkedModelGroup
* Plugin/Host extension data
*/
bool m_hostExtStateIsDirty = false;

};

}
Expand Down
17 changes: 6 additions & 11 deletions include/ClapManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,32 @@ class ClapManager
* Returns a cached URI-to-PluginInfo map
* ClapManager doesn't own the ClapPluginInfo objects, so pointers may be invalidated.
*/
auto uriPluginInfo() const -> const std::unordered_map<std::string, std::weak_ptr<const ClapPluginInfo>>& { return m_uriToPluginInfo; }

//! Allows access to plugin instances
auto instances() const -> const std::vector<std::shared_ptr<ClapInstance>>& { return m_instances; }
auto uriToPluginInfo() const -> const std::unordered_map<std::string, std::weak_ptr<const ClapPluginInfo>>& { return m_uriToPluginInfo; }

//! Return plugin info with URI @p uri or nullptr if none exists
auto getPluginInfo(const std::string& uri) -> std::weak_ptr<const ClapPluginInfo>;
auto pluginInfo(const std::string& uri) -> std::weak_ptr<const ClapPluginInfo>;
//! Return plugin info with URI @p uri or nullptr if none exists
auto getPluginInfo(const QString& uri) -> std::weak_ptr<const ClapPluginInfo>;
auto pluginInfo(const QString& uri) -> std::weak_ptr<const ClapPluginInfo>;

//! Called by Engine at LMMS startup
void initPlugins();

//! Creates a plugin instance given plugin info; Plugin instance is owned by ClapManager
//auto createInstance(const ClapPluginInfo* info) -> std::weak_ptr<ClapPluginInstance>;

static auto getClapGuiApi() -> const char*;
static auto clapGuiApi() -> const char*;

static bool s_debug; //!< If LMMS_CLAP_DEBUG is set, debug output will be printed

private:

std::vector<std::filesystem::path> m_searchPaths; //!< Owns all CLAP search paths; Populated by findSearchPaths()
std::vector<ClapFile> m_files; //!< Owns all loaded .clap files; Populated by loadClapFiles()
std::vector<std::shared_ptr<ClapInstance>> m_instances; //!< Owns all fully initialized CLAP host/plugin instance pairs

// Non-owning plugin caches (for fast iteration/lookup)
std::vector<std::weak_ptr<const ClapPluginInfo>> m_pluginInfo; //!< Non-owning vector of info for all successfully loaded CLAP plugins
std::unordered_map<std::string, std::weak_ptr<const ClapPluginInfo>> m_uriToPluginInfo; //!< Non-owning map of plugin URIs (IDs) to ClapPluginInfo // TODO: Any changes to m_instances must be done here too
//std::unordered_multimap<std::string, std::string_ptr<ClapPluginInstance>> m_uriToPluginInstance; //!< Non-owning map of plugin URIs (IDs) to ClapPluginInstances
//std::vector<const clap_plugin_t*> m_plugins; //!< Non-owning vector of all CLAP plugin instances
std::unordered_map<std::string, std::weak_ptr<const ClapPluginInfo>> m_uriToPluginInfo; //!< Non-owning map of plugin URIs (IDs) to ClapPluginInfo
//std::vector<std::weak_ptr<ClapInstance>> m_instances; //!< Vector of all CLAP plugin instances (for guaranteeing correct clean-up order)

//! Finds all CLAP search paths and populates m_searchPaths
void findSearchPaths();
Expand Down
4 changes: 2 additions & 2 deletions include/ClapParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class ClapParam : public QObject

auto model() const -> AutomatableModel* { return m_connectedModel.get(); }
auto valueType() const -> ParamType { return m_valueType; }
auto getId() const -> std::string_view { return m_id; }
auto getDisplayName() const -> std::string_view { return m_displayName; }
auto id() const -> std::string_view { return m_id; }
auto displayName() const -> std::string_view { return m_displayName; }
auto getValueText(const clap_plugin* plugin, const clap_plugin_params* params) const -> std::string;

auto value() const -> double { return m_value; }
Expand Down
2 changes: 1 addition & 1 deletion include/ClapSubPluginFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class LMMS_EXPORT ClapSubPluginFeatures : public Plugin::Descriptor::SubPluginFe
auto logo(const Key& key) const -> const PixmapLoader* override;

private:
static auto getPluginInfo(const Key& key) -> std::shared_ptr<const ClapPluginInfo>;
static auto pluginInfo(const Key& key) -> std::shared_ptr<const ClapPluginInfo>;
};


Expand Down
2 changes: 1 addition & 1 deletion src/core/clap/ClapControlBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ClapControlBase::ClapControlBase(Model* that, const QString& uri)
{
qDebug() << "ClapControlBase::ClapControlBase";
auto manager = Engine::getClapManager();
m_info = manager->getPluginInfo(uri).lock().get();
m_info = manager->pluginInfo(uri).lock().get();
if (!m_info)
{
qCritical() << "No CLAP plugin found for URI" << uri;
Expand Down
33 changes: 14 additions & 19 deletions src/core/clap/ClapFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,12 @@ ClapFile::~ClapFile()

auto ClapFile::load() -> bool
{
m_valid = false;

m_library = std::make_unique<QLibrary>();
if (!m_library) { return false; }

m_library->setFileName(QString::fromUtf8(m_filename.c_str()));
m_library->setLoadHints(QLibrary::ResolveAllSymbolsHint | QLibrary::DeepBindHint);

// Do not allow reloading yet
if (m_library->isLoaded()) { return false; }
if (m_library && m_library->isLoaded()) { return false; }

m_valid = false;

m_library = std::make_unique<QLibrary>(QString::fromUtf8(m_filename.c_str()));
if (!m_library->load())
{
qWarning() << m_library->errorString();
Expand All @@ -71,20 +66,20 @@ auto ClapFile::load() -> bool
const auto pluginEntry = reinterpret_cast<const clap_plugin_entry*>(m_library->resolve("clap_entry"));
if (!pluginEntry)
{
qWarning() << "Unable to resolve entry point 'clap_entry' in '" << getFilename().c_str() << "'";
qWarning() << "Unable to resolve entry point 'clap_entry' in '" << filename().c_str() << "'";
m_library->unload();
return false;
}

pluginEntry->init(getFilename().c_str());
pluginEntry->init(filename().c_str());
m_factory = static_cast<const clap_plugin_factory*>(pluginEntry->get_factory(CLAP_PLUGIN_FACTORY_ID));

m_pluginCount = m_factory->get_plugin_count(m_factory);
if (ClapManager::s_debug) { qDebug() << "plugin count:" << m_pluginCount; }
if (m_pluginCount <= 0) { return false; }

m_pluginInfo.clear();
for (uint32_t i = 0; i < m_pluginCount; ++i)
for (std::uint32_t i = 0; i < m_pluginCount; ++i)
{
auto& plugin = m_pluginInfo.emplace_back(std::make_shared<ClapPluginInfo>(m_factory, i));
if (!plugin || !plugin->isValid())
Expand All @@ -100,8 +95,9 @@ auto ClapFile::load() -> bool

void ClapFile::unload()
{
// Need to destroy any plugin instances from this .clap file before
// calling this method. See ClapManager::unload().
// NOTE: Need to destroy any plugin instances from this .clap file before
// calling this method. This should be okay as long as the ClapManager
// singleton is destroyed after any ClapControlBase objects.

if (m_entry)
{
Expand All @@ -115,6 +111,8 @@ void ClapFile::unload()
m_library->unload();
m_library = nullptr;
}

m_valid = false;
}

void ClapFile::purgeInvalidPlugins()
Expand All @@ -130,12 +128,9 @@ void ClapFile::purgeInvalidPlugins()
// ClapPluginInfo
////////////////////////////////

ClapPluginInfo::ClapPluginInfo(const clap_plugin_factory* factory, uint32_t index)
ClapPluginInfo::ClapPluginInfo(const clap_plugin_factory* factory, std::uint32_t index)
: m_factory{factory}, m_index{index}
{
m_valid = false;
m_factory = factory;
m_index = index;

m_descriptor = m_factory->get_plugin_descriptor(m_factory, m_index);
if (!m_descriptor)
{
Expand Down
Loading