From 39eae806de0107cb342dd8f3ceeff30f77e8009b Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 6 Dec 2012 15:18:02 +0000 Subject: [PATCH] Changes to make sure the AudioProcessor::wrapperType member is set correctly when its constructor is called. --- .../AAX/juce_AAX_Wrapper.cpp | 11 +-------- .../AU/juce_AU_Wrapper.mm | 11 +-------- .../RTAS/juce_RTAS_Wrapper.cpp | 12 +--------- .../Standalone/juce_StandaloneFilterWindow.h | 14 +++-------- .../VST/juce_VST_Wrapper.cpp | 21 +++-------------- .../utility/juce_IncludeModuleHeaders.h | 2 ++ .../utility/juce_PluginUtilities.cpp | 23 ++++++++++++++++++- .../juce_AudioUnitPluginFormat.mm | 2 +- .../processors/juce_AudioProcessor.cpp | 9 +++++++- .../processors/juce_AudioProcessor.h | 3 +++ 10 files changed, 45 insertions(+), 63 deletions(-) diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp index 30284ff322..703cd161ac 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -54,12 +54,6 @@ using juce::Component; -//============================================================================== -/** Somewhere in the codebase of your plugin, you need to implement this function - and make it return a new instance of the filter subclass that you're building. -*/ -extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); - //============================================================================== struct AAXClasses { @@ -362,10 +356,7 @@ struct AAXClasses public: JuceAAX_Parameters() { - pluginInstance = createPluginFilter(); - jassert (pluginInstance != nullptr); // your createPluginFilter() method must return an object! - - pluginInstance->wrapperType = AudioProcessor::wrapperType_AAX; + pluginInstance = createPluginFilterOfType (AudioProcessor::wrapperType_AAX); } static AAX_CEffectParameters* AAX_CALLBACK Create() { return new JuceAAX_Parameters(); } diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index d6e1f26661..1b17ddaea3 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -108,12 +108,6 @@ static const int numChannelConfigs = sizeof (channelConfigs) / sizeof (*channelC #define JUCE_STATE_DICTIONARY_KEY CFSTR("jucePluginState") #endif -//============================================================================== -/** Somewhere in the codebase of your plugin, you need to implement this function - and make it create an instance of the filter subclass that you're building. -*/ -extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); - //============================================================================== class JuceAU : public JuceAUBaseClass, public AudioProcessorListener, @@ -140,10 +134,7 @@ public: initialiseJuce_GUI(); } - juceFilter = createPluginFilter(); - jassert (juceFilter != nullptr); // your createPluginFilter() method must return an object! - - juceFilter->wrapperType = AudioProcessor::wrapperType_AudioUnit; + juceFilter = createPluginFilterOfType (AudioProcessor::wrapperType_AudioUnit); juceFilter->setPlayHead (this); juceFilter->addListener (this); diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp index b2db17e6d7..3d2da4ab65 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp @@ -133,15 +133,8 @@ const int midiBufferSize = 1024; const OSType juceChunkType = 'juce'; static const int bypassControlIndex = 1; -//============================================================================== -/** Somewhere in the codebase of your plugin, you need to implement this function - and make it return a new instance of the filter subclass that you're building. -*/ -extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); - static int numInstances = 0; - //============================================================================== class JucePlugInProcess : public CEffectProcessMIDI, public CEffectProcessRTAS, @@ -155,10 +148,7 @@ public: sampleRate (44100.0) { asyncUpdater = new InternalAsyncUpdater (*this); - juceFilter = createPluginFilter(); - jassert (juceFilter != nullptr); // your createPluginFilter() method must return an object! - - juceFilter->wrapperType = AudioProcessor::wrapperType_RTAS; + juceFilter = createPluginFilterOfType (AudioProcessor::wrapperType_RTAS); AddChunk (juceChunkType, "Juce Audio Plugin Data"); diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h index 41a84feb49..532d0dd0dc 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -26,13 +26,7 @@ #ifndef __JUCE_STANDALONEFILTERWINDOW_JUCEHEADER__ #define __JUCE_STANDALONEFILTERWINDOW_JUCEHEADER__ - -//============================================================================== -/** Somewhere in the codebase of your plugin, you need to implement this function - and make it create an instance of the filter subclass that you're building. -*/ -extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); - +extern AudioProcessor* JUCE_CALLTYPE createPluginFilterOfType (AudioProcessor::WrapperType); //============================================================================== /** @@ -67,7 +61,7 @@ public: JUCE_TRY { - filter = createPluginFilter(); + filter = createPluginFilterOfType (AudioProcessor::wrapperType_Standalone); } JUCE_CATCH_ALL @@ -77,8 +71,6 @@ public: JUCEApplication::quit(); } - filter->wrapperType = AudioProcessor::wrapperType_Standalone; - filter->setPlayConfigDetails (JucePlugin_MaxNumInputChannels, JucePlugin_MaxNumOutputChannels, 44100, 512); @@ -163,7 +155,7 @@ public: { deleteFilter(); - filter = createPluginFilter(); + filter = createPluginFilterOfType (AudioProcessor::wrapperType_Standalone); if (filter != nullptr) { diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp index 6f42ab8160..fbbc36027e 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -1450,13 +1450,6 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceVSTWrapper) }; -//============================================================================== -/** Somewhere in the codebase of your plugin, you need to implement this function - and make it create an instance of the filter subclass that you're building. -*/ -extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); - - //============================================================================== namespace { @@ -1473,17 +1466,9 @@ namespace MessageManagerLock mmLock; #endif - if (AudioProcessor* const filter = createPluginFilter()) - { - filter->wrapperType = AudioProcessor::wrapperType_VST; - - JuceVSTWrapper* const wrapper = new JuceVSTWrapper (audioMaster, filter); - return wrapper->getAeffect(); - } - else - { - jassertfalse; // your createPluginFilter() method must return an object! - } + AudioProcessor* const filter = createPluginFilterOfType (AudioProcessor::wrapperType_VST); + JuceVSTWrapper* const wrapper = new JuceVSTWrapper (audioMaster, filter); + return wrapper->getAeffect(); } } catch (...) diff --git a/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h b/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h index 9427662c4c..54b753d464 100644 --- a/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h +++ b/modules/juce_audio_plugin_client/utility/juce_IncludeModuleHeaders.h @@ -31,3 +31,5 @@ using namespace juce; #define Point juce::Point #define Component juce::Component #endif + +extern AudioProcessor* JUCE_CALLTYPE createPluginFilterOfType (AudioProcessor::WrapperType); diff --git a/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp b/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp index 73a74d1a46..b4f3aecea6 100644 --- a/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp +++ b/modules/juce_audio_plugin_client/utility/juce_PluginUtilities.cpp @@ -24,7 +24,8 @@ */ #if _MSC_VER -#include + #include +#endif // Your project must contain an AppConfig.h file with your project-specific settings in it, // and your header search path must make it accessible to the module's files. @@ -33,6 +34,8 @@ #include "../utility/juce_CheckSettingMacros.h" #include "juce_IncludeModuleHeaders.h" +#if _MSC_VER + #if JucePlugin_Build_RTAS extern "C" BOOL WINAPI DllMainRTAS (HINSTANCE, DWORD, LPVOID); #endif @@ -57,3 +60,21 @@ extern "C" BOOL WINAPI DllMain (HINSTANCE instance, DWORD reason, LPVOID reserve } #endif + +//============================================================================== +/** Somewhere in the codebase of your plugin, you need to implement this function + and make it return a new instance of the filter subclass that you're building. +*/ +extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); + +AudioProcessor* JUCE_CALLTYPE createPluginFilterOfType (AudioProcessor::WrapperType type) +{ + AudioProcessor::setTypeOfNextNewPlugin (type); + AudioProcessor* const pluginInstance = createPluginFilter(); + AudioProcessor::setTypeOfNextNewPlugin (AudioProcessor::wrapperType_Undefined); + + // your createPluginFilter() method must return an object! + jassert (pluginInstance != nullptr && pluginInstance->wrapperType == type); + + return pluginInstance; +} diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index 4957ad8c98..22392b0328 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -1573,7 +1573,7 @@ bool AudioUnitPluginFormat::fileMightContainThisPluginType (const String& fileOr if (AudioUnitFormatHelpers::getComponentDescFromIdentifier (fileOrIdentifier, desc, name, version, manufacturer)) return FindNextComponent (0, &desc) != 0; - const File f (fileOrIdentifier); + const File f (File::createFileWithoutCheckingPath (fileOrIdentifier)); return f.hasFileExtension (".component") && f.isDirectory(); diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp index e2611160b8..c21793a130 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp @@ -23,8 +23,15 @@ ============================================================================== */ +static ThreadLocalValue wrapperTypeBeingCreated; + +void AudioProcessor::setTypeOfNextNewPlugin (AudioProcessor::WrapperType type) +{ + wrapperTypeBeingCreated = type; +} + AudioProcessor::AudioProcessor() - : wrapperType (wrapperType_Undefined), + : wrapperType (wrapperTypeBeingCreated.get()), playHead (nullptr), sampleRate (0), blockSize (0), diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/modules/juce_audio_processors/processors/juce_AudioProcessor.h index 2a16f21dcc..22ff64e03e 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -592,6 +592,9 @@ public: */ WrapperType wrapperType; + /** @internal */ + static void setTypeOfNextNewPlugin (WrapperType); + protected: //============================================================================== /** Helper function that just converts an xml element into a binary blob.