1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

AudioProcessor: Return unique_ptr from createPluginFilterOfType

This commit is contained in:
reuk 2022-12-12 13:10:56 +00:00
parent 403ba3007f
commit d6f30304f0
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
8 changed files with 12 additions and 12 deletions

View file

@ -2483,7 +2483,7 @@ namespace AAXClasses
static void getPlugInDescription (AAX_IEffectDescriptor& descriptor, [[maybe_unused]] const AAX_IFeatureInfo* featureInfo)
{
std::unique_ptr<AudioProcessor> plugin (createPluginFilterOfType (AudioProcessor::wrapperType_AAX));
auto plugin = createPluginFilterOfType (AudioProcessor::wrapperType_AAX);
auto numInputBuses = plugin->getBusCount (true);
auto numOutputBuses = plugin->getBusCount (false);

View file

@ -92,7 +92,7 @@ struct AudioProcessorHolder
if (initialiseGUI)
initialiseJuce_GUI();
juceFilter.reset (createPluginFilterOfType (AudioProcessor::wrapperType_AudioUnit));
juceFilter = createPluginFilterOfType (AudioProcessor::wrapperType_AudioUnit);
// audio units do not have a notion of enabled or un-enabled buses
juceFilter->enableAllBuses();

View file

@ -79,7 +79,7 @@ using namespace juce;
struct AudioProcessorHolder : public ReferenceCountedObject
{
AudioProcessorHolder() = default;
explicit AudioProcessorHolder (AudioProcessor* p) : processor (p) {}
explicit AudioProcessorHolder (std::unique_ptr<AudioProcessor> p) : processor (std::move (p)) {}
AudioProcessor& operator*() noexcept { return *processor; }
AudioProcessor* operator->() noexcept { return processor.get(); }
AudioProcessor* get() noexcept { return processor.get(); }
@ -1746,9 +1746,9 @@ public:
{
JUCE_ASSERT_MESSAGE_THREAD
if (AudioProcessor* p = createPluginFilterOfType (AudioProcessor::wrapperType_AudioUnitv3))
if (auto p = createPluginFilterOfType (AudioProcessor::wrapperType_AudioUnitv3))
{
processorHolder = new AudioProcessorHolder (p);
processorHolder = new AudioProcessorHolder (std::move (p));
auto& processor = getAudioProcessor();
if (processor.hasEditor())

View file

@ -721,7 +721,7 @@ public:
static std::unique_ptr<AudioProcessor> createProcessorInstance()
{
auto result = rawToUniquePtr (createPluginFilterOfType (AudioProcessor::wrapperType_LV2));
auto result = createPluginFilterOfType (AudioProcessor::wrapperType_LV2);
#if defined (JucePlugin_PreferredChannelConfigurations)
constexpr short channelConfigurations[][2] { JucePlugin_PreferredChannelConfigurations };

View file

@ -124,7 +124,7 @@ public:
//==============================================================================
virtual void createPlugin()
{
processor.reset (createPluginFilterOfType (AudioProcessor::wrapperType_Standalone));
processor = createPluginFilterOfType (AudioProcessor::wrapperType_Standalone);
processor->disableNonMainBuses();
processor->setRateAndBufferSizeDetails (44100, 512);

View file

@ -292,7 +292,7 @@ class AudioProcessorUnityWrapper
public:
AudioProcessorUnityWrapper (bool isTemporary)
{
pluginInstance.reset (createPluginFilterOfType (AudioProcessor::wrapperType_Unity));
pluginInstance = createPluginFilterOfType (AudioProcessor::wrapperType_Unity);
if (! isTemporary && pluginInstance->hasEditor())
{

View file

@ -2420,7 +2420,7 @@ class JuceVST3Component : public Vst::IComponent,
{
public:
JuceVST3Component (Vst::IHostApplication* h)
: pluginInstance (createPluginFilterOfType (AudioProcessor::wrapperType_VST3)),
: pluginInstance (createPluginFilterOfType (AudioProcessor::wrapperType_VST3).release()),
host (h)
{
inParameterChangedCallback = false;

View file

@ -28,18 +28,18 @@
namespace juce
{
inline AudioProcessor* JUCE_API JUCE_CALLTYPE createPluginFilterOfType (AudioProcessor::WrapperType type)
inline std::unique_ptr<AudioProcessor> createPluginFilterOfType (AudioProcessor::WrapperType type)
{
PluginHostType::jucePlugInClientCurrentWrapperType = type;
AudioProcessor::setTypeOfNextNewPlugin (type);
AudioProcessor* const pluginInstance = ::createPluginFilter();
auto pluginInstance = rawToUniquePtr (::createPluginFilter());
AudioProcessor::setTypeOfNextNewPlugin (AudioProcessor::wrapperType_Undefined);
// your createPluginFilter() method must return an object!
jassert (pluginInstance != nullptr && pluginInstance->wrapperType == type);
#if JucePlugin_Enable_ARA
jassert (dynamic_cast<juce::AudioProcessorARAExtension*> (pluginInstance) != nullptr);
jassert (dynamic_cast<juce::AudioProcessorARAExtension*> (pluginInstance.get()) != nullptr);
#endif
return pluginInstance;