mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-13 20:09:59 +02:00
Use std::array for serializing UIDs
These are easily assignable and we have to convert between char pointers, char arrays and UID objects all the time anyways.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// yabridge: a Wine VST bridge
|
||||
// Copyright (C) 2020 Robbert van der Helm
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <pluginterfaces/base/ftypes.h>
|
||||
#include <pluginterfaces/base/funknown.h>
|
||||
|
||||
// Yet Another layer of includes, but these are some VST3-specific typedefs that
|
||||
// we'll need for all of our interfaces
|
||||
|
||||
using Steinberg::TBool, Steinberg::int8, Steinberg::int32, Steinberg::tresult;
|
||||
|
||||
/**
|
||||
* Both `TUID` (`int8_t[16]`) and `FIDString` (`char*`) are hard to work with
|
||||
* because you can't just copy them. So when serializing/deserializing them
|
||||
* we'll use `std::array`.
|
||||
*/
|
||||
using ArrayUID = std::array<
|
||||
std::remove_reference_t<decltype(std::declval<Steinberg::TUID>()[0])>,
|
||||
std::extent_v<Steinberg::TUID>>;
|
||||
@@ -17,14 +17,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include "src/common/serialization/common.h"
|
||||
|
||||
#include <bitsery/ext/pointer.h>
|
||||
#include <bitsery/ext/std_optional.h>
|
||||
#include <bitsery/traits/array.h>
|
||||
#include <pluginterfaces/vst/ivstcomponent.h>
|
||||
|
||||
using Steinberg::TBool, Steinberg::int8, Steinberg::int32, Steinberg::tresult;
|
||||
#include "../common.h"
|
||||
#include "base.h"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
@@ -38,6 +38,9 @@ using Steinberg::TBool, Steinberg::int8, Steinberg::int32, Steinberg::tresult;
|
||||
* We might be able to do some caching here with the buss infos, but since that
|
||||
* sounds like a huge potential source of errors we'll just do pure callbacks
|
||||
* for everything other than the edit controller's class ID.
|
||||
*
|
||||
* TODO: I think it's expected that components also implement `IAudioProcessor`
|
||||
* and `IConnectionPoint`.
|
||||
*/
|
||||
class YaComponent : public Steinberg::Vst::IComponent {
|
||||
public:
|
||||
@@ -60,8 +63,7 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
||||
* The class ID of this component's corresponding editor controller. You
|
||||
* can't use C-style array in `std::optional`s.
|
||||
*/
|
||||
std::optional<std::array<int8, std::extent_v<Steinberg::TUID>>>
|
||||
edit_controller_cid;
|
||||
std::optional<ArrayUID> edit_controller_cid;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
@@ -81,7 +83,7 @@ class YaComponent : public Steinberg::Vst::IComponent {
|
||||
// TODO: Create a `native_tvalue` wrapper, and then also add them here
|
||||
using Response = std::optional<Arguments>;
|
||||
|
||||
Steinberg::TUID cid;
|
||||
ArrayUID cid;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
#include <pluginterfaces/base/ipluginbase.h>
|
||||
|
||||
#include "../../bitsery/ext/vst3.h"
|
||||
|
||||
using Steinberg::int32, Steinberg::tresult;
|
||||
#include "base.h"
|
||||
|
||||
// TODO: After implementing one or two more of these, abstract away some of the
|
||||
// nasty bits
|
||||
|
||||
@@ -53,9 +53,11 @@ void Vst3Bridge::run() {
|
||||
overload{
|
||||
[&](const YaComponent::Create& args)
|
||||
-> YaComponent::Create::Response {
|
||||
Steinberg::TUID cid;
|
||||
std::copy(args.cid.begin(), args.cid.end(), cid);
|
||||
Steinberg::IPtr<Steinberg::Vst::IComponent> component =
|
||||
module->getFactory()
|
||||
.createInstance<Steinberg::Vst::IComponent>(args.cid);
|
||||
.createInstance<Steinberg::Vst::IComponent>(cid);
|
||||
if (component) {
|
||||
std::lock_guard lock(component_instances_mutex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user