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

VSTPluginFormat: internal refactoring, and some new accessor methods.

This commit is contained in:
jules 2012-10-19 09:47:28 +01:00
parent a1614a8879
commit 02f5a1f876
4 changed files with 1212 additions and 1272 deletions

View file

@ -1484,7 +1484,7 @@ void AudioUnitPluginFormat::findAllTypesForFile (OwnedArray <PluginDescription>&
{
ScopedPointer <AudioPluginInstance> createdInstance (createInstanceFromDescription (desc));
if (AudioUnitPluginInstance* const auInstance = dynamic_cast <AudioUnitPluginInstance*> ((AudioPluginInstance*) createdInstance))
if (AudioUnitPluginInstance* const auInstance = dynamic_cast <AudioUnitPluginInstance*> (createdInstance.get()))
{
auInstance->fillInPluginDescription (desc);
results.add (new PluginDescription (desc));

View file

@ -41,11 +41,45 @@ public:
VSTPluginFormat();
~VSTPluginFormat();
//==============================================================================
/** Attempts to retreive the VSTXML data from a plugin.
Will return nullptr if the plugin isn't a VST, or if it doesn't have any VSTXML.
*/
static const XmlElement* getVSTXML (AudioPluginInstance* plugin);
/** Attempts to reload a VST plugin's state from some FXB or FXP data. */
static bool loadFromFXBFile (AudioPluginInstance* plugin, const void* data, size_t dataSize);
/** Attempts to save a VST's state to some FXP or FXB data. */
static bool saveToFXBFile (AudioPluginInstance* plugin, MemoryBlock& result, bool asFXB);
/** Attempts to get a VST's state as a chunk of memory. */
static bool getChunkData (AudioPluginInstance* plugin, MemoryBlock& result, bool isPreset);
/** Attempts to set a VST's state from a chunk of memory. */
static bool setChunkData (AudioPluginInstance* plugin, const void* data, int size, bool isPreset);
//==============================================================================
/** Base class for some extra functions that can be attached to a VST plugin instance. */
class ExtraFunctions
{
public:
virtual ~ExtraFunctions() {}
/** This should return 10000 * the BPM at this position in the current edit. */
virtual int64 getTempoAt (int64 samplePos) = 0;
/** This should return the host's automation state.
@returns 0 = not supported, 1 = off, 2 = read, 3 = write, 4 = read/write
*/
virtual int getAutomationState() = 0;
};
/** Provides an ExtraFunctions callback object for a plugin to use.
The plugin will take ownership of the object and will delete it automatically.
*/
static void setExtraFunctions (AudioPluginInstance* plugin, ExtraFunctions* functions);
//==============================================================================
String getName() const { return "VST"; }
void findAllTypesForFile (OwnedArray <PluginDescription>&, const String& fileOrIdentifier);
@ -58,8 +92,7 @@ public:
bool canScanForPlugins() const { return true; }
private:
//==============================================================================
void recursiveFileSearch (StringArray& results, const File& dir, const bool recursive);
void recursiveFileSearch (StringArray&, const File&, bool recursive);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VSTPluginFormat);
};

View file

@ -201,18 +201,9 @@ private:
void addTimer (Timer* const t) noexcept
{
#if JUCE_DEBUG
Timer* tt = firstTimer;
while (tt != nullptr)
{
// trying to add a timer that's already here - shouldn't get to this point,
// so if you get this assertion, let me know!
jassert (tt != t);
tt = tt->next;
}
jassert (t->previous == nullptr && t->next == nullptr);
// trying to add a timer that's already here - shouldn't get to this point,
// so if you get this assertion, let me know!
jassert (! timerExists (t));
#endif
Timer* i = firstTimer;
@ -246,23 +237,9 @@ private:
void removeTimer (Timer* const t) noexcept
{
#if JUCE_DEBUG
Timer* tt = firstTimer;
bool found = false;
while (tt != nullptr)
{
if (tt == t)
{
found = true;
break;
}
tt = tt->next;
}
// trying to remove a timer that's not here - shouldn't get to this point,
// so if you get this assertion, let me know!
jassert (found);
jassert (timerExists (t));
#endif
if (t->previous != nullptr)
@ -298,6 +275,17 @@ private:
startThread (7);
}
#if JUCE_DEBUG
bool timerExists (Timer* const t) const noexcept
{
for (Timer* tt = firstTimer; tt != nullptr; tt = tt->next)
if (tt == t)
return true;
return false;
}
#endif
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TimerThread);
};