Startup SequenceVST.NET "starts" when the Host calls the exported VSTPluginMain function. Inside the main the following happens
- A HostCommandStub is created on the callback function pointer passed in by the Host.
- A ManagedPluginFactory instance is created based on the name of the executing assembly (which is the renamed Interop assembly).
- The ManagedPluginFactory is asked to create a PluginCommandStub instance. Inside the ManagedPluginFactory:
- The managed plugin assembly is loaded based on the naming convention (.net postfix).
- All public types inside the assembly are checked for the IVstPluginCommandStub interface.
- An instance is created of the first type that implements this interface (otherwise an exception is thrown).
- The PluginCommandStub is called to create the VstPluginInfo the defines the managed Plugin. Inside the StdPluginCommandStub (in Framework):
- A PluginContext instance is created.
- A VstHost instance is created that takes the reference of the HostCommandStub that was passed as a method parameter and stored in the PluginContext
- The CreatePluginInstance abstract method is called, the derived class now creates an instance of its Plugin and returns the IVstPlugin interface.
- The reference to the Plugin (IVstPlugin) is stored in the PluginContext.
- Then the Plugin is queried for its supported interfaces (and the Capabilities property is read) to fill the VstPluginInfo properties.
- The filled VstPluginInfo is stored in the PluginContext and returned (back to VstPluginMain).
- Based on the returned VstPluginInfo the AEffect struct is created and filled. The function pointers to the plugin callback functions provided by the Interop assembly are assigned.
- The AEffect instance is used to initialize the HostCommandStub and returned from the VstPluginMain exported function.
- If an exception occurs it is shown in a message box and the HostCommandStub is disposed.
Teardown sequenceShutting down the plugin and cleaning up resources starts when the Host calls the Close 'method' through the dispatcher callback function.
- The PluginCommandProxy (in Interop) receives the Close opcode from the Host (no parameters).
- The PluginCommandProxy calls the PluginCommandStub's (created in startup sequence) Close method. Inside the StdPluginCommandStub (in Framework):
- The StdPluginCommandStub calls Dispose on the VstHost instance (via PluginContext).
- The VstHost calls Dispose on the IVstHostCommandStub reference it owns.
- The HostCommandStub deletes the allocated AEffect struct.
- StdPluginCommandStub calls Dispose on the IVstPlugin instance (via PluginContext) and the Plugin implementation now performs a complete cleanup.
- The PluginCommandProxy performs its own cleanup and is elligable for garbage collection.