commit 09ad9bb5701d892b71469ad809a0fd2596b20797
parent fb11675884a0fe166708e8887e9cdfda22d2f56e
Author: falkTX <falktx@falktx.com>
Date: Wed, 29 Dec 2021 17:09:08 +0000
Allow JACK/Standalone to have resources/bundle path too
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
2 files changed, 51 insertions(+), 21 deletions(-)
diff --git a/distrho/src/DistrhoPluginJACK.cpp b/distrho/src/DistrhoPluginJACK.cpp
@@ -15,6 +15,7 @@
*/
#include "DistrhoPluginInternal.hpp"
+#include "../DistrhoPluginUtils.hpp"
#if DISTRHO_PLUGIN_HAS_UI
# include "DistrhoUIInternal.hpp"
@@ -32,6 +33,7 @@
#ifndef DISTRHO_OS_WINDOWS
# include <signal.h>
+# include <unistd.h>
#endif
#ifndef JACK_METADATA_ORDER
@@ -949,6 +951,34 @@ int main(int argc, char* argv[])
d_nextSampleRate = jackbridge_get_sample_rate(client);
d_nextCanRequestParameterValueChanges = true;
+ #ifndef DISTRHO_OS_WINDOWS
+ // find plugin bundle
+ static String bundlePath;
+ if (bundlePath.isEmpty())
+ {
+ String tmpPath(getBinaryFilename());
+ tmpPath.truncate(tmpPath.rfind(DISTRHO_OS_SEP));
+ #ifdef DISTRHO_OS_MAC
+ if (tmpPath.endsWith("/MacOS"))
+ {
+ tmpPath.truncate(tmpPath.rfind('/'));
+ if (tmpPath.endsWith("/Contents"))
+ {
+ tmpPath.truncate(tmpPath.rfind('/'));
+ bundlePath = tmpPath;
+ d_nextBundlePath = bundlePath.buffer();
+ }
+ }
+ #else
+ if (access(tmpPath + DISTRHO_OS_SEP_STR "resources", F_OK) == 0)
+ {
+ bundlePath = tmpPath;
+ d_nextBundlePath = bundlePath.buffer();
+ }
+ #endif
+ }
+ #endif
+
const PluginJack p(client);
return 0;
diff --git a/distrho/src/DistrhoUtils.cpp b/distrho/src/DistrhoUtils.cpp
@@ -94,40 +94,40 @@ const char* getResourcePath(const char* const bundlePath) noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(bundlePath != nullptr, nullptr);
-#if defined(DISTRHO_PLUGIN_TARGET_LV2)
- static String bundlePathLV2;
+#if defined(DISTRHO_PLUGIN_TARGET_JACK) || defined(DISTRHO_PLUGIN_TARGET_VST2)
+ static String resourcePath;
- if (bundlePathLV2.isEmpty())
+ if (resourcePath.isEmpty())
{
- bundlePathLV2 = bundlePath;
- bundlePathLV2 += DISTRHO_OS_SEP_STR "resources";
+ resourcePath = bundlePath;
+# ifdef DISTRHO_OS_MAC
+ resourcePath += "/Contents/Resources";
+# else
+ resourcePath += DISTRHO_OS_SEP_STR "resources";
+# endif
}
- return bundlePathLV2.buffer();
-#elif defined(DISTRHO_PLUGIN_TARGET_VST2)
- static String bundlePathVST2;
+ return resourcePath.buffer();
+#elif defined(DISTRHO_PLUGIN_TARGET_LV2)
+ static String resourcePath;
- if (bundlePathVST2.isEmpty())
+ if (resourcePath.isEmpty())
{
- bundlePathVST2 = bundlePath;
-# ifdef DISTRHO_OS_MAC
- bundlePathVST2 += "/Contents/Resources";
-# else
- bundlePathVST2 += DISTRHO_OS_SEP_STR "resources";
-# endif
+ resourcePath = bundlePath;
+ resourcePath += DISTRHO_OS_SEP_STR "resources";
}
- return bundlePathVST2.buffer();
+ return resourcePath.buffer();
#elif defined(DISTRHO_PLUGIN_TARGET_VST3)
- static String bundlePathVST3;
+ static String resourcePath;
- if (bundlePathVST3.isEmpty())
+ if (resourcePath.isEmpty())
{
- bundlePathVST3 = bundlePath;
- bundlePathVST3 += "/Contents/Resources";
+ resourcePath = bundlePath;
+ resourcePath += "/Contents/Resources";
}
- return bundlePathVST3.buffer();
+ return resourcePath.buffer();
#endif
return nullptr;