Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clap Proxy re-use changes #131

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
21 changes: 20 additions & 1 deletion src/clap_proxy.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "clap_proxy.h"
#include "detail/clap/fsutil.h"
#include "public.sdk/source/main/pluginfactory.h"
#include <cstring>

#if MAC || LIN
#include <iostream>
Expand Down Expand Up @@ -116,6 +116,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 >= 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