commit 6e436c13c6b0beac8f52678913862f45d4821e2d parent 3ae01dda535bff34a94546c2c1d43b8d5699d9bf Author: Alexandre BIQUE <bique.alexandre@gmail.com> Date: Sun, 8 Aug 2021 12:51:50 +0200 More work Diffstat:
17 files changed, 342 insertions(+), 333 deletions(-)
diff --git a/examples/gui/application.cc b/examples/gui/application.cc @@ -14,16 +14,16 @@ Application::Application(int argc, char **argv) QCommandLineParser parser; - QCommandLineOption qmlOpt("qml", tr("path to the QML skin"), tr("path")); + QCommandLineOption skinOpt("skin", tr("path to the skin directory"), tr("path")); QCommandLineOption socketOpt("socket", tr("path to the QML skin"), tr("path")); - parser.addOption(qmlOpt); + parser.addOption(skinOpt); parser.addOption(socketOpt); parser.addHelpOption(); parser.process(*this); - quickView_->setSource(parser.value(qmlOpt)); + quickView_->setSource(parser.value(skinOpt) + "/main.qml"); auto socket = parser.value(socketOpt).toULongLong(); diff --git a/examples/plugins/CMakeLists.txt b/examples/plugins/CMakeLists.txt @@ -6,8 +6,8 @@ add_library( parameters.cc parameters.hh parameter-interpolator.hh - plugin-helper.cc - plugin-helper.hh + core-plugin.hh + core-plugin.cc stream-helper.hh path-provider.hh diff --git a/examples/plugins/abstract-gui.hh b/examples/plugins/abstract-gui.hh @@ -4,10 +4,10 @@ namespace clap { - class PluginHelper; + class CorePlugin; class AbstractGui { public: - AbstractGui(PluginHelper &plugin) : plugin_(plugin) {} + AbstractGui(CorePlugin &plugin) : plugin_(plugin) {} virtual ~AbstractGui() = default; virtual void defineParameter(const clap_param_info&) noexcept = 0; @@ -25,7 +25,7 @@ namespace clap { virtual void destroy() noexcept = 0; protected: - PluginHelper &plugin_; + CorePlugin &plugin_; }; } // namespace clap \ No newline at end of file diff --git a/examples/plugins/clap-entry.cc b/examples/plugins/clap-entry.cc @@ -21,17 +21,18 @@ struct PluginEntry { }; static std::vector<PluginEntry> g_plugins; +static std::string g_pluginPath; template <typename T> static void addPlugin() { g_plugins.emplace_back(T::descriptor(), [](const clap_host *host) -> const clap_plugin * { - auto plugin = new T(host); + auto plugin = new T(g_pluginPath, host); return plugin->clapPlugin(); }); } static bool clap_init(const char *plugin_path) { - clap::PathProvider::createInstance(plugin_path); + g_pluginPath = plugin_path; addPlugin<clap::Gain>(); addPlugin<clap::DcOffset>(); @@ -40,7 +41,7 @@ static bool clap_init(const char *plugin_path) { static void clap_deinit(void) { g_plugins.clear(); - clap::PathProvider::destroyInstance(); + g_pluginPath.clear(); } static uint32_t clap_get_plugin_count(void) { return g_plugins.size(); } diff --git a/examples/plugins/core-plugin.cc b/examples/plugins/core-plugin.cc @@ -0,0 +1,127 @@ +#include <boost/archive/text_iarchive.hpp> +#include <boost/archive/text_oarchive.hpp> + +#include "core-plugin.hh" +#include "stream-helper.hh" + +namespace clap { + + CorePlugin::CorePlugin(std::unique_ptr<PathProvider> &&pathProvider, + const clap_plugin_descriptor *desc, + const clap_host *host) + : Plugin(desc, host), pathProvider_(std::move(pathProvider)) {} + + bool CorePlugin::init() noexcept { + initTrackInfo(); + return true; + } + + void CorePlugin::initTrackInfo() noexcept { + checkMainThread(); + + assert(!hasTrackInfo_); + if (!canUseTrackInfo()) + return; + + hasTrackInfo_ = hostTrackInfo_->get(host_, &trackInfo_); + } + + void CorePlugin::trackInfoChanged() noexcept { + if (!hostTrackInfo_->get(host_, &trackInfo_)) { + hasTrackInfo_ = false; + hostMisbehaving( + "clap_host_track_info.get() failed after calling clap_plugin_track_info.changed()"); + return; + } + + hasTrackInfo_ = true; + } + + bool CorePlugin::implementsAudioPorts() const noexcept { return true; } + + uint32_t CorePlugin::audioPortsCount(bool is_input) const noexcept { + return is_input ? audioInputs_.size() : audioOutputs_.size(); + } + + bool CorePlugin::audioPortsInfo(uint32_t index, + bool is_input, + clap_audio_port_info *info) const noexcept { + *info = is_input ? audioInputs_[index] : audioOutputs_[index]; + return true; + } + + uint32_t CorePlugin::audioPortsConfigCount() const noexcept { return audioConfigs_.size(); } + + bool CorePlugin::audioPortsGetConfig(uint32_t index, + clap_audio_ports_config *config) const noexcept { + *config = audioConfigs_[index]; + return true; + } + + bool CorePlugin::audioPortsSetConfig(clap_id config_id) noexcept { return false; } + + bool CorePlugin::stateSave(clap_ostream *stream) noexcept { + try { + OStream os(stream); + boost::archive::text_oarchive ar(os); + ar << parameters_; + } catch (...) { + return false; + } + return true; + } + + bool CorePlugin::stateLoad(clap_istream *stream) noexcept { + try { + IStream is(stream); + boost::archive::text_iarchive ar(is); + ar >> parameters_; + } catch (...) { + return false; + } + return true; + } + + bool CorePlugin::guiCreate() noexcept { + remoteGui_.reset(new RemoteGui(*this)); + + if (!remoteGui_->spawn()) { + remoteGui_.reset(); + return false; + } + + return true; + } + + void CorePlugin::guiDestroy() noexcept { + if (remoteGui_) + remoteGui_->destroy(); + } + + bool CorePlugin::guiSize(uint32_t *width, uint32_t *height) noexcept { + if (!remoteGui_) + return false; + + return remoteGui_->size(width, height); + } + + void CorePlugin::guiSetScale(double scale) noexcept { + if (remoteGui_) + remoteGui_->setScale(scale); + } + + void CorePlugin::guiShow() noexcept { + if (remoteGui_) + remoteGui_->show(); + } + + void CorePlugin::guiHide() noexcept { + if (remoteGui_) + remoteGui_->hide(); + } + + void CorePlugin::eventLoopOnFd(clap_fd fd, uint32_t flags) noexcept { + if (remoteGui_ && fd == remoteGui_->fd()) + remoteGui_->onFd(flags); + } +} // namespace clap +\ No newline at end of file diff --git a/examples/plugins/core-plugin.hh b/examples/plugins/core-plugin.hh @@ -0,0 +1,161 @@ +#pragma once + +#include <memory> + +#include <clap-plugin.hh> + +#include "parameters.hh" +#include "remote-gui.hh" +#include "path-provider.hh" + +namespace clap { + class CorePlugin : public Plugin { + public: + CorePlugin(std::unique_ptr<PathProvider>&& pathProvider, const clap_plugin_descriptor *desc, const clap_host *host); + + const PathProvider& pathProvider() const noexcept { return *pathProvider_; } + + protected: + //-------------// + // clap_plugin // + //-------------// + bool init() noexcept override; + void initTrackInfo() noexcept; + + //------------------------// + // clap_plugin_track_info // + //------------------------// + bool implementsTrackInfo() const noexcept override { return true; } + void trackInfoChanged() noexcept override; + + //-------------------------// + // clap_plugin_audio_ports // + //-------------------------// + bool implementsAudioPorts() const noexcept override; + uint32_t audioPortsCount(bool is_input) const noexcept override; + bool audioPortsInfo(uint32_t index, + bool is_input, + clap_audio_port_info *info) const noexcept override; + uint32_t audioPortsConfigCount() const noexcept override; + bool audioPortsGetConfig(uint32_t index, + clap_audio_ports_config *config) const noexcept override; + bool audioPortsSetConfig(clap_id config_id) noexcept override; + + //--------------------// + // clap_plugin_params // + //--------------------// + bool implementsParams() const noexcept override { return true; } + + uint32_t paramsCount() const noexcept override { return parameters_.count(); } + + bool paramsInfo(int32_t paramIndex, clap_param_info *info) const noexcept override { + *info = parameters_.getByIndex(paramIndex)->info(); + return true; + } + + virtual bool paramsValue(clap_id paramId, double *value) noexcept override { + *value = parameters_.getById(paramId)->value(); + return true; + } + + virtual bool paramsValueToText(clap_id paramId, + double value, + char *display, + uint32_t size) noexcept override { + // TODO + return false; + } + + virtual bool paramsTextToValue(clap_id param_id, + const char *display, + double *value) noexcept override { + // TODO + return false; + } + + //-------------------// + // clap_plugin_state // + //-------------------// + bool implementsState() const noexcept override { return true; } + bool stateSave(clap_ostream *stream) noexcept override; + bool stateLoad(clap_istream *stream) noexcept override; + + //-----------------// + // clap_plugin_gui // + //-----------------// + bool implementsGui() const noexcept override { return true; } + bool guiCreate() noexcept override; + void guiDestroy() noexcept override; + bool guiCanResize() const noexcept override { return false; } + bool guiSize(uint32_t *width, uint32_t *height) noexcept override; + void guiRoundSize(uint32_t *width, uint32_t *height) noexcept override { + guiSize(width, height); + } + void guiSetScale(double scale) noexcept override; + void guiShow() noexcept override; + void guiHide() noexcept override; + + //---------------------// + // clap_plugin_gui_x11 // + //---------------------// + bool implementsGuiX11() const noexcept override { return false; } + bool guiX11Attach(const char *displayName, unsigned long window) noexcept override { + return false; + } + + //-----------------------// + // clap_plugin_gui_win32 // + //-----------------------// + bool implementsGuiWin32() const noexcept override { return false; } + bool guiWin32Attach(clap_hwnd window) noexcept override { return false; } + + //-----------------------// + // clap_plugin_gui_cocoa // + //-----------------------// + bool implementsGuiCocoa() const noexcept override { return false; } + bool guiCocoaAttach(void *nsView) noexcept override { return false; } + + //-------------------------------// + // clap_plugin_gui_free_standing // + //-------------------------------// + bool implementsGuiFreeStanding() const noexcept override { return false; } + bool guiFreeStandingOpen() noexcept override { return false; } + + ////////////////////// + // Cached Host Info // + ////////////////////// + bool hasTrackInfo() const noexcept { return hasTrackInfo_; } + const clap_track_info &trackInfo() const noexcept { + assert(hasTrackInfo_); + return trackInfo_; + } + uint32_t trackChannelCount() const noexcept { + return hasTrackInfo_ ? trackInfo_.channel_count : 2; + } + clap_chmap trackChannelMap() const noexcept { + return hasTrackInfo_ ? trackInfo_.channel_map : CLAP_CHMAP_STEREO; + } + + //------------------------// + // clap_plugin_event_loop // + //------------------------// + bool implementsEventLoop() const noexcept override { return true; } + void eventLoopOnFd(clap_fd fd, uint32_t flags) noexcept override; + + protected: + friend class RemoteGui; + + std::unique_ptr<PathProvider> pathProvider_; + + bool hasTrackInfo_ = false; + clap_track_info trackInfo_; + + std::vector<clap_audio_port_info> audioInputs_; + std::vector<clap_audio_port_info> audioOutputs_; + std::vector<clap_audio_ports_config> audioConfigs_; + + std::unique_ptr<RemoteGui> remoteGui_; + + Parameters parameters_; + }; +} // namespace clap +\ No newline at end of file diff --git a/examples/plugins/dc-offset/dc-offset.cc b/examples/plugins/dc-offset/dc-offset.cc @@ -27,7 +27,7 @@ namespace clap { kParamIdOffset = 0, }; - DcOffset::DcOffset(const clap_host *host) : PluginHelper(descriptor(), host) { + DcOffset::DcOffset(const std::string& pluginPath, const clap_host *host) : CorePlugin(PathProvider::create(pluginPath, "dc-offset"), descriptor(), host) { parameters_.addParameter(clap_param_info{ .id = kParamIdOffset, .flags = 0, diff --git a/examples/plugins/dc-offset/dc-offset.hh b/examples/plugins/dc-offset/dc-offset.hh @@ -1,14 +1,14 @@ #pragma once -#include "../plugin-helper.hh" +#include "../core-plugin.hh" namespace clap { - class DcOffset final : public PluginHelper { + class DcOffset final : public CorePlugin { private: - using super = PluginHelper; + using super = CorePlugin; public: - DcOffset(const clap_host *host); + DcOffset(const std::string& pluginPath, const clap_host *host); static const clap_plugin_descriptor *descriptor(); diff --git a/examples/plugins/dc-offset/qml/main.qml b/examples/plugins/dc-offset/skin/main.qml diff --git a/examples/plugins/gain/gain.cc b/examples/plugins/gain/gain.cc @@ -26,7 +26,7 @@ namespace clap { kParamIdGain = 0, }; - Gain::Gain(const clap_host *host) : PluginHelper(descriptor(), host) { + Gain::Gain(const std::string& pluginPath, const clap_host *host) : CorePlugin(PathProvider::create(pluginPath, "gain"), descriptor(), host) { parameters_.addParameter(clap_param_info{ .id = kParamIdGain, .flags = 0, diff --git a/examples/plugins/gain/gain.hh b/examples/plugins/gain/gain.hh @@ -1,14 +1,14 @@ #pragma once -#include "../plugin-helper.hh" +#include "../core-plugin.hh" namespace clap { - class Gain final : public PluginHelper { + class Gain final : public CorePlugin { private: - using super = PluginHelper; + using super = CorePlugin; public: - Gain(const clap_host *host); + Gain(const std::string& pluginPath, const clap_host *host); static const clap_plugin_descriptor *descriptor(); diff --git a/examples/plugins/path-provider.cc b/examples/plugins/path-provider.cc @@ -9,7 +9,7 @@ namespace clap { class LinuxPathProvider final : public PathProvider { public: - LinuxPathProvider(const std::string &pluginPath) : prefix_(computePrefix(pluginPath)) {} + LinuxPathProvider(const std::string &pluginPath, const std::string &pluginName) : prefix_(computePrefix(pluginPath)), pluginName_(pluginName) {} static std::string computePrefix(const std::string &pluginPath) { static const std::regex r("(/.*)/lib/clap/.*$", std::regex::optimize); @@ -22,16 +22,19 @@ namespace clap { std::string getGuiExecutable() const override { return prefix_ / "bin/clap-gui"; } + std::string getSkinDirectory() const override { return prefix_ / "lib/clap/" / pluginName_ / "skin"; } + bool isValid() const noexcept override { return !prefix_.empty(); } private: const std::filesystem::path prefix_; + const std::string pluginName_; }; class LinuxDevelopmentPathProvider final : public PathProvider { public: - LinuxDevelopmentPathProvider(const std::string &pluginPath) - : srcRoot_(computeSrcRoot(pluginPath)), buildRoot_(computeBuildRoot(pluginPath)) {} + LinuxDevelopmentPathProvider(const std::string &pluginPath, const std::string &pluginName) + : srcRoot_(computeSrcRoot(pluginPath)), buildRoot_(computeBuildRoot(pluginPath)), pluginName_(pluginName) {} static std::string computeSrcRoot(const std::string &pluginPath) { static const std::regex r("(/.*)/cmake-builds/.*$", std::regex::optimize); @@ -52,34 +55,28 @@ namespace clap { return m[1]; } - std::string getGuiExecutable() const override { - return buildRoot_ / "examples/gui/clap-gui"; - } + std::string getGuiExecutable() const override { return buildRoot_ / "examples/gui/clap-gui"; } + + std::string getSkinDirectory() const override { return srcRoot_ / "examples/plugins/" / pluginName_ / "skin"; } bool isValid() const noexcept override { return !srcRoot_.empty() && !buildRoot_.empty(); } private: const std::filesystem::path srcRoot_; const std::filesystem::path buildRoot_; + const std::string pluginName_; }; - std::unique_ptr<PathProvider> PathProvider::instance_; - - const PathProvider *PathProvider::createInstance(const std::string &pluginPath) { - assert(!instance_); - + std::unique_ptr<PathProvider> PathProvider::create(const std::string &pluginPath, const std::string& pluginName) { #ifdef __linux__ { - instance_.reset(new LinuxDevelopmentPathProvider(pluginPath)); - if (instance_->isValid()) - return instance_.get(); - - instance_.reset(new LinuxPathProvider(pluginPath)); - if (instance_->isValid()) - return instance_.get(); + auto devPtr = std::make_unique<LinuxDevelopmentPathProvider>(pluginPath, pluginName); + if (devPtr->isValid()) + return std::move(devPtr); - instance_.reset(); - return nullptr; + auto ptr = std::make_unique<LinuxPathProvider>(pluginPath, pluginName); + if (ptr->isValid()) + return std::move(ptr); } #endif diff --git a/examples/plugins/path-provider.hh b/examples/plugins/path-provider.hh @@ -1,3 +1,5 @@ +#pragma once + #include <memory> #include <string> @@ -6,14 +8,11 @@ namespace clap { public: virtual ~PathProvider() = default; - static const PathProvider *createInstance(const std::string &pluginPath); - static void destroyInstance() { instance_.reset(); } - static const PathProvider *instance() { return instance_.get(); } + static std::unique_ptr<PathProvider> create(const std::string &pluginPath, const std::string& pluginName); virtual std::string getGuiExecutable() const = 0; - virtual bool isValid() const = 0; + virtual std::string getSkinDirectory() const = 0; - private: - static std::unique_ptr<PathProvider> instance_; + virtual bool isValid() const = 0; }; } // namespace clap \ No newline at end of file diff --git a/examples/plugins/plugin-helper.cc b/examples/plugins/plugin-helper.cc @@ -1,125 +0,0 @@ -#include <boost/archive/text_iarchive.hpp> -#include <boost/archive/text_oarchive.hpp> - -#include "plugin-helper.hh" -#include "stream-helper.hh" - -namespace clap { - - PluginHelper::PluginHelper(const clap_plugin_descriptor *desc, const clap_host *host) - : Plugin(desc, host) {} - - bool PluginHelper::init() noexcept { - initTrackInfo(); - return true; - } - - void PluginHelper::initTrackInfo() noexcept { - checkMainThread(); - - assert(!hasTrackInfo_); - if (!canUseTrackInfo()) - return; - - hasTrackInfo_ = hostTrackInfo_->get(host_, &trackInfo_); - } - - void PluginHelper::trackInfoChanged() noexcept { - if (!hostTrackInfo_->get(host_, &trackInfo_)) { - hasTrackInfo_ = false; - hostMisbehaving( - "clap_host_track_info.get() failed after calling clap_plugin_track_info.changed()"); - return; - } - - hasTrackInfo_ = true; - } - - bool PluginHelper::implementsAudioPorts() const noexcept { return true; } - - uint32_t PluginHelper::audioPortsCount(bool is_input) const noexcept { - return is_input ? audioInputs_.size() : audioOutputs_.size(); - } - - bool PluginHelper::audioPortsInfo(uint32_t index, - bool is_input, - clap_audio_port_info *info) const noexcept { - *info = is_input ? audioInputs_[index] : audioOutputs_[index]; - return true; - } - - uint32_t PluginHelper::audioPortsConfigCount() const noexcept { return audioConfigs_.size(); } - - bool PluginHelper::audioPortsGetConfig(uint32_t index, - clap_audio_ports_config *config) const noexcept { - *config = audioConfigs_[index]; - return true; - } - - bool PluginHelper::audioPortsSetConfig(clap_id config_id) noexcept { return false; } - - bool PluginHelper::stateSave(clap_ostream *stream) noexcept { - try { - OStream os(stream); - boost::archive::text_oarchive ar(os); - ar << parameters_; - } catch (...) { - return false; - } - return true; - } - - bool PluginHelper::stateLoad(clap_istream *stream) noexcept { - try { - IStream is(stream); - boost::archive::text_iarchive ar(is); - ar >> parameters_; - } catch (...) { - return false; - } - return true; - } - - bool PluginHelper::guiCreate() noexcept { - remoteGui_.reset(new RemoteGui(*this)); - - if (!remoteGui_->spawn()) { - remoteGui_.reset(); - return false; - } - - return true; - } - - void PluginHelper::guiDestroy() noexcept { - if (remoteGui_) - remoteGui_->destroy(); - } - - bool PluginHelper::guiSize(uint32_t *width, uint32_t *height) noexcept { - if (!remoteGui_) - return false; - - return remoteGui_->size(width, height); - } - - void PluginHelper::guiSetScale(double scale) noexcept { - if (remoteGui_) - remoteGui_->setScale(scale); - } - - void PluginHelper::guiShow() noexcept { - if (remoteGui_) - remoteGui_->show(); - } - - void PluginHelper::guiHide() noexcept { - if (remoteGui_) - remoteGui_->hide(); - } - - void PluginHelper::eventLoopOnFd(clap_fd fd, uint32_t flags) noexcept { - if (remoteGui_ && fd == remoteGui_->fd()) - remoteGui_->onFd(flags); - } -} // namespace clap -\ No newline at end of file diff --git a/examples/plugins/plugin-helper.hh b/examples/plugins/plugin-helper.hh @@ -1,154 +0,0 @@ -#pragma once - -#include <clap-plugin.hh> - -#include "parameters.hh" -#include "remote-gui.hh" - -namespace clap { - class PluginHelper : public Plugin { - public: - PluginHelper(const clap_plugin_descriptor *desc, const clap_host *host); - - protected: - //-------------// - // clap_plugin // - //-------------// - bool init() noexcept override; - void initTrackInfo() noexcept; - - //------------------------// - // clap_plugin_track_info // - //------------------------// - bool implementsTrackInfo() const noexcept override { return true; } - void trackInfoChanged() noexcept override; - - //-------------------------// - // clap_plugin_audio_ports // - //-------------------------// - bool implementsAudioPorts() const noexcept override; - uint32_t audioPortsCount(bool is_input) const noexcept override; - bool audioPortsInfo(uint32_t index, - bool is_input, - clap_audio_port_info *info) const noexcept override; - uint32_t audioPortsConfigCount() const noexcept override; - bool audioPortsGetConfig(uint32_t index, - clap_audio_ports_config *config) const noexcept override; - bool audioPortsSetConfig(clap_id config_id) noexcept override; - - //--------------------// - // clap_plugin_params // - //--------------------// - bool implementsParams() const noexcept override { return true; } - - uint32_t paramsCount() const noexcept override { return parameters_.count(); } - - bool paramsInfo(int32_t paramIndex, clap_param_info *info) const noexcept override { - *info = parameters_.getByIndex(paramIndex)->info(); - return true; - } - - virtual bool paramsValue(clap_id paramId, double *value) noexcept override { - *value = parameters_.getById(paramId)->value(); - return true; - } - - virtual bool paramsValueToText(clap_id paramId, - double value, - char *display, - uint32_t size) noexcept override { - // TODO - return false; - } - - virtual bool paramsTextToValue(clap_id param_id, - const char *display, - double *value) noexcept override { - // TODO - return false; - } - - //-------------------// - // clap_plugin_state // - //-------------------// - bool implementsState() const noexcept override { return true; } - bool stateSave(clap_ostream *stream) noexcept override; - bool stateLoad(clap_istream *stream) noexcept override; - - //-----------------// - // clap_plugin_gui // - //-----------------// - bool implementsGui() const noexcept override { return true; } - bool guiCreate() noexcept override; - void guiDestroy() noexcept override; - bool guiCanResize() const noexcept override { return false; } - bool guiSize(uint32_t *width, uint32_t *height) noexcept override; - void guiRoundSize(uint32_t *width, uint32_t *height) noexcept override { - guiSize(width, height); - } - void guiSetScale(double scale) noexcept override; - void guiShow() noexcept override; - void guiHide() noexcept override; - - //---------------------// - // clap_plugin_gui_x11 // - //---------------------// - bool implementsGuiX11() const noexcept override { return false; } - bool guiX11Attach(const char *displayName, unsigned long window) noexcept override { - return false; - } - - //-----------------------// - // clap_plugin_gui_win32 // - //-----------------------// - bool implementsGuiWin32() const noexcept override { return false; } - bool guiWin32Attach(clap_hwnd window) noexcept override { return false; } - - //-----------------------// - // clap_plugin_gui_cocoa // - //-----------------------// - bool implementsGuiCocoa() const noexcept override { return false; } - bool guiCocoaAttach(void *nsView) noexcept override { return false; } - - //-------------------------------// - // clap_plugin_gui_free_standing // - //-------------------------------// - bool implementsGuiFreeStanding() const noexcept override { return false; } - bool guiFreeStandingOpen() noexcept override { return false; } - - ////////////////////// - // Cached Host Info // - ////////////////////// - bool hasTrackInfo() const noexcept { return hasTrackInfo_; } - const clap_track_info &trackInfo() const noexcept { - assert(hasTrackInfo_); - return trackInfo_; - } - uint32_t trackChannelCount() const noexcept { - return hasTrackInfo_ ? trackInfo_.channel_count : 2; - } - clap_chmap trackChannelMap() const noexcept { - return hasTrackInfo_ ? trackInfo_.channel_map : CLAP_CHMAP_STEREO; - } - - //------------------------// - // clap_plugin_event_loop // - //------------------------// - bool implementsEventLoop() const noexcept override { return true; } - void eventLoopOnFd(clap_fd fd, uint32_t flags) noexcept override; - - protected: - friend class RemoteGui; - - bool hasTrackInfo_ = false; - clap_track_info trackInfo_; - - std::vector<clap_audio_port_info> audioInputs_; - std::vector<clap_audio_port_info> audioOutputs_; - std::vector<clap_audio_ports_config> audioConfigs_; - - std::unique_ptr<RemoteGui> remoteGui_; - - Parameters parameters_; - }; -} // namespace clap -\ No newline at end of file diff --git a/examples/plugins/remote-gui.cc b/examples/plugins/remote-gui.cc @@ -7,7 +7,7 @@ #include "../io/messages.hh" #include "path-provider.hh" -#include "plugin-helper.hh" +#include "core-plugin.hh" #include "remote-gui.hh" namespace clap { @@ -22,6 +22,8 @@ namespace clap { assert(child_ == -1); assert(!channel_); + auto& pathProvider = plugin_.pathProvider(); + #ifdef __unix__ /* create a socket pair */ int sockets[2]; @@ -30,7 +32,7 @@ namespace clap { } printf("About to start GUI: %s --socket %d\n", - PathProvider::instance()->getGuiExecutable().c_str(), + pathProvider.getGuiExecutable().c_str(), sockets[0]); child_ = ::fork(); @@ -45,8 +47,9 @@ namespace clap { ::close(sockets[0]); char socketStr[16]; ::snprintf(socketStr, sizeof(socketStr), "%d", sockets[1]); - auto path = PathProvider::instance()->getGuiExecutable(); - ::execl(path.c_str(), path.c_str(), "--socket", socketStr, nullptr); + auto path = pathProvider.getGuiExecutable(); + auto skin = pathProvider.getSkinDirectory(); + ::execl(path.c_str(), path.c_str(), "--socket", socketStr, "--skin", skin.c_str(), nullptr); printf("Failed to start child process: %m\n"); std::terminate(); } else { diff --git a/examples/plugins/remote-gui.hh b/examples/plugins/remote-gui.hh @@ -12,7 +12,7 @@ namespace clap { class RemoteGui : public AbstractGui, public RemoteChannel::EventControl { public: - RemoteGui(PluginHelper &plugin) : AbstractGui(plugin) {} + RemoteGui(CorePlugin &plugin) : AbstractGui(plugin) {} ~RemoteGui(); bool spawn();