# LV2 Contexts Extension # # Allows for an LV2 plugin to have several independent contexts, each with its # own run callback and associated ports. # # Copyright (C) 2007-2010 David Robillard # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. @prefix ctx: . @prefix lv2: . @prefix rdf: . @prefix rdfs: . @prefix xsd: . @prefix doap: . @prefix foaf: . a lv2:Specification ; a lv2:Feature ; doap:name "LV2 Contexts" ; rdfs:comment """ 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. """^^lv2:basicXHTML . ########################## ## Context Base Classes ## ########################## ctx:Context a rdfs:Class ; rdfs:label "LV2 Context" ; rdfs:comment """ 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. """ . ctx:AudioContext a ctx:Context , lv2:Feature ; rdfs:comment """The context of LV2_Descriptor.run().""" . ctx:MessageContext a ctx:Context , lv2:Feature ; rdfs:comment """ 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). """ . ctx:IdleContext a ctx:Context , lv2:Feature ; rdfs:comment """ A non-realtime idle context, periodically run by the host roughly every second. """ . ctx:context a rdf:Property ; rdfs:domain lv2:Port ; rdfs:range ctx:Context ; rdfs:label "is used in context" ; rdfs: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.""" .