Send the factory from the Wine host to the plugin

This commit is contained in:
Robbert van der Helm
2020-12-06 14:41:50 +01:00
parent 79c6f02d91
commit c2503f8aaa
5 changed files with 28 additions and 16 deletions
+1 -1
View File
@@ -178,7 +178,7 @@ class Vst3MessageHandler : public AdHocSocketHandler<Thread> {
request);
}
const auto response = callback(request);
const auto& response = callback(request);
if (logging) {
auto [logger, is_host_vst] = *logging;
logger.log_response(!is_host_vst, response);
+3 -1
View File
@@ -50,7 +50,9 @@ struct WantsConfiguration {
* copy of the hosted Windows VST3 plugin's `IPluginFactory{,2,3}` interface.
*/
struct WantsPluginFactory {
using Response = YaPluginFactory;
// TODO: Some things had to be changed to use references since this is an
// abstract class. Check if nothing breaks.
using Response = YaPluginFactory&;
};
/**
+4
View File
@@ -73,6 +73,10 @@ SMTG_EXPORT_SYMBOL Steinberg::IPluginFactory* PLUGIN_API GetPluginFactory() {
// The host should have called `InitModule()` first
assert(bridge);
// TODO: I think there is a flag that indicates that the class configuration
// may change, but I don't remember if it's at runtime or every time
// the module is loaded. If it's the former then this will take some
// special handling.
return bridge->plugin_factory.get();
// TODO: In the normal implementation of this function they manually call
+13 -14
View File
@@ -36,6 +36,11 @@ Vst3Bridge::Vst3Bridge(MainContext& main_context,
sockets.connect();
// Serialize the plugin's plugin factory. The native VST3 plugin will
// request a copy of this during its initialization.
plugin_factory =
std::make_unique<YaPluginFactoryHostImpl>(module->getFactory().get());
// Fetch this instance's configuration from the plugin to finish the setup
// process
config = sockets.vst_host_callback.send_message(WantsConfiguration{},
@@ -43,18 +48,12 @@ Vst3Bridge::Vst3Bridge(MainContext& main_context,
}
void Vst3Bridge::run() {
// TODO: Remove, this is just for type checking
if (false) {
boost::asio::local::stream_protocol::socket* socket;
Steinberg::IPtr<Steinberg::IPluginFactory> factory;
YaPluginFactoryHostImpl object(factory);
write_object(*socket, object);
}
// TODO: Handle events
// sockets.host_vst_control.receive_messages(
// std::nullopt, [&](ControlRequest request) -> ControlResponse {
// });
std::cerr << "TODO: Not yet implemented" << std::endl;
sockets.host_vst_control.receive_messages(
std::nullopt, [&](ControlRequest request) -> auto& {
return std::visit(overload{[&](const WantsPluginFactory&)
-> WantsPluginFactory::Response {
return *plugin_factory;
}},
request);
});
}
+7
View File
@@ -83,4 +83,11 @@ class Vst3Bridge : public HostBridge {
* threads to exit.
*/
Vst3Sockets<Win32Thread> sockets;
/**
* A plugin factory copied from the Windows VST3 plugin during
* initialization. The native VST3 plugin will request a copy of this
* information during its initialization.
*/
std::unique_ptr<YaPluginFactory> plugin_factory;
};