diff --git a/distrho/src/DistrhoPluginJACK.cpp b/distrho/src/DistrhoPluginJACK.cpp index 8329d327..40446937 100644 --- 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 +# include #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 index eb39fdc5..772f4b67 100644 --- 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;