From ca8b5f7483ef0b882f733ee7f9fc2b38d0b127e7 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 10 Oct 2024 13:18:09 +0100 Subject: [PATCH] VST3 Host: Use correct path to .so on Linux This fixes an issue where VST3 plugins failed to scan and load on Linux. --- .../format_types/juce_VST3PluginFormat.cpp | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 2312683ba4..14611a9b5b 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -1334,8 +1334,10 @@ public: return handle.getFile(); } - static Ptr getHandle (const File& f) + static Ptr getHandle (const String& modulePath) { + const auto f = getDLLFileFromBundle (modulePath); + auto& bundles = getHandles(); const auto iter = std::find_if (bundles.begin(), bundles.end(), [&] (Ptr x) @@ -1356,6 +1358,30 @@ private: getHandles().insert (this); } + static File getDLLFileFromBundle (const String& bundlePath) + { + #if JUCE_LINUX || JUCE_BSD + const auto machineName = []() -> String + { + struct utsname unameData; + const auto res = uname (&unameData); + + if (res != 0) + return {}; + + return unameData.machine; + }(); + + const File file { bundlePath }; + + return file.getChildFile ("Contents") + .getChildFile (machineName + "-linux") + .getChildFile (file.getFileNameWithoutExtension() + ".so"); + #else + return File { bundlePath }; + #endif + } + static std::set& getHandles() { static std::set bundles; @@ -1373,7 +1399,7 @@ public: static VST3ModuleHandle create (const File& pluginFile, const PluginDescription& desc) { VST3ModuleHandle result; - result.handle = RefCountedDllHandle::getHandle (pluginFile); + result.handle = RefCountedDllHandle::getHandle (pluginFile.getFullPathName()); if (result.handle == nullptr) return {};