1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +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

@ -2,6 +2,25 @@
# Version 8.0.9 # 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 ## Change
The signatures of OpenGLFrameBuffer::readPixels() and The signatures of OpenGLFrameBuffer::readPixels() and

View file

@ -84,7 +84,7 @@ public:
return opt; return opt;
}()); }());
pluginFormatManager.addDefaultFormats(); addDefaultFormatsToManager (pluginFormatManager);
if (auto savedPluginList = appProperties.getUserSettings()->getXmlValue ("pluginList")) if (auto savedPluginList = appProperties.getUserSettings()->getXmlValue ("pluginList"))
pluginList.recreateFromXml (*savedPluginList); pluginList.recreateFromXml (*savedPluginList);

View file

@ -46,7 +46,7 @@ class PluginScannerSubprocess final : private ChildProcessWorker,
public: public:
PluginScannerSubprocess() PluginScannerSubprocess()
{ {
formatManager.addDefaultFormats(); addDefaultFormatsToManager (formatManager);
} }
using ChildProcessWorker::initialiseFromCommandLine; using ChildProcessWorker::initialiseFromCommandLine;

View file

@ -314,8 +314,8 @@ MainHostWindow::MainHostWindow()
LookAndFeel::getDefaultLookAndFeel().findColour (ResizableWindow::backgroundColourId), LookAndFeel::getDefaultLookAndFeel().findColour (ResizableWindow::backgroundColourId),
DocumentWindow::allButtons) DocumentWindow::allButtons)
{ {
formatManager.addDefaultFormats(); addDefaultFormatsToManager (formatManager);
formatManager.addFormat (new InternalPluginFormat()); formatManager.addFormat (std::make_unique<InternalPluginFormat>());
auto safeThis = SafePointer<MainHostWindow> (this); auto safeThis = SafePointer<MainHostWindow> (this);
RuntimePermissions::request (RuntimePermissions::recordAudio, RuntimePermissions::request (RuntimePermissions::recordAudio,

View file

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

View file

@ -47,14 +47,14 @@ class JUCE_API AudioPluginFormatManager
{ {
public: public:
//============================================================================== //==============================================================================
AudioPluginFormatManager(); AudioPluginFormatManager() = default;
/** Destructor. */
~AudioPluginFormatManager();
//============================================================================== //==============================================================================
/** Adds the set of available standard formats, e.g. VST. */ /** This function has been removed. To add default formats to the manager,
void addDefaultFormats(); use one of the new functions addDefaultFormatsToManager() or
addHeadlessDefaultFormatsToManager();
*/
void addDefaultFormats() = delete;
//============================================================================== //==============================================================================
/** Returns the number of types of format that are available. /** Returns the number of types of format that are available.
@ -74,7 +74,13 @@ public:
/** Adds a format to the list. /** Adds a format to the list.
The object passed in will be owned and deleted by the manager. 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 /** 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) 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 } // namespace juce