Implement the Wine side for createView()

This commit is contained in:
Robbert van der Helm
2020-12-19 20:41:06 +01:00
parent e391bbccb7
commit f0ece64018
6 changed files with 90 additions and 1 deletions
+22 -1
View File
@@ -414,6 +414,15 @@ bool Vst3Logger::log_request(
});
}
bool Vst3Logger::log_request(bool is_host_vst,
const YaEditController::CreateView& request) {
return log_request_base(is_host_vst, [&](auto& message) {
message << request.instance_id
<< ": IEditController::createView(name = " << request.name
<< ")";
});
}
bool Vst3Logger::log_request(bool is_host_vst,
const YaPluginBase::Initialize& request) {
return log_request_base(is_host_vst, [&](auto& message) {
@@ -661,7 +670,19 @@ void Vst3Logger::log_response(
log_response_base(is_host_vst, [&](auto& message) {
message << response.result.string();
if (response.result == Steinberg::kResultOk) {
message << ", " << response.value_normalized << std::endl;
message << ", " << response.value_normalized;
}
});
}
void Vst3Logger::log_response(
bool is_host_vst,
const YaEditController::CreateViewResponse& response) {
log_response_base(is_host_vst, [&](auto& message) {
if (response.plug_view_args) {
message << "<IPlugView*>";
} else {
message << "<nullptr>";
}
});
}
+3
View File
@@ -106,6 +106,7 @@ class Vst3Logger {
const YaEditController::SetParamNormalized&);
bool log_request(bool is_host_vst,
const YaEditController::SetComponentHandler&);
bool log_request(bool is_host_vst, const YaEditController::CreateView&);
bool log_request(bool is_host_vst, const YaPluginBase::Initialize&);
bool log_request(bool is_host_vst, const YaPluginBase::Terminate&);
bool log_request(bool is_host_vst, const YaPluginFactory::Construct&);
@@ -140,6 +141,8 @@ class Vst3Logger {
const YaEditController::GetParamStringByValueResponse&);
void log_response(bool is_host_vst,
const YaEditController::GetParamValueByStringResponse&);
void log_response(bool is_host_vst,
const YaEditController::CreateViewResponse&);
void log_response(bool is_host_vst, const YaPluginFactory::ConstructArgs&);
void log_response(bool is_host_vst, const Configuration&);
+1
View File
@@ -90,6 +90,7 @@ using ControlRequest = std::variant<Vst3PluginProxy::Construct,
YaEditController::GetParamNormalized,
YaEditController::SetParamNormalized,
YaEditController::SetComponentHandler,
YaEditController::CreateView,
YaPluginBase::Initialize,
YaPluginBase::Terminate,
YaPluginFactory::Construct,
@@ -22,6 +22,7 @@
#include "../../common.h"
#include "../base.h"
#include "../component-handler-proxy.h"
#include "../plug-view-proxy.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
@@ -361,6 +362,40 @@ class YaEditController : public Steinberg::Vst::IEditController {
virtual tresult PLUGIN_API setComponentHandler(
Steinberg::Vst::IComponentHandler* handler) override = 0;
/**
* The `IPlugView` proxy arguments returned from a call to
* `IEditController::createView(name)`. If not empty, then we'll use this to
* construct a proxy object that can send control messages to the plugin
* instance's actual `IPlugView` object.
*/
struct CreateViewResponse {
std::optional<Vst3PlugViewProxy::ConstructArgs> plug_view_args;
template <typename S>
void serialize(S& s) {
s.ext(plug_view_args, bitsery::ext::StdOptional{});
}
};
/**
* Message to pass through a call to `IEditController::createView(name)` to
* the Wine plugin host.
*/
struct CreateView {
using Response = CreateViewResponse;
native_size_t instance_id;
std::string name;
template <typename S>
void serialize(S& s) {
s.value8b(instance_id);
s.text1b(name, 128);
}
};
virtual Steinberg::IPlugView* PLUGIN_API
createView(Steinberg::FIDString name) override = 0;
+19
View File
@@ -371,6 +371,25 @@ void Vst3Bridge::run() {
object_instances[request.instance_id]
.component_handler_proxy);
},
[&](const YaEditController::CreateView& request)
-> YaEditController::CreateView::Response {
object_instances[request.instance_id].plug_view =
Steinberg::owned(
object_instances[request.instance_id]
.edit_controller->createView(request.name.c_str()));
// We'll create a proxy so the host can call functions on this
// `IPlugView` object
return YaEditController::CreateViewResponse{
.plug_view_args =
(object_instances[request.instance_id].plug_view
? std::make_optional<
Vst3PlugViewProxy::ConstructArgs>(
object_instances[request.instance_id]
.plug_view,
request.instance_id)
: std::nullopt)};
},
[&](YaPluginBase::Initialize& request)
-> YaPluginBase::Initialize::Response {
// If we got passed a host context, we'll create a proxy object
+10
View File
@@ -60,6 +60,16 @@ struct InstanceInterfaces {
*/
Steinberg::IPtr<Steinberg::FUnknown> object;
/**
* The `IPlugView` object the plugin returned from a call to
* `IEditController::createView()`.
*
* XXX: Technically VST3 supports multiple named views, so we could have
* multiple different view for a single plugin. This is not used within
* the SDK, so a single pointer should be fine for now.
*/
Steinberg::IPtr<Steinberg::IPlugView> plug_view;
// All smart pointers below are created from `component`. They will be null
// pointers if `component` did not implement the interface.