Audacity 3.2.0
ConnectionProxy.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file ConnectionProxy.cpp
6
7 @author Vitaly Sverchinsky
8
9 @brief Part of Audacity VST3 module
10
11**********************************************************************/
12
13#include "ConnectionProxy.h"
14
15internal::ConnectionProxy::ConnectionProxy(Steinberg::Vst::IConnectionPoint* source)
16 : mSource(source)
17{
18 mThreadId = std::this_thread::get_id();
19 FUNKNOWN_CTOR;
20}
22{
23 FUNKNOWN_DTOR;
24}
25
26Steinberg::tresult internal::ConnectionProxy::connect (IConnectionPoint* other)
27{
28 if(other == nullptr)
29 return Steinberg::kInvalidArgument;
30 if(mTarget.get() != nullptr)
31 return Steinberg::kResultFalse;
32
33 //Looks a bit awkward, but the source can send messages to
34 //the target during connection
35 mTarget = other;
36 auto result = mSource->connect(this);
37 if(result != Steinberg::kResultOk)
38 mTarget = nullptr;
39 return result;
40}
41
42Steinberg::tresult internal::ConnectionProxy::disconnect (IConnectionPoint* other)
43{
44 if(other == nullptr)
45 return Steinberg::kInvalidArgument;
46 if(other != mTarget.get())
47 return Steinberg::kResultFalse;
48
49 auto result = mSource->disconnect(this);
50 if(result == Steinberg::kResultOk)
51 mTarget = nullptr;
52 return result;
53}
54
55Steinberg::tresult internal::ConnectionProxy::notify (Steinberg::Vst::IMessage* message)
56{
57 if(mTarget.get() == nullptr ||
58 std::this_thread::get_id() != mThreadId)
59 return Steinberg::kResultFalse;
60
61 return mTarget->notify(message);
62}
63
64
65IMPLEMENT_FUNKNOWN_METHODS(internal::ConnectionProxy, Steinberg::Vst::IConnectionPoint, Steinberg::Vst::IConnectionPoint::iid);
IMPLEMENT_FUNKNOWN_METHODS(internal::ConnectionProxy, Steinberg::Vst::IConnectionPoint, Steinberg::Vst::IConnectionPoint::iid)
Host's proxy object between connection points.
ConnectionProxy(Steinberg::Vst::IConnectionPoint *source)
Steinberg::tresult PLUGIN_API connect(IConnectionPoint *other) override
Steinberg::tresult PLUGIN_API disconnect(IConnectionPoint *other) override
Steinberg::tresult PLUGIN_API notify(Steinberg::Vst::IMessage *message) override