mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-15 16:03:55 +02:00
Unify handling for *::{get,set}State
Since these functions are exactly the same, and for whatever reason they didn't just add them to the `IPluginBase` both `IComponent` and `IEditController`. inherit from
This commit is contained in:
+29
-28
@@ -60,6 +60,23 @@ void Vst3Logger::log_request(bool is_host_vst,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Vst3Logger::log_request(bool is_host_vst,
|
||||||
|
const Vst3PluginProxy::SetState& request) {
|
||||||
|
log_request_base(is_host_vst, [&](auto& message) {
|
||||||
|
message << "<{IComponent,IEditController}* #" << request.instance_id
|
||||||
|
<< ">::setState(state = <IBStream* containing "
|
||||||
|
<< request.state.size() << "bytes>)";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vst3Logger::log_request(bool is_host_vst,
|
||||||
|
const Vst3PluginProxy::GetState& request) {
|
||||||
|
log_request_base(is_host_vst, [&](auto& message) {
|
||||||
|
message << "<{IComponent,IEditController}* #" << request.instance_id
|
||||||
|
<< ">::getState(state = <IBStream*>)";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Vst3Logger::log_request(
|
void Vst3Logger::log_request(
|
||||||
bool is_host_vst,
|
bool is_host_vst,
|
||||||
const YaAudioProcessor::SetBusArrangements& request) {
|
const YaAudioProcessor::SetBusArrangements& request) {
|
||||||
@@ -247,23 +264,6 @@ void Vst3Logger::log_request(bool is_host_vst,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vst3Logger::log_request(bool is_host_vst,
|
|
||||||
const YaComponent::SetState& request) {
|
|
||||||
log_request_base(is_host_vst, [&](auto& message) {
|
|
||||||
message << "<IComponent* #" << request.instance_id
|
|
||||||
<< ">::setState(state = <IBStream* containing "
|
|
||||||
<< request.state.size() << "bytes>)";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void Vst3Logger::log_request(bool is_host_vst,
|
|
||||||
const YaComponent::GetState& request) {
|
|
||||||
log_request_base(is_host_vst, [&](auto& message) {
|
|
||||||
message << "<IComponent* #" << request.instance_id
|
|
||||||
<< ">::getState(state = <IBStream*>)";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void Vst3Logger::log_request(bool is_host_vst,
|
void Vst3Logger::log_request(bool is_host_vst,
|
||||||
const YaPluginBase::Initialize& request) {
|
const YaPluginBase::Initialize& request) {
|
||||||
log_request_base(is_host_vst, [&](auto& message) {
|
log_request_base(is_host_vst, [&](auto& message) {
|
||||||
@@ -323,6 +323,18 @@ void Vst3Logger::log_response(bool is_host_vst,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Vst3Logger::log_response(
|
||||||
|
bool is_host_vst,
|
||||||
|
const Vst3PluginProxy::GetStateResponse& response) {
|
||||||
|
log_response_base(is_host_vst, [&](auto& message) {
|
||||||
|
message << response.result.string();
|
||||||
|
if (response.result == Steinberg::kResultOk) {
|
||||||
|
message << ", <IBStream* containing "
|
||||||
|
<< response.updated_state.size() << " bytes>";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Vst3Logger::log_response(
|
void Vst3Logger::log_response(
|
||||||
bool is_host_vst,
|
bool is_host_vst,
|
||||||
const YaAudioProcessor::GetBusArrangementResponse& response) {
|
const YaAudioProcessor::GetBusArrangementResponse& response) {
|
||||||
@@ -403,17 +415,6 @@ void Vst3Logger::log_response(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vst3Logger::log_response(bool is_host_vst,
|
|
||||||
const YaComponent::GetStateResponse& response) {
|
|
||||||
log_response_base(is_host_vst, [&](auto& message) {
|
|
||||||
message << response.result.string();
|
|
||||||
if (response.result == Steinberg::kResultOk) {
|
|
||||||
message << ", <IBStream* containing "
|
|
||||||
<< response.updated_state.size() << " bytes>";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void Vst3Logger::log_response(bool is_host_vst,
|
void Vst3Logger::log_response(bool is_host_vst,
|
||||||
const YaPluginFactory::ConstructArgs& args) {
|
const YaPluginFactory::ConstructArgs& args) {
|
||||||
log_response_base(is_host_vst, [&](auto& message) {
|
log_response_base(is_host_vst, [&](auto& message) {
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ class Vst3Logger {
|
|||||||
|
|
||||||
void log_request(bool is_host_vst, const Vst3PluginProxy::Construct&);
|
void log_request(bool is_host_vst, const Vst3PluginProxy::Construct&);
|
||||||
void log_request(bool is_host_vst, const Vst3PluginProxy::Destruct&);
|
void log_request(bool is_host_vst, const Vst3PluginProxy::Destruct&);
|
||||||
|
void log_request(bool is_host_vst, const Vst3PluginProxy::SetState&);
|
||||||
|
void log_request(bool is_host_vst, const Vst3PluginProxy::GetState&);
|
||||||
void log_request(bool is_host_vst,
|
void log_request(bool is_host_vst,
|
||||||
const YaAudioProcessor::SetBusArrangements&);
|
const YaAudioProcessor::SetBusArrangements&);
|
||||||
void log_request(bool is_host_vst,
|
void log_request(bool is_host_vst,
|
||||||
@@ -77,8 +79,6 @@ class Vst3Logger {
|
|||||||
void log_request(bool is_host_vst, const YaComponent::GetRoutingInfo&);
|
void log_request(bool is_host_vst, const YaComponent::GetRoutingInfo&);
|
||||||
void log_request(bool is_host_vst, const YaComponent::ActivateBus&);
|
void log_request(bool is_host_vst, const YaComponent::ActivateBus&);
|
||||||
void log_request(bool is_host_vst, const YaComponent::SetActive&);
|
void log_request(bool is_host_vst, const YaComponent::SetActive&);
|
||||||
void log_request(bool is_host_vst, const YaComponent::SetState&);
|
|
||||||
void log_request(bool is_host_vst, const YaComponent::GetState&);
|
|
||||||
void log_request(bool is_host_vst, const YaPluginBase::Initialize&);
|
void log_request(bool is_host_vst, const YaPluginBase::Initialize&);
|
||||||
void log_request(bool is_host_vst, const YaPluginBase::Terminate&);
|
void log_request(bool is_host_vst, const YaPluginBase::Terminate&);
|
||||||
void log_request(bool is_host_vst, const YaPluginFactory::Construct&);
|
void log_request(bool is_host_vst, const YaPluginFactory::Construct&);
|
||||||
@@ -89,6 +89,8 @@ class Vst3Logger {
|
|||||||
void log_response(
|
void log_response(
|
||||||
bool is_host_vst,
|
bool is_host_vst,
|
||||||
const std::variant<Vst3PluginProxy::ConstructArgs, UniversalTResult>&);
|
const std::variant<Vst3PluginProxy::ConstructArgs, UniversalTResult>&);
|
||||||
|
void log_response(bool is_host_vst,
|
||||||
|
const Vst3PluginProxy::GetStateResponse&);
|
||||||
void log_response(bool is_host_vst,
|
void log_response(bool is_host_vst,
|
||||||
const YaAudioProcessor::GetBusArrangementResponse&);
|
const YaAudioProcessor::GetBusArrangementResponse&);
|
||||||
void log_response(bool is_host_vst,
|
void log_response(bool is_host_vst,
|
||||||
@@ -96,7 +98,6 @@ class Vst3Logger {
|
|||||||
void log_response(bool is_host_vst, const YaComponent::GetBusInfoResponse&);
|
void log_response(bool is_host_vst, const YaComponent::GetBusInfoResponse&);
|
||||||
void log_response(bool is_host_vst,
|
void log_response(bool is_host_vst,
|
||||||
const YaComponent::GetRoutingInfoResponse&);
|
const YaComponent::GetRoutingInfoResponse&);
|
||||||
void log_response(bool is_host_vst, const YaComponent::GetStateResponse&);
|
|
||||||
void log_response(bool is_host_vst, const YaPluginFactory::ConstructArgs&);
|
void log_response(bool is_host_vst, const YaPluginFactory::ConstructArgs&);
|
||||||
void log_response(bool is_host_vst, const Configuration&);
|
void log_response(bool is_host_vst, const Configuration&);
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ struct WantsConfiguration {
|
|||||||
*/
|
*/
|
||||||
using ControlRequest = std::variant<Vst3PluginProxy::Construct,
|
using ControlRequest = std::variant<Vst3PluginProxy::Construct,
|
||||||
Vst3PluginProxy::Destruct,
|
Vst3PluginProxy::Destruct,
|
||||||
|
Vst3PluginProxy::SetState,
|
||||||
|
Vst3PluginProxy::GetState,
|
||||||
YaAudioProcessor::SetBusArrangements,
|
YaAudioProcessor::SetBusArrangements,
|
||||||
YaAudioProcessor::GetBusArrangement,
|
YaAudioProcessor::GetBusArrangement,
|
||||||
YaAudioProcessor::CanProcessSampleSize,
|
YaAudioProcessor::CanProcessSampleSize,
|
||||||
@@ -73,8 +75,6 @@ using ControlRequest = std::variant<Vst3PluginProxy::Construct,
|
|||||||
YaComponent::GetRoutingInfo,
|
YaComponent::GetRoutingInfo,
|
||||||
YaComponent::ActivateBus,
|
YaComponent::ActivateBus,
|
||||||
YaComponent::SetActive,
|
YaComponent::SetActive,
|
||||||
YaComponent::SetState,
|
|
||||||
YaComponent::GetState,
|
|
||||||
YaPluginBase::Initialize,
|
YaPluginBase::Initialize,
|
||||||
YaPluginBase::Terminate,
|
YaPluginBase::Terminate,
|
||||||
YaPluginFactory::Construct,
|
YaPluginFactory::Construct,
|
||||||
|
|||||||
@@ -150,6 +150,58 @@ class Vst3PluginProxy : public YaAudioProcessor,
|
|||||||
|
|
||||||
DECLARE_FUNKNOWN_METHODS
|
DECLARE_FUNKNOWN_METHODS
|
||||||
|
|
||||||
|
// We'll define messages for functions that have identical definitions in
|
||||||
|
// multiple interfaces below. When the Wine plugin host process handles
|
||||||
|
// these it should check which of the interfaces is supported on the host.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message to pass through a call to
|
||||||
|
* `{IComponent,IEditController}::setState(state)` to the Wine plugin host.
|
||||||
|
*/
|
||||||
|
struct SetState {
|
||||||
|
using Response = UniversalTResult;
|
||||||
|
|
||||||
|
native_size_t instance_id;
|
||||||
|
|
||||||
|
VectorStream state;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s) {
|
||||||
|
s.value8b(instance_id);
|
||||||
|
s.object(state);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The response code and written state for a call to
|
||||||
|
* `{IComponent,IEditController}::getState(state)`.
|
||||||
|
*/
|
||||||
|
struct GetStateResponse {
|
||||||
|
UniversalTResult result;
|
||||||
|
VectorStream updated_state;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s) {
|
||||||
|
s.object(result);
|
||||||
|
s.object(updated_state);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message to pass through a call to
|
||||||
|
* `{IComponent,IEditController}::getState(state)` to the Wine plugin host.
|
||||||
|
*/
|
||||||
|
struct GetState {
|
||||||
|
using Response = GetStateResponse;
|
||||||
|
|
||||||
|
native_size_t instance_id;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s) {
|
||||||
|
s.value8b(instance_id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ConstructArgs arguments;
|
ConstructArgs arguments;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -255,57 +255,12 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
|||||||
|
|
||||||
virtual tresult PLUGIN_API setActive(TBool state) override = 0;
|
virtual tresult PLUGIN_API setActive(TBool state) override = 0;
|
||||||
|
|
||||||
/**
|
// `setState()` and `getState()` are defiend in both `IComponent` and
|
||||||
* Message to pass through a call to `IComponent::setState(state)` to the
|
// `IEditController`. Since an object can only ever implement one or the
|
||||||
* Wine plugin host.
|
// other, the messages for calling either are defined directly on
|
||||||
*/
|
// `Vst3PluginProxy`.
|
||||||
struct SetState {
|
|
||||||
using Response = UniversalTResult;
|
|
||||||
|
|
||||||
native_size_t instance_id;
|
|
||||||
|
|
||||||
VectorStream state;
|
|
||||||
|
|
||||||
template <typename S>
|
|
||||||
void serialize(S& s) {
|
|
||||||
s.value8b(instance_id);
|
|
||||||
s.object(state);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual tresult PLUGIN_API
|
virtual tresult PLUGIN_API
|
||||||
setState(Steinberg::IBStream* state) override = 0;
|
setState(Steinberg::IBStream* state) override = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* The response code and written state for a call to
|
|
||||||
* `IComponent::getState(state)`.
|
|
||||||
*/
|
|
||||||
struct GetStateResponse {
|
|
||||||
UniversalTResult result;
|
|
||||||
VectorStream updated_state;
|
|
||||||
|
|
||||||
template <typename S>
|
|
||||||
void serialize(S& s) {
|
|
||||||
s.object(result);
|
|
||||||
s.object(updated_state);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Message to pass through a call to `IComponent::getState(state)` to the
|
|
||||||
* Wine plugin host.
|
|
||||||
*/
|
|
||||||
struct GetState {
|
|
||||||
using Response = GetStateResponse;
|
|
||||||
|
|
||||||
native_size_t instance_id;
|
|
||||||
|
|
||||||
template <typename S>
|
|
||||||
void serialize(S& s) {
|
|
||||||
s.value8b(instance_id);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual tresult PLUGIN_API
|
virtual tresult PLUGIN_API
|
||||||
getState(Steinberg::IBStream* state) override = 0;
|
getState(Steinberg::IBStream* state) override = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -80,10 +80,16 @@ class YaEditController2 : public Steinberg::Vst::IEditController,
|
|||||||
|
|
||||||
virtual tresult PLUGIN_API
|
virtual tresult PLUGIN_API
|
||||||
setComponentState(Steinberg::IBStream* state) override = 0;
|
setComponentState(Steinberg::IBStream* state) override = 0;
|
||||||
|
|
||||||
|
// `setState()` and `getState()` are defiend in both `IComponent` and
|
||||||
|
// `IEditController`. Since an object can only ever implement one or the
|
||||||
|
// other, the messages for calling either are defined directly on
|
||||||
|
// `Vst3PluginProxy`.
|
||||||
virtual tresult PLUGIN_API
|
virtual tresult PLUGIN_API
|
||||||
setState(Steinberg::IBStream* state) override = 0;
|
setState(Steinberg::IBStream* state) override = 0;
|
||||||
virtual tresult PLUGIN_API
|
virtual tresult PLUGIN_API
|
||||||
getState(Steinberg::IBStream* state) override = 0;
|
getState(Steinberg::IBStream* state) override = 0;
|
||||||
|
|
||||||
virtual int32 PLUGIN_API getParameterCount() override = 0;
|
virtual int32 PLUGIN_API getParameterCount() override = 0;
|
||||||
virtual tresult PLUGIN_API
|
virtual tresult PLUGIN_API
|
||||||
getParameterInfo(int32 paramIndex,
|
getParameterInfo(int32 paramIndex,
|
||||||
|
|||||||
@@ -171,22 +171,23 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setActive(TBool state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API Vst3PluginProxyImpl::setState(Steinberg::IBStream* state) {
|
tresult PLUGIN_API Vst3PluginProxyImpl::setState(Steinberg::IBStream* state) {
|
||||||
return bridge.send_message(YaComponent::SetState{
|
// Since both interfaces contain this function, this is used for both
|
||||||
|
// `IComponent::setState()` as well as `IEditController::setState()`
|
||||||
|
return bridge.send_message(Vst3PluginProxy::SetState{
|
||||||
.instance_id = arguments.instance_id, .state = state});
|
.instance_id = arguments.instance_id, .state = state});
|
||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API Vst3PluginProxyImpl::getState(Steinberg::IBStream* state) {
|
tresult PLUGIN_API Vst3PluginProxyImpl::getState(Steinberg::IBStream* state) {
|
||||||
|
// Since both interfaces contain this function, this is used for both
|
||||||
|
// `IComponent::getState()` as well as `IEditController::getState()`
|
||||||
const GetStateResponse response = bridge.send_message(
|
const GetStateResponse response = bridge.send_message(
|
||||||
YaComponent::GetState{.instance_id = arguments.instance_id});
|
Vst3PluginProxy::GetState{.instance_id = arguments.instance_id});
|
||||||
|
|
||||||
assert(response.updated_state.write_back(state) == Steinberg::kResultOk);
|
assert(response.updated_state.write_back(state) == Steinberg::kResultOk);
|
||||||
|
|
||||||
return response.result;
|
return response.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Fix `{set,get}State()` for `IEditController` as mentioned in the
|
|
||||||
// header
|
|
||||||
|
|
||||||
tresult PLUGIN_API
|
tresult PLUGIN_API
|
||||||
Vst3PluginProxyImpl::setComponentState(Steinberg::IBStream* state) {
|
Vst3PluginProxyImpl::setComponentState(Steinberg::IBStream* state) {
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
|
|||||||
@@ -81,12 +81,9 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy {
|
|||||||
|
|
||||||
// From `IEditController`
|
// From `IEditController`
|
||||||
tresult PLUGIN_API setComponentState(Steinberg::IBStream* state) override;
|
tresult PLUGIN_API setComponentState(Steinberg::IBStream* state) override;
|
||||||
// FIXME: These are duplicate, we need to change the implementation to call
|
// `IEditController` also contains `getState()` and `setState()` functions.
|
||||||
// this on either `object_instances[instance_id].component` or
|
// These are identical to those defiend in `IComponent` and they're thus
|
||||||
// `object_instances[instance_id].edit_controller` depending on which
|
// handled in in the same function.
|
||||||
// one exists.
|
|
||||||
// tresult PLUGIN_API setState(Steinberg::IBStream* state) override;
|
|
||||||
// tresult PLUGIN_API getState(Steinberg::IBStream* state) override;
|
|
||||||
int32 PLUGIN_API getParameterCount() override;
|
int32 PLUGIN_API getParameterCount() override;
|
||||||
tresult PLUGIN_API
|
tresult PLUGIN_API
|
||||||
getParameterInfo(int32 paramIndex,
|
getParameterInfo(int32 paramIndex,
|
||||||
|
|||||||
@@ -106,6 +106,36 @@ void Vst3Bridge::run() {
|
|||||||
|
|
||||||
return Ack{};
|
return Ack{};
|
||||||
},
|
},
|
||||||
|
[&](Vst3PluginProxy::SetState& request)
|
||||||
|
-> Vst3PluginProxy::SetState::Response {
|
||||||
|
// This same function is defined in both `IComponent` and
|
||||||
|
// `IEditController`, so the host is calling one or the other
|
||||||
|
if (object_instances[request.instance_id].component) {
|
||||||
|
return object_instances[request.instance_id]
|
||||||
|
.component->setState(&request.state);
|
||||||
|
} else {
|
||||||
|
return object_instances[request.instance_id]
|
||||||
|
.edit_controller->setState(&request.state);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[&](Vst3PluginProxy::GetState& request)
|
||||||
|
-> Vst3PluginProxy::GetState::Response {
|
||||||
|
VectorStream stream;
|
||||||
|
tresult result;
|
||||||
|
|
||||||
|
// This same function is defined in both `IComponent` and
|
||||||
|
// `IEditController`, so the host is calling one or the other
|
||||||
|
if (object_instances[request.instance_id].component) {
|
||||||
|
result = object_instances[request.instance_id]
|
||||||
|
.component->getState(&stream);
|
||||||
|
} else {
|
||||||
|
result = object_instances[request.instance_id]
|
||||||
|
.edit_controller->getState(&stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Vst3PluginProxy::GetStateResponse{
|
||||||
|
.result = result, .updated_state = std::move(stream)};
|
||||||
|
},
|
||||||
[&](YaAudioProcessor::SetBusArrangements& request)
|
[&](YaAudioProcessor::SetBusArrangements& request)
|
||||||
-> YaAudioProcessor::SetBusArrangements::Response {
|
-> YaAudioProcessor::SetBusArrangements::Response {
|
||||||
return object_instances[request.instance_id]
|
return object_instances[request.instance_id]
|
||||||
@@ -201,21 +231,6 @@ void Vst3Bridge::run() {
|
|||||||
return object_instances[request.instance_id]
|
return object_instances[request.instance_id]
|
||||||
.component->setActive(request.state);
|
.component->setActive(request.state);
|
||||||
},
|
},
|
||||||
[&](YaComponent::SetState& request)
|
|
||||||
-> YaComponent::SetState::Response {
|
|
||||||
return object_instances[request.instance_id]
|
|
||||||
.component->setState(&request.state);
|
|
||||||
},
|
|
||||||
[&](YaComponent::GetState& request)
|
|
||||||
-> YaComponent::GetState::Response {
|
|
||||||
VectorStream stream;
|
|
||||||
const tresult result =
|
|
||||||
object_instances[request.instance_id].component->getState(
|
|
||||||
&stream);
|
|
||||||
|
|
||||||
return YaComponent::GetStateResponse{
|
|
||||||
.result = result, .updated_state = std::move(stream)};
|
|
||||||
},
|
|
||||||
[&](YaPluginBase::Initialize& request)
|
[&](YaPluginBase::Initialize& request)
|
||||||
-> YaPluginBase::Initialize::Response {
|
-> YaPluginBase::Initialize::Response {
|
||||||
// If we got passed a host context, we'll create a proxy object
|
// If we got passed a host context, we'll create a proxy object
|
||||||
|
|||||||
Reference in New Issue
Block a user