mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-15 21:15:51 +02:00
Add an IConnectionPoint proxy proxy
This is a bit dumb, but this way we can support indirectly connected objects.
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
// 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 "../common.h"
|
||||
#include "plugin/connection-point.h"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
|
||||
/**
|
||||
* This is only needed to...proxy a connection point proxy. Most hosts will
|
||||
* connect a plugin's processor and controller directly using
|
||||
* `IConnectionPoint::connect()`. But some hosts, like Ardour, will place a
|
||||
* proxy object between them that forwards calls to
|
||||
* `IConnectionPoint::notify()`. When objects are connected directly by the host
|
||||
* we can also connect them directly in the Wine plugin host, but when the host
|
||||
* uses proxies we'll also have to go through that proxy. The purpose of this
|
||||
* class is to provide a proxy for such a connection proxy. So when the plugin
|
||||
* calls `notify()` on an object of this class, then we will forward that call
|
||||
* to the `IConnectionPoint` proxy provided by the host, which will then in turn
|
||||
* call `IConnectionPoint::notify()` on the other object and we'll then forward
|
||||
* that message again to them Wine plugin host.
|
||||
*/
|
||||
class Vst3ConnectionPointProxy : public YaConnectionPoint {
|
||||
public:
|
||||
/**
|
||||
* These are the arguments for constructing a
|
||||
* `Vst3ConnectionPointProxyImpl`.
|
||||
*/
|
||||
struct ConstructArgs {
|
||||
ConstructArgs();
|
||||
|
||||
/**
|
||||
* Read from an existing object. We will try to mimic this object, so
|
||||
* we'll support any interfaces this object also supports.
|
||||
*
|
||||
* This is not necessary in this case since the object has to support
|
||||
* `IConnectionPoint`, but let's stay consistent with the overall style
|
||||
* here.
|
||||
*/
|
||||
ConstructArgs(Steinberg::IPtr<FUnknown> object,
|
||||
size_t owner_instance_id);
|
||||
|
||||
/**
|
||||
* The unique instance identifier of the proxy object instance this
|
||||
* connection proxy has been passed to and thus belongs to. This way we
|
||||
* can refer to the correct 'actual' `IConnectionPoint` instance when
|
||||
* the plugin calls `notify()` on this proxy object.
|
||||
*/
|
||||
native_size_t owner_instance_id;
|
||||
|
||||
YaConnectionPoint::ConstructArgs connection_point_args;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(owner_instance_id);
|
||||
s.object(connection_point_args);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiate this instance with arguments read from an actual
|
||||
* `IConnectionPoint` object/proxy.
|
||||
*
|
||||
* @note This object will be created as part of handling
|
||||
* `IConnectionPoint::connect()` if the connection is indirect.
|
||||
*/
|
||||
Vst3ConnectionPointProxy(const ConstructArgs&& args);
|
||||
|
||||
/**
|
||||
* This object will be destroyed again during
|
||||
* `IConnectionPoint::disconnect()`.
|
||||
*/
|
||||
virtual ~Vst3ConnectionPointProxy();
|
||||
|
||||
DECLARE_FUNKNOWN_METHODS
|
||||
|
||||
/**
|
||||
* Get the instance ID of the owner of this object.
|
||||
*/
|
||||
inline size_t owner_instance_id() const {
|
||||
return arguments.owner_instance_id;
|
||||
}
|
||||
|
||||
private:
|
||||
ConstructArgs arguments;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
Reference in New Issue
Block a user