Don't cache IComponent::getControllerClassId()

For the same reasons as the last commit. Now we don't have any of these
cached methods anymore.
This commit is contained in:
Robbert van der Helm
2020-12-19 18:56:47 +01:00
parent 63ae5f330c
commit b422f6fd42
8 changed files with 80 additions and 34 deletions
@@ -20,31 +20,7 @@ YaComponent::ConstructArgs::ConstructArgs() {}
YaComponent::ConstructArgs::ConstructArgs(
Steinberg::IPtr<Steinberg::FUnknown> object)
: supported(false) {
if (auto component =
Steinberg::FUnknownPtr<Steinberg::Vst::IComponent>(object)) {
supported = true;
// `IComponent::getControllerClassId`
Steinberg::TUID cid;
if (component->getControllerClassId(cid) == Steinberg::kResultOk) {
edit_controller_cid = std::to_array(cid);
}
}
}
: supported(Steinberg::FUnknownPtr<Steinberg::Vst::IComponent>(object)) {}
YaComponent::YaComponent(const ConstructArgs&& args)
: arguments(std::move(args)) {}
tresult PLUGIN_API YaComponent::getControllerClassId(Steinberg::TUID classId) {
// TODO: This is now not being logged at all. It's probably better if we
// just drop these two functions that output cached data directly.
// They'll only be used once or twice anyways.
if (arguments.edit_controller_cid) {
std::copy(arguments.edit_controller_cid->begin(),
arguments.edit_controller_cid->end(), classId);
return Steinberg::kResultOk;
} else {
return Steinberg::kNotImplemented;
}
}
@@ -52,17 +52,9 @@ class YaComponent : public Steinberg::Vst::IComponent {
*/
bool supported;
/**
* The class ID of this component's corresponding editor controller. You
* can't use C-style array in `std::optional`s.
*/
std::optional<ArrayUID> edit_controller_cid;
template <typename S>
void serialize(S& s) {
s.value1b(supported);
s.ext(edit_controller_cid, bitsery::ext::StdOptional{},
[](S& s, auto& cid) { s.container1b(cid); });
}
};
@@ -74,7 +66,38 @@ class YaComponent : public Steinberg::Vst::IComponent {
inline bool supported() const { return arguments.supported; }
tresult PLUGIN_API getControllerClassId(Steinberg::TUID classId) override;
/**
* The response code and returned CID for a call to
* `IComponent::getControllerClassId()`.
*/
struct GetControllerClassIdResponse {
UniversalTResult result;
ArrayUID editor_cid;
template <typename S>
void serialize(S& s) {
s.object(result);
s.container1b(editor_cid);
}
};
/**
* Message to pass through a call to `IComponent::getControllerClassId()` to
* the Wine plugin host.
*/
struct GetControllerClassId {
using Response = GetControllerClassIdResponse;
native_size_t instance_id;
template <typename S>
void serialize(S& s) {
s.value8b(instance_id);
}
};
virtual tresult PLUGIN_API
getControllerClassId(Steinberg::TUID classId) override = 0;
/**
* Message to pass through a call to `IComponent::setIoMode(mode)` to the