From 5d20cc3b8722977d09b42d87a25205e9efe3efac Mon Sep 17 00:00:00 2001 From: =?utf8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 20 Aug 2019 14:38:49 +0200 Subject: [PATCH] JUCE544 compat Gbp-Pq: Name 0003-JUCE544-compat.patch --- src/core/plugin.cpp | 6 +++--- src/core/plugin.h | 4 ++-- src/core/pluginManager.cpp | 18 ++++++++---------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/core/plugin.cpp b/src/core/plugin.cpp index 32e9b88..26108ca 100644 --- a/src/core/plugin.cpp +++ b/src/core/plugin.cpp @@ -48,9 +48,9 @@ int Plugin::m_idGenerator = 1; /* -------------------------------------------------------------------------- */ -Plugin::Plugin(juce::AudioPluginInstance* plugin, double samplerate, int buffersize) +Plugin::Plugin(std::unique_ptr plugin, double samplerate, int buffersize) : m_ui (nullptr), - m_plugin(plugin), + m_plugin(std::move(plugin)), m_id (m_idGenerator++), m_bypass(false) { @@ -59,7 +59,7 @@ Plugin::Plugin(juce::AudioPluginInstance* plugin, double samplerate, int buffers /* Init midiInParams. All values are empty (0x0): they will be filled during midi learning process. */ - const OwnedArray& params = m_plugin->getParameters(); + auto params = m_plugin->getParameters(); for (int i=0; i p, double samplerate, int buffersize); ~Plugin(); /* getUniqueId @@ -102,7 +102,7 @@ private: static int m_idGenerator; juce::AudioProcessorEditor* m_ui; // gui - juce::AudioPluginInstance* m_plugin; // core + std::unique_ptr m_plugin; // core juce::AudioBuffer m_buffer; int m_id; diff --git a/src/core/pluginManager.cpp b/src/core/pluginManager.cpp index 4b6d1a1..53a6186 100644 --- a/src/core/pluginManager.cpp +++ b/src/core/pluginManager.cpp @@ -104,14 +104,14 @@ VSTs: their ID is based on the plug-in file location. E.g.: The following function simply drops the first hash code during comparison. */ -const juce::PluginDescription* findPluginDescription_(const string& id) +std::unique_ptr findPluginDescription_(const string& id) { vector idParts = splitPluginDescription_(id); - for (const juce::PluginDescription* pd : knownPluginList_) { + for (auto pd : knownPluginList_) { vector tmpIdParts = splitPluginDescription_(pd->createIdentifierString().toStdString()); if (idParts[0] == tmpIdParts[0] && idParts[2] == tmpIdParts[2]) - return pd; + return std::unique_ptr (pd); } return nullptr; } @@ -181,10 +181,9 @@ int saveList(const string& filepath) int loadList(const string& filepath) { - juce::XmlElement* elem = juce::XmlDocument::parse(juce::File(filepath)); + std::unique_ptr elem = juce::XmlDocument::parse(juce::File(filepath)); if (elem != nullptr) { knownPluginList_.recreateFromXml(*elem); - delete elem; return 1; } return 0; @@ -199,11 +198,11 @@ std::unique_ptr makePlugin(const string& fid) /* Initialize plugin. The default mode uses getTypeForIdentifierString, falling back to getTypeForFile (deprecated) for old patches (< 0.14.4). */ - const juce::PluginDescription* pd = findPluginDescription_(fid); + auto pd = findPluginDescription_(fid); if (pd == nullptr) { gu_log("[pluginManager::makePlugin] no plugin found with fid=%s! Trying with " "deprecated mode...\n", fid.c_str()); - pd = knownPluginList_.getTypeForFile(fid); + pd = std::move(knownPluginList_.getTypeForFile(fid)); if (pd == nullptr) { gu_log("[pluginManager::makePlugin] still nothing to do, returning unknown plugin\n"); missingPlugins_ = true; @@ -212,15 +211,14 @@ std::unique_ptr makePlugin(const string& fid) } } - juce::AudioPluginInstance* pi = pluginFormat_.createInstanceFromDescription(*pd, samplerate_, buffersize_); + auto pi = pluginFormat_.createInstanceFromDescription(*pd, samplerate_, buffersize_); if (!pi) { gu_log("[pluginManager::makePlugin] unable to create instance with fid=%s!\n", fid.c_str()); missingPlugins_ = true; return {}; } gu_log("[pluginManager::makePlugin] plugin instance with fid=%s created\n", fid.c_str()); - - return std::make_unique(pi, samplerate_, buffersize_); + return std::make_unique(std::move(pi), samplerate_, buffersize_); } -- 2.30.2