LMMS
Loading...
Searching...
No Matches
juce_ARACommon.cpp
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26#if (JUCE_PLUGINHOST_ARA && (JUCE_PLUGINHOST_VST3 || JUCE_PLUGINHOST_AU) && (JUCE_MAC || JUCE_WINDOWS))
27
28#include <ARA_Library/Debug/ARADebug.h>
29
30namespace juce
31{
32
33static void dummyARAInterfaceAssert (ARA::ARAAssertCategory, const void*, const char*)
34{}
35
36static ARA::ARAInterfaceConfiguration createInterfaceConfig (const ARA::ARAFactory* araFactory)
37{
38 static auto* assertFunction = &dummyARAInterfaceAssert;
39
40 #if ARA_VALIDATE_API_CALLS
41 assertFunction = &::ARA::ARAInterfaceAssert;
42 static std::once_flag flag;
43 std::call_once (flag, [] { ARA::ARASetExternalAssertReference (&assertFunction); });
44 #endif
45
46 return makeARASizedStruct (&ARA::ARAInterfaceConfiguration::assertFunctionAddress,
47 jmin (araFactory->highestSupportedApiGeneration, (ARA::ARAAPIGeneration) ARA::kARAAPIGeneration_2_X_Draft),
48 &assertFunction);
49}
50
51static std::shared_ptr<const ARA::ARAFactory> getOrCreateARAFactory (const ARA::ARAFactory* ptr,
52 std::function<void (const ARA::ARAFactory*)> onDelete)
53{
55
56 static std::unordered_map<const ARA::ARAFactory*, std::weak_ptr<const ARA::ARAFactory>> cache;
57
58 auto& cachePtr = cache[ptr];
59
60 if (const auto obj = cachePtr.lock())
61 return obj;
62
63 const auto interfaceConfig = createInterfaceConfig (ptr);
64 ptr->initializeARAWithConfiguration (&interfaceConfig);
65 const auto obj = std::shared_ptr<const ARA::ARAFactory> (ptr, [deleter = std::move (onDelete)] (const ARA::ARAFactory* factory)
66 {
67 factory->uninitializeARA();
68 deleter (factory);
69 });
70 cachePtr = obj;
71 return obj;
72}
73
74}
75
76#endif
Type jmin(const Type a, const Type b)
Definition MathsFunctions.h:60
#define JUCE_ASSERT_MESSAGE_THREAD
Definition juce_MessageManager.h:473
struct Steinberg::Singleton::Deleter deleter
Definition carla_juce.cpp:31
constexpr Obj makeARASizedStruct(Member Obj::*member, Ts &&... ts)
Definition juce_ARACommon.h:79
jack_client_t client jack_client_t client jack_client_t client jack_client_t JackInfoShutdownCallback void arg jack_client_t jack_port_t port void func jack_client_t const char const char unsigned long flags const jack_port_t port jack_client_t jack_port_id_t port_id const jack_port_t const char port_name const jack_port_t port void * ptr
Definition juce_linux_JackAudio.cpp:79
int flag
Definition unix.c:754