VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / utils / CarlaMacUtils.hpp
blob7d74494a44ddd289f0e4631d0a7d503c9709dc35
1 /*
2 * Carla macOS utils
3 * Copyright (C) 2018-2023 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #ifndef CARLA_MAC_UTILS_HPP_INCLUDED
19 #define CARLA_MAC_UTILS_HPP_INCLUDED
21 #ifndef CARLA_OS_MAC
22 # error wrong include
23 #endif
25 #include "CarlaBackend.h"
27 // don't include Foundation.h here
28 extern "C" {
29 typedef struct __CFBundle* CFBundleRef;
30 typedef const struct __CFString* CFStringRef;
31 void* CFBundleGetFunctionPointerForName(CFBundleRef, CFStringRef);
34 CARLA_BACKEND_START_NAMESPACE
36 // --------------------------------------------------------------------------------------------------------------------
39 * ...
41 CARLA_API void initStandaloneApplication();
44 * ...
46 CARLA_API const char* findBinaryInBundle(const char* const bundleDir);
49 * ...
51 CARLA_API bool removeFileFromQuarantine(const char* const filename);
53 // --------------------------------------------------------------------------------------------------------------------
56 * ...
58 class AutoNSAutoreleasePool {
59 public:
60 AutoNSAutoreleasePool();
61 ~AutoNSAutoreleasePool();
63 private:
64 void* const pool;
67 // --------------------------------------------------------------------------------------------------------------------
69 struct BundleLoader {
70 BundleLoader();
71 ~BundleLoader();
72 bool load(const char* const filename);
73 CFBundleRef getRef() const noexcept;
75 template<typename Func>
76 inline Func getSymbol(const CFStringRef name) const
78 return reinterpret_cast<Func>(CFBundleGetFunctionPointerForName(getRef(), name));
81 private:
82 struct PrivateData;
83 PrivateData* const pData;
86 // --------------------------------------------------------------------------------------------------------------------
88 CARLA_BACKEND_END_NAMESPACE
90 #endif // CARLA_MAC_UTILS_HPP_INCLUDED