Skip to content

Commit

Permalink
Clap Proxy re-use changes
Browse files Browse the repository at this point in the history
1. Remove a specious vst3 include
2. Move the clap-prox to the right cmake target
3. Add a few more Plugin creators from factory directly
   (which is useful for the static standalone, not included
   in this commit)
  • Loading branch information
baconpaul committed Sep 11, 2023
1 parent b0e822b commit 88f11ca
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
5 changes: 2 additions & 3 deletions cmake/enable_sdks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ function(DefineCLAPASVST3Sources)
endif()

set(wrappersources_vst3
src/clap_proxy.h
src/clap_proxy.cpp
src/wrapasvst3.h
src/wrapasvst3.cpp
src/wrapasvst3_entry.cpp
Expand Down Expand Up @@ -660,14 +658,15 @@ if (APPLE)
endif()
endif()


# Define the extensions target
if ( NOT TARGET clap-wrapper-extensions)
add_library(clap-wrapper-extensions INTERFACE)
target_include_directories(clap-wrapper-extensions INTERFACE include)
endif()

add_library(clap-wrapper-shared-detail STATIC
src/clap_proxy.h
src/clap_proxy.cpp
src/detail/sha1.h
src/detail/sha1.cpp
src/detail/clap/fsutil.h
Expand Down
20 changes: 19 additions & 1 deletion src/clap_proxy.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "clap_proxy.h"
#include "detail/clap/fsutil.h"
#include "public.sdk/source/main/pluginfactory.h"

#if MAC || LIN
#include <iostream>
Expand Down Expand Up @@ -116,6 +115,25 @@ const clap_host_tail tail = {tail_changed};

} // namespace HostExt

std::shared_ptr<Plugin> Plugin::createInstance(const clap_plugin_factory* fac, const std::string& id,
Clap::IHost* host)
{
auto plug = std::shared_ptr<Plugin>(new Plugin(host));
auto instance = fac->create_plugin(fac, plug->getClapHostInterface(), id.c_str());
plug->connectClap(instance);

return plug;
}

std::shared_ptr<Plugin> Plugin::createInstance(const clap_plugin_factory* fac, size_t idx,
Clap::IHost* host)
{
auto pc = fac->get_plugin_count(fac);
if (idx < 0 || idx >= pc) return nullptr;
auto desc = fac->get_plugin_descriptor(fac, idx);
return createInstance(fac, desc->id, host);
}

std::shared_ptr<Plugin> Plugin::createInstance(Clap::Library& library, size_t index, IHost* host)
{
if (library.plugins.size() > index)
Expand Down
5 changes: 4 additions & 1 deletion src/clap_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ class Raise
class Plugin
{
public:
static std::shared_ptr<Plugin> createInstance(Clap::Library& library, size_t index, IHost* host);
static std::shared_ptr<Plugin> createInstance(const clap_plugin_factory*, const std::string& id,
IHost* host);
static std::shared_ptr<Plugin> createInstance(const clap_plugin_factory*, size_t idx, IHost* host);
static std::shared_ptr<Plugin> createInstance(Clap::Library& library, size_t idx, IHost* host);

protected:
// only the Clap::Library is allowed to create instances
Expand Down

0 comments on commit 88f11ca

Please sign in to comment.