Implement IComponent::setState()

This commit is contained in:
Robbert van der Helm
2020-12-14 12:09:47 +01:00
parent c463543ac9
commit 816d1c1501
10 changed files with 56 additions and 6 deletions
+9
View File
@@ -133,6 +133,15 @@ 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 YaPluginFactory::Construct&) {
log_request_base(is_host_vst,
+1
View File
@@ -66,6 +66,7 @@ class Vst3Logger {
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::SetActive&);
void log_request(bool is_host_vst, const YaComponent::SetState&);
void log_request(bool is_host_vst, const YaPluginFactory::Construct&);
void log_request(bool is_host_vst, const YaPluginFactory::SetHostContext&);
void log_request(bool is_host_vst, const WantsConfiguration&);
+1
View File
@@ -67,6 +67,7 @@ using ControlRequest = std::variant<YaComponent::Construct,
YaComponent::GetRoutingInfo,
YaComponent::ActivateBus,
YaComponent::SetActive,
YaComponent::SetState,
YaPluginFactory::Construct,
YaPluginFactory::SetHostContext>;
+4
View File
@@ -175,6 +175,10 @@ tresult PLUGIN_API VectorStream::queryInterface(Steinberg::FIDString _iid,
return Steinberg::kNoInterface;
}
size_t VectorStream::size() const {
return buffer.size();
}
tresult PLUGIN_API VectorStream::read(void* buffer,
int32 numBytes,
int32* numBytesRead) {
+5
View File
@@ -134,6 +134,11 @@ class VectorStream : public Steinberg::IBStream,
DECLARE_FUNKNOWN_METHODS
/**
* Return the buffer's, used in the logging messages.
*/
size_t size() const;
// From `IBstream`
tresult PLUGIN_API read(void* buffer,
int32 numBytes,
+19
View File
@@ -350,6 +350,25 @@ class YaComponent : public Steinberg::Vst::IComponent {
};
virtual tresult PLUGIN_API setActive(TBool state) override = 0;
/**
* Message to pass through a call to `IComponent::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);
}
};
virtual tresult PLUGIN_API
setState(Steinberg::IBStream* state) override = 0;
virtual tresult PLUGIN_API
+4 -3
View File
@@ -141,9 +141,10 @@ tresult PLUGIN_API YaComponentPluginImpl::setActive(TBool state) {
}
tresult PLUGIN_API YaComponentPluginImpl::setState(Steinberg::IBStream* state) {
// TODO: Implement
bridge.logger.log("TODO: IComponent::setState()");
return Steinberg::kNotImplemented;
return bridge
.send_message(YaComponent::SetState{
.instance_id = arguments.instance_id, .state = state})
.native();
}
tresult PLUGIN_API YaComponentPluginImpl::getState(Steinberg::IBStream* state) {
@@ -30,6 +30,11 @@ YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid,
Steinberg::FIDString _iid,
void** obj) {
// TODO: Do the same thing for other types
// These arw pointers are scary. The idea here is that we return a newly
// initialized object (that initializes itself with a reference count of 1),
// and then the receiving side will use `Steinberg::owned()` to adopt it to
// an `IPtr<T>`.
ArrayUID cid_array;
std::copy(cid, cid + sizeof(Steinberg::TUID), cid_array.begin());
if (Steinberg::FIDStringsEqual(_iid, Steinberg::Vst::IComponent::iid)) {
@@ -38,8 +43,8 @@ YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid,
return std::visit(
overload{
[&](YaComponent::ConstructArgs&& args) -> tresult {
// I find all of these raw pointers scary
*obj = new YaComponentPluginImpl(bridge, std::move(args));
*obj = static_cast<Steinberg::Vst::IComponent*>(
new YaComponentPluginImpl(bridge, std::move(args)));
return Steinberg::kResultOk;
},
[&](const UniversalTResult& code) { return code.native(); }},
+1 -1
View File
@@ -441,7 +441,7 @@ class HostCallbackDataConverter : DefaultDataConverter {
switch (opcode) {
case audioMasterGetTime:
// Write the returned `VstTimeInfo` struct into a field and
// make the function return a poitner to it in the function
// make the function return a pointer to it in the function
// below. Depending on whether the host supported the
// requested time information this operations returns either
// a null pointer or a pointer to a `VstTimeInfo` object.
+5
View File
@@ -153,6 +153,11 @@ void Vst3Bridge::run() {
return component_instances[request.instance_id]
.component->setActive(request.state);
},
[&](YaComponent::SetState& request)
-> YaComponent::SetState::Response {
return component_instances[request.instance_id]
.component->setState(&request.state);
},
[&](const YaPluginFactory::Construct&)
-> YaPluginFactory::Construct::Response {
return YaPluginFactory::ConstructArgs(