mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-16 08:23:55 +02:00
Request and deserialize plugin factory from plugin
This commit is contained in:
@@ -27,8 +27,6 @@
|
||||
namespace bitsery {
|
||||
namespace ext {
|
||||
|
||||
// TODO: There's probably a better way to do all of this
|
||||
|
||||
/**
|
||||
* An adapter for serializing and deserializing filesystem paths since they're
|
||||
* not mutable.
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "vst3.h"
|
||||
|
||||
#include <sstream>
|
||||
#include "src/common/serialization/vst3.h"
|
||||
|
||||
// TODO: Reconsider the output format
|
||||
// TODO: Maybe think of an alterantive that's a little less boilerplaty
|
||||
@@ -33,6 +34,16 @@ void Vst3Logger::log_request(bool is_host_vst, const WantsConfiguration&) {
|
||||
}
|
||||
}
|
||||
|
||||
void Vst3Logger::log_request(bool is_host_vst, const WantsPluginFactory&) {
|
||||
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) {
|
||||
std::ostringstream message;
|
||||
message << get_log_prefix(is_host_vst)
|
||||
<< " >> Requesting <IPluginFactory*>";
|
||||
|
||||
log(message.str());
|
||||
}
|
||||
}
|
||||
|
||||
void Vst3Logger::log_response(bool is_host_vst, const Configuration&) {
|
||||
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) {
|
||||
std::ostringstream message;
|
||||
@@ -41,3 +52,15 @@ void Vst3Logger::log_response(bool is_host_vst, const Configuration&) {
|
||||
log(message.str());
|
||||
}
|
||||
}
|
||||
|
||||
void Vst3Logger::log_response(bool is_host_vst,
|
||||
const YaPluginFactory& factory) {
|
||||
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) {
|
||||
std::ostringstream message;
|
||||
message << get_log_prefix(is_host_vst) << " <IPluginFactory*> with "
|
||||
<< const_cast<YaPluginFactory&>(factory).countClasses()
|
||||
<< " registered classes";
|
||||
|
||||
log(message.str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,10 @@ class Vst3Logger {
|
||||
// (what we'll call a control message).
|
||||
|
||||
void log_request(bool is_host_vst, const WantsConfiguration&);
|
||||
void log_request(bool is_host_vst, const WantsPluginFactory&);
|
||||
|
||||
void log_response(bool is_host_vst, const Configuration&);
|
||||
void log_response(bool is_host_vst, const YaPluginFactory&);
|
||||
|
||||
Logger& logger;
|
||||
|
||||
|
||||
@@ -45,16 +45,24 @@ struct WantsConfiguration {
|
||||
using Response = Configuration;
|
||||
};
|
||||
|
||||
/**
|
||||
* Marker struct to indicate the other side (the Wine plugin host) should send a
|
||||
* copy of the hosted Windows VST3 plugin's `IPluginFactory{,2,3}` interface.
|
||||
*/
|
||||
struct WantsPluginFactory {
|
||||
using Response = YaPluginFactory;
|
||||
};
|
||||
|
||||
/**
|
||||
* When we send a control message from the plugin to the Wine VST host, this
|
||||
* encodes the information we request or the operation we want to perform. A
|
||||
* request of type `ControlRequest(T)` should send back a `T::Reponse`.
|
||||
*/
|
||||
using ControlRequest = std::variant<>;
|
||||
using ControlRequest = std::variant<WantsPluginFactory>;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s, ControlRequest& payload) {
|
||||
s.ext(payload, bitsery::ext::StdVariant{});
|
||||
s.ext(payload, bitsery::ext::StdVariant{[](S&, WantsPluginFactory&) {}});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,8 +53,6 @@ YaPluginFactory::YaPluginFactory(
|
||||
// `IPluginFactory::countClasses`
|
||||
num_classes = factory->countClasses();
|
||||
// `IPluginFactory::getClassInfo`
|
||||
// TODO: At this point we don't know what this class is and thus we can't
|
||||
// filter unsupported classes, right?
|
||||
class_infos_1.resize(num_classes);
|
||||
for (int i = 0; i < num_classes; i++) {
|
||||
Steinberg::PClassInfo info;
|
||||
|
||||
@@ -86,6 +86,29 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
||||
virtual tresult PLUGIN_API
|
||||
setHostContext(Steinberg::FUnknown* context) override = 0;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.ext(known_iids, bitsery::ext::StdSet{32},
|
||||
[](S& s, Steinberg::FUID& iid) {
|
||||
s.ext(iid, bitsery::ext::FUID{});
|
||||
});
|
||||
s.ext(factory_info, bitsery::ext::StdOptional{});
|
||||
s.value4b(num_classes);
|
||||
s.container(class_infos_1, 2048,
|
||||
[](S& s, std::optional<Steinberg::PClassInfo>& info) {
|
||||
s.ext(info, bitsery::ext::StdOptional{});
|
||||
});
|
||||
s.container(class_infos_2, 2048,
|
||||
[](S& s, std::optional<Steinberg::PClassInfo2>& info) {
|
||||
s.ext(info, bitsery::ext::StdOptional{});
|
||||
});
|
||||
s.container(class_infos_unicode, 2048,
|
||||
[](S& s, std::optional<Steinberg::PClassInfoW>& info) {
|
||||
s.ext(info, bitsery::ext::StdOptional{});
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* The IIDs that the interface we serialized supports.
|
||||
*/
|
||||
@@ -115,28 +138,6 @@ class YaPluginFactory : public Steinberg::IPluginFactory3 {
|
||||
* above.
|
||||
*/
|
||||
std::vector<std::optional<Steinberg::PClassInfoW>> class_infos_unicode;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.ext(known_iids, bitsery::ext::StdSet{32},
|
||||
[](S& s, Steinberg::FUID& iid) {
|
||||
s.ext(iid, bitsery::ext::FUID{});
|
||||
});
|
||||
s.ext(factory_info, bitsery::ext::StdOptional{});
|
||||
s.value4b(num_classes);
|
||||
s.container(class_infos_1, 2048,
|
||||
[](S& s, std::optional<Steinberg::PClassInfo>& info) {
|
||||
s.ext(info, bitsery::ext::StdOptional{});
|
||||
});
|
||||
s.container(class_infos_2, 2048,
|
||||
[](S& s, std::optional<Steinberg::PClassInfo2>& info) {
|
||||
s.ext(info, bitsery::ext::StdOptional{});
|
||||
});
|
||||
s.container(class_infos_unicode, 2048,
|
||||
[](S& s, std::optional<Steinberg::PClassInfoW>& info) {
|
||||
s.ext(info, bitsery::ext::StdOptional{});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
Reference in New Issue
Block a user