mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Implement IComponent::setState()
This commit is contained in:
@@ -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,
|
void Vst3Logger::log_request(bool is_host_vst,
|
||||||
const YaPluginFactory::Construct&) {
|
const YaPluginFactory::Construct&) {
|
||||||
log_request_base(is_host_vst,
|
log_request_base(is_host_vst,
|
||||||
|
|||||||
@@ -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::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 YaPluginFactory::Construct&);
|
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 YaPluginFactory::SetHostContext&);
|
||||||
void log_request(bool is_host_vst, const WantsConfiguration&);
|
void log_request(bool is_host_vst, const WantsConfiguration&);
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ using ControlRequest = std::variant<YaComponent::Construct,
|
|||||||
YaComponent::GetRoutingInfo,
|
YaComponent::GetRoutingInfo,
|
||||||
YaComponent::ActivateBus,
|
YaComponent::ActivateBus,
|
||||||
YaComponent::SetActive,
|
YaComponent::SetActive,
|
||||||
|
YaComponent::SetState,
|
||||||
YaPluginFactory::Construct,
|
YaPluginFactory::Construct,
|
||||||
YaPluginFactory::SetHostContext>;
|
YaPluginFactory::SetHostContext>;
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,10 @@ tresult PLUGIN_API VectorStream::queryInterface(Steinberg::FIDString _iid,
|
|||||||
return Steinberg::kNoInterface;
|
return Steinberg::kNoInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t VectorStream::size() const {
|
||||||
|
return buffer.size();
|
||||||
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API VectorStream::read(void* buffer,
|
tresult PLUGIN_API VectorStream::read(void* buffer,
|
||||||
int32 numBytes,
|
int32 numBytes,
|
||||||
int32* numBytesRead) {
|
int32* numBytesRead) {
|
||||||
|
|||||||
@@ -134,6 +134,11 @@ class VectorStream : public Steinberg::IBStream,
|
|||||||
|
|
||||||
DECLARE_FUNKNOWN_METHODS
|
DECLARE_FUNKNOWN_METHODS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the buffer's, used in the logging messages.
|
||||||
|
*/
|
||||||
|
size_t size() const;
|
||||||
|
|
||||||
// From `IBstream`
|
// From `IBstream`
|
||||||
tresult PLUGIN_API read(void* buffer,
|
tresult PLUGIN_API read(void* buffer,
|
||||||
int32 numBytes,
|
int32 numBytes,
|
||||||
|
|||||||
@@ -350,6 +350,25 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual tresult PLUGIN_API setActive(TBool state) override = 0;
|
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
|
virtual tresult PLUGIN_API
|
||||||
setState(Steinberg::IBStream* state) override = 0;
|
setState(Steinberg::IBStream* state) override = 0;
|
||||||
virtual tresult PLUGIN_API
|
virtual tresult PLUGIN_API
|
||||||
|
|||||||
@@ -141,9 +141,10 @@ tresult PLUGIN_API YaComponentPluginImpl::setActive(TBool state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API YaComponentPluginImpl::setState(Steinberg::IBStream* state) {
|
tresult PLUGIN_API YaComponentPluginImpl::setState(Steinberg::IBStream* state) {
|
||||||
// TODO: Implement
|
return bridge
|
||||||
bridge.logger.log("TODO: IComponent::setState()");
|
.send_message(YaComponent::SetState{
|
||||||
return Steinberg::kNotImplemented;
|
.instance_id = arguments.instance_id, .state = state})
|
||||||
|
.native();
|
||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API YaComponentPluginImpl::getState(Steinberg::IBStream* state) {
|
tresult PLUGIN_API YaComponentPluginImpl::getState(Steinberg::IBStream* state) {
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid,
|
|||||||
Steinberg::FIDString _iid,
|
Steinberg::FIDString _iid,
|
||||||
void** obj) {
|
void** obj) {
|
||||||
// TODO: Do the same thing for other types
|
// 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;
|
ArrayUID cid_array;
|
||||||
std::copy(cid, cid + sizeof(Steinberg::TUID), cid_array.begin());
|
std::copy(cid, cid + sizeof(Steinberg::TUID), cid_array.begin());
|
||||||
if (Steinberg::FIDStringsEqual(_iid, Steinberg::Vst::IComponent::iid)) {
|
if (Steinberg::FIDStringsEqual(_iid, Steinberg::Vst::IComponent::iid)) {
|
||||||
@@ -38,8 +43,8 @@ YaPluginFactoryPluginImpl::createInstance(Steinberg::FIDString cid,
|
|||||||
return std::visit(
|
return std::visit(
|
||||||
overload{
|
overload{
|
||||||
[&](YaComponent::ConstructArgs&& args) -> tresult {
|
[&](YaComponent::ConstructArgs&& args) -> tresult {
|
||||||
// I find all of these raw pointers scary
|
*obj = static_cast<Steinberg::Vst::IComponent*>(
|
||||||
*obj = new YaComponentPluginImpl(bridge, std::move(args));
|
new YaComponentPluginImpl(bridge, std::move(args)));
|
||||||
return Steinberg::kResultOk;
|
return Steinberg::kResultOk;
|
||||||
},
|
},
|
||||||
[&](const UniversalTResult& code) { return code.native(); }},
|
[&](const UniversalTResult& code) { return code.native(); }},
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ class HostCallbackDataConverter : DefaultDataConverter {
|
|||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case audioMasterGetTime:
|
case audioMasterGetTime:
|
||||||
// Write the returned `VstTimeInfo` struct into a field and
|
// 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
|
// below. Depending on whether the host supported the
|
||||||
// requested time information this operations returns either
|
// requested time information this operations returns either
|
||||||
// a null pointer or a pointer to a `VstTimeInfo` object.
|
// a null pointer or a pointer to a `VstTimeInfo` object.
|
||||||
|
|||||||
@@ -153,6 +153,11 @@ void Vst3Bridge::run() {
|
|||||||
return component_instances[request.instance_id]
|
return component_instances[request.instance_id]
|
||||||
.component->setActive(request.state);
|
.component->setActive(request.state);
|
||||||
},
|
},
|
||||||
|
[&](YaComponent::SetState& request)
|
||||||
|
-> YaComponent::SetState::Response {
|
||||||
|
return component_instances[request.instance_id]
|
||||||
|
.component->setState(&request.state);
|
||||||
|
},
|
||||||
[&](const YaPluginFactory::Construct&)
|
[&](const YaPluginFactory::Construct&)
|
||||||
-> YaPluginFactory::Construct::Response {
|
-> YaPluginFactory::Construct::Response {
|
||||||
return YaPluginFactory::ConstructArgs(
|
return YaPluginFactory::ConstructArgs(
|
||||||
|
|||||||
Reference in New Issue
Block a user