2 * DISTRHO Plugin Framework (DPF)
3 * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with
6 * or without fee is hereby granted, provided that the above copyright notice and this
7 * permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef DISTRHO_IS_STANDALONE
18 # error Wrong build configuration
21 #include "../extra/String.hpp"
22 #include "../DistrhoStandaloneUtils.hpp"
24 #ifdef DISTRHO_OS_WINDOWS
34 #if defined(DISTRHO_OS_WINDOWS) && !defined(STATIC_BUILD) && !DISTRHO_IS_STANDALONE
35 static HINSTANCE hInstance
= nullptr;
38 BOOL WINAPI
DllMain(HINSTANCE hInst
, DWORD reason
, LPVOID
)
40 if (reason
== DLL_PROCESS_ATTACH
)
46 START_NAMESPACE_DISTRHO
48 // -----------------------------------------------------------------------
50 const char* getBinaryFilename()
52 static String filename
;
55 if (filename
.isNotEmpty())
58 # ifdef DISTRHO_OS_WINDOWS
59 # if DISTRHO_IS_STANDALONE
60 constexpr const HINSTANCE hInstance
= nullptr;
62 CHAR filenameBuf
[MAX_PATH
];
63 filenameBuf
[0] = '\0';
64 GetModuleFileNameA(hInstance
, filenameBuf
, sizeof(filenameBuf
));
65 filename
= filenameBuf
;
68 dladdr((void*)getBinaryFilename
, &info
);
69 char filenameBuf
[PATH_MAX
];
70 filename
= realpath(info
.dli_fname
, filenameBuf
);
77 const char* getPluginFormatName() noexcept
79 #if defined(DISTRHO_PLUGIN_TARGET_CARLA)
81 #elif defined(DISTRHO_PLUGIN_TARGET_JACK)
82 # ifdef DISTRHO_OS_WASM
83 return "Wasm/Standalone";
85 return "JACK/Standalone";
87 #elif defined(DISTRHO_PLUGIN_TARGET_LADSPA)
89 #elif defined(DISTRHO_PLUGIN_TARGET_DSSI)
91 #elif defined(DISTRHO_PLUGIN_TARGET_LV2)
93 #elif defined(DISTRHO_PLUGIN_TARGET_VST2)
95 #elif defined(DISTRHO_PLUGIN_TARGET_VST3)
102 const char* getResourcePath(const char* const bundlePath
) noexcept
104 DISTRHO_SAFE_ASSERT_RETURN(bundlePath
!= nullptr, nullptr);
106 #if defined(DISTRHO_PLUGIN_TARGET_JACK) || defined(DISTRHO_PLUGIN_TARGET_VST2)
107 static String resourcePath
;
109 if (resourcePath
.isEmpty())
111 resourcePath
= bundlePath
;
112 # ifdef DISTRHO_OS_MAC
113 resourcePath
+= "/Contents/Resources";
115 resourcePath
+= DISTRHO_OS_SEP_STR
"resources";
119 return resourcePath
.buffer();
120 #elif defined(DISTRHO_PLUGIN_TARGET_LV2)
121 static String resourcePath
;
123 if (resourcePath
.isEmpty())
125 resourcePath
= bundlePath
;
126 resourcePath
+= DISTRHO_OS_SEP_STR
"resources";
129 return resourcePath
.buffer();
130 #elif defined(DISTRHO_PLUGIN_TARGET_VST3)
131 static String resourcePath
;
133 if (resourcePath
.isEmpty())
135 resourcePath
= bundlePath
;
136 resourcePath
+= "/Contents/Resources";
139 return resourcePath
.buffer();
145 #ifndef DISTRHO_PLUGIN_TARGET_JACK
146 // all these are null for non-standalone targets
147 bool isUsingNativeAudio() noexcept
{ return false; }
148 bool supportsAudioInput() { return false; }
149 bool supportsBufferSizeChanges() { return false; }
150 bool supportsMIDI() { return false; }
151 bool isAudioInputEnabled() { return false; }
152 bool isMIDIEnabled() { return false; }
153 uint
getBufferSize() { return 0; }
154 bool requestAudioInput() { return false; }
155 bool requestBufferSizeChange(uint
) { return false; }
156 bool requestMIDI() { return false; }
159 // -----------------------------------------------------------------------
161 END_NAMESPACE_DISTRHO