commit 55a509506a3063f3de003b5939ffca1ec8bf45d6
parent 052bd460e656de978a8be2f39419408a030ea2e9
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date: Sun, 1 Aug 2021 14:41:27 +0200
Start a path provider
Diffstat:
6 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/examples/plugins/CMakeLists.txt b/examples/plugins/CMakeLists.txt
@@ -10,6 +10,9 @@ add_library(
plugin-helper.hh
stream-helper.hh
+ path-provider.hh
+ path-provider.cc
+
abstract-gui.hh
remote-gui.hh
remote-gui.cc
diff --git a/examples/plugins/abstract-gui.hh b/examples/plugins/abstract-gui.hh
@@ -10,6 +10,8 @@ namespace clap {
AbstractGui(PluginHelper &plugin) : plugin_(plugin) {}
virtual ~AbstractGui() = default;
+ virtual void defineParameter(const clap_param_info&) noexcept = 0;
+
virtual bool attachCocoa(void *nsView) noexcept = 0;
virtual bool attachWin32(clap_hwnd window) noexcept = 0;
virtual bool attachX11(const char *display_name, unsigned long window) noexcept = 0;
diff --git a/examples/plugins/clap-entry.cc b/examples/plugins/clap-entry.cc
@@ -6,8 +6,9 @@
#include <sstream>
#include <vector>
-#include "gain/gain.hh"
#include "dc-offset/dc-offset.hh"
+#include "gain/gain.hh"
+#include "path-provider.hh"
struct PluginEntry {
using create_func = std::function<const clap_plugin *(const clap_host *)>;
@@ -15,7 +16,7 @@ struct PluginEntry {
PluginEntry(const clap_plugin_descriptor *d, create_func &&func)
: desc(d), create(std::move(func)) {}
- const clap_plugin_descriptor * desc;
+ const clap_plugin_descriptor *desc;
std::function<const clap_plugin *(const clap_host *)> create;
};
@@ -30,12 +31,17 @@ static void addPlugin() {
}
static bool clap_init(const char *plugin_path) {
+ clap::PathProvider::createInstance(plugin_path);
+
addPlugin<clap::Gain>();
addPlugin<clap::DcOffset>();
return true;
}
-static void clap_deinit(void) { g_plugins.clear(); }
+static void clap_deinit(void) {
+ g_plugins.clear();
+ clap::PathProvider::destroyInstance();
+}
static uint32_t clap_get_plugin_count(void) { return g_plugins.size(); }
@@ -56,19 +62,13 @@ static const clap_plugin *clap_create_plugin(const clap_host *host, const char *
return nullptr;
}
-static uint32_t clap_get_invalidation_sources_count(void)
-{
- return 0;
-}
+static uint32_t clap_get_invalidation_sources_count(void) { return 0; }
-static const clap_plugin_invalidation_source *clap_get_invalidation_sources(uint32_t index)
-{
+static const clap_plugin_invalidation_source *clap_get_invalidation_sources(uint32_t index) {
return nullptr;
}
-static void clap_refresh(void)
-{
-}
+static void clap_refresh(void) {}
CLAP_EXPORT const struct clap_plugin_entry clap_plugin_entry = {
CLAP_VERSION,
diff --git a/examples/plugins/path-provider.cc b/examples/plugins/path-provider.cc
diff --git a/examples/plugins/path-provider.hh b/examples/plugins/path-provider.hh
@@ -0,0 +1,18 @@
+#include <memory>
+#include <string>
+
+namespace clap {
+ class PathProvider {
+ public:
+ virtual ~PathProvider() = default;
+
+ static const PathProvider *createInstance(const std::string &pluginPath);
+ static void destroyInstance() { instance_.reset(); }
+ static const PathProvider *instance() { return instance_.get(); }
+
+ virtual std::string getGuiExecutable() const = 0;
+
+ private:
+ static std::unique_ptr<PathProvider> instance_;
+ };
+} // namespace clap
+\ No newline at end of file
diff --git a/examples/plugins/remote-gui.hh b/examples/plugins/remote-gui.hh
@@ -16,6 +16,8 @@ namespace clap {
bool spawn();
+ void defineParameter(const clap_param_info&) noexcept override;
+
bool attachCocoa(void *nsView) noexcept override;
bool attachWin32(clap_hwnd window) noexcept override;
bool attachX11(const char *display_name, unsigned long window) noexcept override;