contexts
type: Specification
type: Feature
name: LV2 Contexts
documentation: An extension for LV2 plugins which have several execution contexts. Contexts allow plugins to run tasks and/or process 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. A context is an LV2 feature, so the usual LV2 feature mechanism is used to determine whether a plugin has a given context, and whether or not it is mandatory. 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.

LV2 Context
type: Class
documentation: 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.

AudioContext
type: LV2 Context
type: Feature
comment: The context of LV2_Descriptor.run().

MessageContext
type: LV2 Context
type: Feature
documentation: 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_Contexts_MessageContext).

IdleContext
type: LV2 Context
type: Feature
comment: A non-realtime idle context, periodically run by the host roughly every second. This context never has any ports.

RequestRunFeature
type: Feature
documentation: A feature allowing the plugin to request the execution of a particular context at an arbitrary time. To support this feature, the host MUST pass an LV2_Feature to instantiate with data pointing to a LV2_Contexts_Request_Run_Feature. The plugin MAY call request_run with the given data from any non-realtime context to demand soon-as-possible execution of the specified context.

is used in context
type: Property
domain: Port
range: LV2 Context
comment: 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.