diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 83dfe5efb6..7a414e6d2f 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -2,6 +2,25 @@ # Version 8.0.9 +## Change + +The function AudioPluginFormatManager::addDefaultFormats() has been removed. + +**Possible Issues** + +Code that calls this function will fail to compile. + +**Workaround** + +Use the new non-member function "addDefaultFormatsToManager()" instead. + +**Rationale** + +This change removes the dependency between the AudioPluginFormatManager and the +concrete plugin format types, allowing the AudioPluginFormatManager to be built +in isolation. + + ## Change The signatures of OpenGLFrameBuffer::readPixels() and diff --git a/examples/Plugins/HostPluginDemo.h b/examples/Plugins/HostPluginDemo.h index 89cb55fc89..9c7257d46e 100644 --- a/examples/Plugins/HostPluginDemo.h +++ b/examples/Plugins/HostPluginDemo.h @@ -84,7 +84,7 @@ public: return opt; }()); - pluginFormatManager.addDefaultFormats(); + addDefaultFormatsToManager (pluginFormatManager); if (auto savedPluginList = appProperties.getUserSettings()->getXmlValue ("pluginList")) pluginList.recreateFromXml (*savedPluginList); diff --git a/extras/AudioPluginHost/Source/HostStartup.cpp b/extras/AudioPluginHost/Source/HostStartup.cpp index 519f850949..d4899455b4 100644 --- a/extras/AudioPluginHost/Source/HostStartup.cpp +++ b/extras/AudioPluginHost/Source/HostStartup.cpp @@ -46,7 +46,7 @@ class PluginScannerSubprocess final : private ChildProcessWorker, public: PluginScannerSubprocess() { - formatManager.addDefaultFormats(); + addDefaultFormatsToManager (formatManager); } using ChildProcessWorker::initialiseFromCommandLine; diff --git a/extras/AudioPluginHost/Source/UI/MainHostWindow.cpp b/extras/AudioPluginHost/Source/UI/MainHostWindow.cpp index cc3466f488..644c89a859 100644 --- a/extras/AudioPluginHost/Source/UI/MainHostWindow.cpp +++ b/extras/AudioPluginHost/Source/UI/MainHostWindow.cpp @@ -314,8 +314,8 @@ MainHostWindow::MainHostWindow() LookAndFeel::getDefaultLookAndFeel().findColour (ResizableWindow::backgroundColourId), DocumentWindow::allButtons) { - formatManager.addDefaultFormats(); - formatManager.addFormat (new InternalPluginFormat()); + addDefaultFormatsToManager (formatManager); + formatManager.addFormat (std::make_unique()); auto safeThis = SafePointer (this); RuntimePermissions::request (RuntimePermissions::recordAudio, diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp index 90065b9c15..f695e29096 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.cpp @@ -37,56 +37,27 @@ namespace juce { -AudioPluginFormatManager::AudioPluginFormatManager() {} -AudioPluginFormatManager::~AudioPluginFormatManager() {} - //============================================================================== -void AudioPluginFormatManager::addDefaultFormats() +void addDefaultFormatsToManager (AudioPluginFormatManager& manager) { - #if JUCE_DEBUG - // you should only call this method once! - for (auto* format [[maybe_unused]] : formats) - { - #if JUCE_INTERNAL_HAS_VST - jassert (dynamic_cast (format) == nullptr); - #endif - - #if JUCE_INTERNAL_HAS_VST3 - jassert (dynamic_cast (format) == nullptr); - #endif - - #if JUCE_INTERNAL_HAS_AU - jassert (dynamic_cast (format) == nullptr); - #endif - - #if JUCE_INTERNAL_HAS_LADSPA - jassert (dynamic_cast (format) == nullptr); - #endif - - #if JUCE_INTERNAL_HAS_LV2 - jassert (dynamic_cast (format) == nullptr); - #endif - } - #endif - #if JUCE_INTERNAL_HAS_AU - formats.add (new AudioUnitPluginFormat()); + manager.addFormat (std::make_unique()); #endif #if JUCE_INTERNAL_HAS_VST - formats.add (new VSTPluginFormat()); + manager.addFormat (std::make_unique()); #endif #if JUCE_INTERNAL_HAS_VST3 - formats.add (new VST3PluginFormat()); + manager.addFormat (std::make_unique()); #endif #if JUCE_INTERNAL_HAS_LADSPA - formats.add (new LADSPAPluginFormat()); + manager.addFormat (std::make_unique()); #endif #if JUCE_INTERNAL_HAS_LV2 - formats.add (new LV2PluginFormat()); + manager.addFormat (std::make_unique()); #endif } @@ -100,9 +71,19 @@ Array AudioPluginFormatManager::getFormats() const return a; } -void AudioPluginFormatManager::addFormat (AudioPluginFormat* format) +void AudioPluginFormatManager::addFormat (std::unique_ptr format) { - formats.add (format); + for (auto* existing : formats) + { + if (existing->getName() == format->getName()) + { + // This format manager already contains a format with this name! + jassertfalse; + return; + } + } + + formats.add (std::move (format)); } std::unique_ptr AudioPluginFormatManager::createPluginInstance (const PluginDescription& description, diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h index a71a3160ee..1175c81767 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h @@ -47,14 +47,14 @@ class JUCE_API AudioPluginFormatManager { public: //============================================================================== - AudioPluginFormatManager(); - - /** Destructor. */ - ~AudioPluginFormatManager(); + AudioPluginFormatManager() = default; //============================================================================== - /** Adds the set of available standard formats, e.g. VST. */ - void addDefaultFormats(); + /** This function has been removed. To add default formats to the manager, + use one of the new functions addDefaultFormatsToManager() or + addHeadlessDefaultFormatsToManager(); + */ + void addDefaultFormats() = delete; //============================================================================== /** Returns the number of types of format that are available. @@ -74,7 +74,13 @@ public: /** Adds a format to the list. The object passed in will be owned and deleted by the manager. */ - void addFormat (AudioPluginFormat*); + [[deprecated ("Prefer the signature that accepts a unique_ptr")]] + void addFormat (AudioPluginFormat* f) { addFormat (rawToUniquePtr (f)); } + + /** Adds a format to the list. + The object passed in will be owned and deleted by the manager. + */ + void addFormat (std::unique_ptr); //============================================================================== /** Tries to load the type for this description, by trying all the formats @@ -148,4 +154,10 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginFormatManager) }; +/** Add all standard plugin formats to the AudioPluginFormatManager, *with* UI support. + + This function replaces AudioPluginFormatManager::addDefaultFormats(). +*/ +void addDefaultFormatsToManager (AudioPluginFormatManager&); + } // namespace juce