An extension for LV2 plugins which have several execution contexts. Contexts allow plugins to run several tasks in parallel and process port input/output in multiple threads. Contexts can be used to add non-realtime functionality to a plugin while still keeping the audio run() method realtime safe. Any host which supports this extension must pass an LV2_Feature to the plugin's instantiate method with URI http://lv2plug.in/ns/ext/contexts and a pointer to a struct { void* host_handle; void (*request_run)(void* host_handle, const char* context_uri); } where the plugin may call request_run with the given host_handle (from any context) to demand immediate execution of the context specified. If the host does not support blocking contexts, request_run may be set to NULL, but plugins which have a :BlockingContext which is :mandatory MUST NOT be instantiated. If the plugin has ANY context which is :hardRTCapable, request_run must be realtime safe (as defined by lv2:hardRTCapable). Unless otherwise stated, each context (defined by some URI) adds a new threading class similar to the Audio class defined by LV2. Each context has a run callback and a connect_port callback both in the same class (i.e. can't be called concurrently), but may be called concurrently with functions for other contexts (excluding the Instantiation class). Context properties such as ctx:hardRTCapable apply to both functions. The host MUST only call the correct connect_port function associated with the context for that port, i.e. it is an error to use the main LV2 connect_port function on a port with a context other than the main LV2 run function.
A potentially concurrent context (callback) on a plugin. Ports are always associated with a context. If a port has no explicit context property, then its context is ctx:AudioContext (the default LV2 run() context). A plugin indicates support for a context by supporting an LV2 Feature with that context's URI. If a plugin optionally supports a context (e.g. <plugin> lv2:optionalFeature ctx:IdleContext .), then all ports associated with that context MUST be lv2:connectionOptional. Thus, hosts that do not support contexts will connect such ports to NULL and the plugin can run with only a standard LV2 run() context. Any plugin that supports any context (optionally or mandatorily) MUST adhere to the following additional threading rules for LV2_Descriptor.connect_port: connect_port MUST only be called for a given port from the context associated with that port connect_port MAY be called concurrently for ports with different contexts (but MUST NOT be called concurrently for multiple ports in the same context) Note this implies that any shared data access in connect_port may be accessed concurrently. The plugin is responsible for any synchronisation or locking necessary to make this possible.
A non-realtime context for plugin control via message passing. This context has a run method which takes a bitset of flags for parameters specifying which input and output ports are valid before and after the run method has executed, respectively (see LV2_Context_MessageContext).
A non-realtime idle context, periodically run by the host roughly every second.
The context a particular port is associated with; the port will only be connected/read/written by that context. If no context is specified, the port is considered part of the default LV2 audio context.