From 71528d7daa9fc5683a5560b9e07b116bfc717f8f Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 26 Oct 2014 17:56:14 +0000 Subject: [PATCH] Fix loading VST3 plugins, closes #155 --- source/backend/plugin/JucePlugin.cpp | 16 ++++++++------ source/discovery/carla-discovery.cpp | 22 +++++++++++++++---- .../format_types/juce_VST3PluginFormat.cpp | 3 ++- source/utils/CarlaJuceUtils.hpp | 6 +++++ source/utils/CarlaStateUtils.cpp | 3 +-- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/source/backend/plugin/JucePlugin.cpp b/source/backend/plugin/JucePlugin.cpp index 20a9ca3e4..015333697 100644 --- a/source/backend/plugin/JucePlugin.cpp +++ b/source/backend/plugin/JucePlugin.cpp @@ -1147,14 +1147,14 @@ public: return false; } - if (std::strcmp(format, "AU") == 0) + if (label == nullptr || label[0] == '\0') { - if (label == nullptr || label[0] == '\0') - { - pData->engine->setLastError("null label"); - return false; - } + pData->engine->setLastError("null label"); + return false; + } + if (std::strcmp(format, "AU") == 0) + { fDesc.fileOrIdentifier = label; } else @@ -1168,7 +1168,8 @@ public: String jfilename(filename); #ifdef CARLA_OS_WIN - if (jfilename.startsWith("/")) + // Fix for wine usage + if (juce_isRunningInWine() && filename[0] == '/') { jfilename.replace("/", "\\"); jfilename = "Z:" + jfilename; @@ -1176,6 +1177,7 @@ public: #endif fDesc.fileOrIdentifier = jfilename; + fDesc.name = label; fDesc.uid = static_cast(uniqueId); } diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index fe2e4e05b..e5a88bbe2 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -1381,10 +1381,21 @@ static void do_juce_check(const char* const filename_, const char* const stype, carla_debug("do_juce_check(%s, %s, %s)", filename_, stype, bool2str(doInit)); using namespace juce; + juce::String filename; - juce::String filename(File(filename_).getFullPathName()); +#ifdef CARLA_OS_WIN + // Fix for wine usage + if (juce_isRunningInWine() && filename_[0] == '/') + { + filename = filename_; + filename.replace("/", "\\"); + filename = "Z:" + filename; + } + else +#endif + filename = File(filename_).getFullPathName(); - ScopedPointer pluginFormat; + juce::ScopedPointer pluginFormat; /* */ if (std::strcmp(stype, "VST") == 0) { @@ -1417,6 +1428,9 @@ static void do_juce_check(const char* const filename_, const char* const stype, return; } +#ifdef CARLA_OS_WIN + CARLA_SAFE_ASSERT_RETURN(File(filename).existsAsFile(),); +#endif CARLA_SAFE_ASSERT_RETURN(pluginFormat->fileMightContainThisPluginType(filename),); OwnedArray results; @@ -1464,8 +1478,8 @@ static void do_juce_check(const char* const filename_, const char* const stype, DISCOVERY_OUT("init", "-----------"); DISCOVERY_OUT("build", BINARY_NATIVE); DISCOVERY_OUT("hints", hints); - DISCOVERY_OUT("name", desc->name); - DISCOVERY_OUT("label", desc->descriptiveName); + DISCOVERY_OUT("name", desc->descriptiveName); + DISCOVERY_OUT("label", desc->name); DISCOVERY_OUT("maker", desc->manufacturerName); DISCOVERY_OUT("uniqueId", desc->uid); DISCOVERY_OUT("audio.ins", audioIns); diff --git a/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index a7416264c..8170fcafc 100644 --- a/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/source/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -1403,7 +1403,8 @@ private: const Result result (finder.findDescriptionsAndPerform (f)); - if (result.getErrorMessage() == MatchingDescriptionFinder::getSuccessString()) + if (result.getErrorMessage() == MatchingDescriptionFinder::getSuccessString() || + result.getErrorMessage().isEmpty()) { name = description.name; return true; diff --git a/source/utils/CarlaJuceUtils.hpp b/source/utils/CarlaJuceUtils.hpp index 3264c10ea..c3f8a759b 100644 --- a/source/utils/CarlaJuceUtils.hpp +++ b/source/utils/CarlaJuceUtils.hpp @@ -193,4 +193,10 @@ private: CARLA_PREVENT_HEAP_ALLOCATION }; +#ifdef CARLA_OS_WIN +namespace juce { +extern bool juce_isRunningInWine(); +} +#endif + #endif // CARLA_JUCE_UTILS_HPP_INCLUDED diff --git a/source/utils/CarlaStateUtils.cpp b/source/utils/CarlaStateUtils.cpp index 0eda7830d..0bdb24648 100644 --- a/source/utils/CarlaStateUtils.cpp +++ b/source/utils/CarlaStateUtils.cpp @@ -506,9 +506,8 @@ String StateSave::toString() const infoXml << " " << uniqueId << "\n"; break; case PLUGIN_VST3: - // TODO? infoXml << " " << xmlSafeString(binary, true) << "\n"; - infoXml << " " << uniqueId << "\n"; + infoXml << " \n"; break; case PLUGIN_AU: infoXml << " " << xmlSafeString(label, true) << "\n";