Implement IComponent::getState()

With this the basic IComponent interface is fully implemented. Next will
be `IAudioProcessor` and `IConnectionPoint` as additions to IComponent.
We'll use the same `known_iids` mechanism as used in the plugin factory.
This commit is contained in:
Robbert van der Helm
2020-12-14 12:33:35 +01:00
parent 02e6fb1ba8
commit e653142e45
9 changed files with 75 additions and 8 deletions
+1
View File
@@ -68,6 +68,7 @@ using ControlRequest = std::variant<YaComponent::Construct,
YaComponent::ActivateBus,
YaComponent::SetActive,
YaComponent::SetState,
YaComponent::GetState,
YaPluginFactory::Construct,
YaPluginFactory::SetHostContext>;
+3 -3
View File
@@ -175,15 +175,15 @@ tresult PLUGIN_API VectorStream::queryInterface(Steinberg::FIDString _iid,
return Steinberg::kNoInterface;
}
tresult VectorStream::write_back(Steinberg::IBStream* stream) {
tresult VectorStream::write_back(Steinberg::IBStream* stream) const {
if (!stream) {
return Steinberg::kInvalidArgument;
}
int32 num_bytes_written;
assert(stream->seek(0, kIBSeekSet) == Steinberg::kResultOk);
assert(stream->write(buffer.data(), buffer.size(), &num_bytes_written) ==
Steinberg::kResultOk);
assert(stream->write(const_cast<uint8_t*>(buffer.data()), buffer.size(),
&num_bytes_written) == Steinberg::kResultOk);
assert(num_bytes_written == 0 ||
static_cast<size_t>(num_bytes_written) == buffer.size());
+1 -1
View File
@@ -140,7 +140,7 @@ class VectorStream : public Steinberg::IBStream,
* Write the vector buffer back to an IBStream. After writing the seek
* position will be left at the end of the stream.
*/
tresult write_back(Steinberg::IBStream* stream);
tresult write_back(Steinberg::IBStream* stream) const;
/**
* Return the buffer's, used in the logging messages.
+31
View File
@@ -371,6 +371,37 @@ class YaComponent : public Steinberg::Vst::IComponent {
virtual tresult PLUGIN_API
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
getState(Steinberg::IBStream* state) override = 0;