1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

AudioPluginFormatManager: Replace addDefaultFormats function() with non-member

This commit is contained in:
reuk 2025-08-15 18:14:02 +01:00
parent 33b9f1e6ec
commit 426b74fcf7
No known key found for this signature in database
6 changed files with 60 additions and 48 deletions

View file

@ -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<VSTPluginFormat*> (format) == nullptr);
#endif
#if JUCE_INTERNAL_HAS_VST3
jassert (dynamic_cast<VST3PluginFormat*> (format) == nullptr);
#endif
#if JUCE_INTERNAL_HAS_AU
jassert (dynamic_cast<AudioUnitPluginFormat*> (format) == nullptr);
#endif
#if JUCE_INTERNAL_HAS_LADSPA
jassert (dynamic_cast<LADSPAPluginFormat*> (format) == nullptr);
#endif
#if JUCE_INTERNAL_HAS_LV2
jassert (dynamic_cast<LV2PluginFormat*> (format) == nullptr);
#endif
}
#endif
#if JUCE_INTERNAL_HAS_AU
formats.add (new AudioUnitPluginFormat());
manager.addFormat (std::make_unique<AudioUnitPluginFormat>());
#endif
#if JUCE_INTERNAL_HAS_VST
formats.add (new VSTPluginFormat());
manager.addFormat (std::make_unique<VSTPluginFormat>());
#endif
#if JUCE_INTERNAL_HAS_VST3
formats.add (new VST3PluginFormat());
manager.addFormat (std::make_unique<VST3PluginFormat>());
#endif
#if JUCE_INTERNAL_HAS_LADSPA
formats.add (new LADSPAPluginFormat());
manager.addFormat (std::make_unique<LADSPAPluginFormat>());
#endif
#if JUCE_INTERNAL_HAS_LV2
formats.add (new LV2PluginFormat());
manager.addFormat (std::make_unique<LV2PluginFormat>());
#endif
}
@ -100,9 +71,19 @@ Array<AudioPluginFormat*> AudioPluginFormatManager::getFormats() const
return a;
}
void AudioPluginFormatManager::addFormat (AudioPluginFormat* format)
void AudioPluginFormatManager::addFormat (std::unique_ptr<AudioPluginFormat> 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<AudioPluginInstance> AudioPluginFormatManager::createPluginInstance (const PluginDescription& description,

View file

@ -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<AudioPluginFormat>);
//==============================================================================
/** 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