From 5ef77d9bd9b102c76dbef24fbcd006c4534e9fc1 Mon Sep 17 00:00:00 2001
From: David Robillard
Date: Fri, 23 Mar 2012 01:26:47 +0000
Subject: Add worker extension to remove thread stuff from plugins.
---
lv2/lv2plug.in/ns/ext/atom/forge.h | 1 -
lv2/lv2plug.in/ns/ext/urid/urid.ttl | 4 +-
lv2/lv2plug.in/ns/ext/worker/ext.pc.in | 1 +
lv2/lv2plug.in/ns/ext/worker/manifest.ttl | 8 ++
lv2/lv2plug.in/ns/ext/worker/waf | 1 +
lv2/lv2plug.in/ns/ext/worker/worker.h | 138 ++++++++++++++++++++++++++++++
lv2/lv2plug.in/ns/ext/worker/worker.ttl | 58 +++++++++++++
lv2/lv2plug.in/ns/ext/worker/wscript | 1 +
8 files changed, 209 insertions(+), 3 deletions(-)
create mode 120000 lv2/lv2plug.in/ns/ext/worker/ext.pc.in
create mode 100644 lv2/lv2plug.in/ns/ext/worker/manifest.ttl
create mode 120000 lv2/lv2plug.in/ns/ext/worker/waf
create mode 100644 lv2/lv2plug.in/ns/ext/worker/worker.h
create mode 100644 lv2/lv2plug.in/ns/ext/worker/worker.ttl
create mode 120000 lv2/lv2plug.in/ns/ext/worker/wscript
(limited to 'lv2/lv2plug.in/ns/ext')
diff --git a/lv2/lv2plug.in/ns/ext/atom/forge.h b/lv2/lv2plug.in/ns/ext/atom/forge.h
index 322e14e..ea5977e 100644
--- a/lv2/lv2plug.in/ns/ext/atom/forge.h
+++ b/lv2/lv2plug.in/ns/ext/atom/forge.h
@@ -120,7 +120,6 @@ static inline void
lv2_atom_forge_init(LV2_Atom_Forge* forge, LV2_URID_Map* map)
{
lv2_atom_forge_set_buffer(forge, NULL, 0);
- forge->stack = NULL;
forge->Blank = map->map(map->handle, LV2_ATOM__Blank);
forge->Bool = map->map(map->handle, LV2_ATOM__Bool);
forge->Double = map->map(map->handle, LV2_ATOM__Double);
diff --git a/lv2/lv2plug.in/ns/ext/urid/urid.ttl b/lv2/lv2plug.in/ns/ext/urid/urid.ttl
index 121ffaf..d080107 100644
--- a/lv2/lv2plug.in/ns/ext/urid/urid.ttl
+++ b/lv2/lv2plug.in/ns/ext/urid/urid.ttl
@@ -68,7 +68,7 @@ urid:map
lv2:documentation """
A feature which is used to map URIs to integers. To support this feature,
the host must pass an LV2_Feature to LV2_Descriptor::instantiate() with URI
-LV2_URID_MAP_URI and data pointed to an instance of LV2_URID_Map.
+LV2_URID__map and data pointed to an instance of LV2_URID_Map.
""" .
urid:unmap
@@ -76,6 +76,6 @@ urid:unmap
lv2:documentation """
A feature which is used to unmap URIs previously mapped to integers by
urid:map. To support this feature, the host must pass an LV2_Feature to
-LV2_Descriptor::instantiate() with URI LV2_URID_UNMAP_URI and data pointed to
+LV2_Descriptor::instantiate() with URI LV2_URID__unmapl and data pointed to
an instance of LV2_URID_Unmap.
""" .
diff --git a/lv2/lv2plug.in/ns/ext/worker/ext.pc.in b/lv2/lv2plug.in/ns/ext/worker/ext.pc.in
new file mode 120000
index 0000000..03dd044
--- /dev/null
+++ b/lv2/lv2plug.in/ns/ext/worker/ext.pc.in
@@ -0,0 +1 @@
+../../../../../ext.pc.in
\ No newline at end of file
diff --git a/lv2/lv2plug.in/ns/ext/worker/manifest.ttl b/lv2/lv2plug.in/ns/ext/worker/manifest.ttl
new file mode 100644
index 0000000..af46f01
--- /dev/null
+++ b/lv2/lv2plug.in/ns/ext/worker/manifest.ttl
@@ -0,0 +1,8 @@
+@prefix lv2: .
+@prefix rdfs: .
+
+
+ a lv2:Specification ;
+ lv2:minorVersion 0 ;
+ lv2:microVersion 1 ;
+ rdfs:seeAlso .
diff --git a/lv2/lv2plug.in/ns/ext/worker/waf b/lv2/lv2plug.in/ns/ext/worker/waf
new file mode 120000
index 0000000..5235032
--- /dev/null
+++ b/lv2/lv2plug.in/ns/ext/worker/waf
@@ -0,0 +1 @@
+../../../../../waf
\ No newline at end of file
diff --git a/lv2/lv2plug.in/ns/ext/worker/worker.h b/lv2/lv2plug.in/ns/ext/worker/worker.h
new file mode 100644
index 0000000..612a24c
--- /dev/null
+++ b/lv2/lv2plug.in/ns/ext/worker/worker.h
@@ -0,0 +1,138 @@
+/*
+ Copyright 2012 David Robillard
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+/**
+ @file worker.h C header for the LV2 Worker extension
+ .
+*/
+
+#ifndef LV2_WORKER_H
+#define LV2_WORKER_H
+
+#include
+
+#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+
+#define LV2_WORKER_URI "http://lv2plug.in/ns/ext/worker"
+#define LV2_WORKER_PREFIX LV2_WORKER_URI "#"
+
+#define LV2_WORKER__Interface LV2_WORKER_PREFIX "Interface"
+#define LV2_WORKER__schedule LV2_WORKER_PREFIX "schedule"
+
+/**
+ A status code for worker functions.
+*/
+typedef enum {
+ LV2_WORKER_SUCCESS = 0, /**< Completed successfully. */
+ LV2_WORKER_ERR_UNKNOWN = 1, /**< Unknown error. */
+ LV2_WORKER_ERR_NO_SPACE = 2 /**< Failed due to lack of space. */
+} LV2_Worker_Status;
+
+typedef void* LV2_Worker_Respond_Handle;
+
+/**
+ A function to respond to run() from the worker method.
+
+ The @p data MUST be safe for the host to copy and later pass to
+ work_response(), and the host MUST guarantee that it will be eventually
+ passed to work_response() if this function returns LV2_WORKER_SUCCESS.
+*/
+typedef LV2_Worker_Status (*LV2_Worker_Respond_Function)(
+ LV2_Worker_Respond_Handle handle,
+ uint32_t size,
+ const void* data);
+
+/**
+ LV2 Plugin Worker Interface.
+
+ This is the interface provided by the plugin to implement a worker method.
+ The plugin's extension_data() method should return an LV2_Worker_Interface
+ when called with LV2_WORKER__Interface as its argument.
+*/
+typedef struct _LV2_Worker_Interface {
+ /**
+ The worker method. This is called by the host in a non-realtime context
+ as requested, possibly with an arbitrary message to handle.
+
+ A response can be sent to run() using @p respond. The plugin MUST NOT
+ make any assumptions about which thread calls this method, other than
+ the fact that there are no real-time requirements.
+
+ @param instance The LV2 instance this is a method on.
+ @param respond A function for sending a response to run().
+ @param handle Must be passed to @p respond if it is called.
+ @param size The size of @p data.
+ @param data Data from run(), or NULL.
+ */
+ LV2_Worker_Status (*work)(LV2_Handle instance,
+ LV2_Worker_Respond_Function respond,
+ LV2_Worker_Respond_Handle handle,
+ uint32_t size,
+ const void* data);
+
+ /**
+ Handle a response from the worker. This is called by the host in the
+ run() context when a response from the worker is ready.
+
+ @param instance The LV2 instance this is a method on.
+ @param size The size of @p body.
+ @param body Message body, or NULL.
+ */
+ LV2_Worker_Status (*work_response)(LV2_Handle instance,
+ uint32_t size,
+ const void* body);
+} LV2_Worker_Interface;
+
+typedef void* LV2_Worker_Schedule_Handle;
+
+typedef struct _LV2_Worker_Schedule {
+ /**
+ Opaque host data.
+ */
+ LV2_Worker_Schedule_Handle handle;
+
+ /**
+ Request from run() that the host call the worker.
+
+ This function is in the audio threading class. It should be called from
+ run() to request that the host call the work() method in a non-realtime
+ context with the given arguments.
+
+ This function is always safe to call from run(), but it is not
+ guaranteed that the worker is actually called from a different thread.
+ In particular, when free-wheeling (e.g. for offline rendering), the
+ worker may be executed immediately. This allows single-threaded
+ processing with sample accuracy and avoids timing problems when run() is
+ executing much faster or slower than real-time.
+
+ Plugins SHOULD be written in such a way that if the worker runs
+ immediately, and responses from the worker are delivered immediately,
+ the effect of the work takes place immediately with sample accuracy.
+
+ The @p data MUST be safe for the host to copy and later pass to work(),
+ and the host MUST guarantee that it will be eventually passed to work()
+ if this function returns LV2_WORKER_SUCCESS.
+
+ @param handle The handle field of this struct.
+ @param size The size of @p body.
+ @param data Message to pass to work(), or NULL.
+ */
+ LV2_Worker_Status (*schedule_work)(LV2_Worker_Schedule_Handle handle,
+ uint32_t size,
+ const void* data);
+} LV2_Worker_Schedule;
+
+#endif /* LV2_WORKER_H */
diff --git a/lv2/lv2plug.in/ns/ext/worker/worker.ttl b/lv2/lv2plug.in/ns/ext/worker/worker.ttl
new file mode 100644
index 0000000..ea49056
--- /dev/null
+++ b/lv2/lv2plug.in/ns/ext/worker/worker.ttl
@@ -0,0 +1,58 @@
+# LV2 Worker Extension
+# Copyright 2012 David Robillard
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+@prefix work: .
+@prefix lv2: .
+@prefix rdf: .
+@prefix rdfs: .
+@prefix xsd: .
+@prefix doap: .
+@prefix foaf: .
+
+
+ a lv2:Specification ,
+ lv2:Feature ;
+ doap:name "LV2 Worker" ;
+ doap:shortdesc "Support for a non-realtime plugin worker method." ;
+ lv2:documentation """
+""" .
+
+work:Interface
+ a rdfs:Class ;
+ rdfs:subClassOf lv2:ExtensionData ;
+ lv2:documentation """
+A structure (LV2_Worker_Interface) which contains the worker method to be
+called by the host. In order to support this extension, the plugin must return
+a valid LV2_Worker_Interface from LV2_Descriptor::extension_data() when it is
+called with URI LV2_WORKER__Interface.
+
+The plugin data file should describe this like so:
+
+@prefix work: <http://lv2plug.in/ns/ext/worker#> .
+
+<plugin>
+ a lv2:Plugin ;
+ lv2:extensionData work:Interface .
+
+""" .
+
+work:schedule
+ a lv2:Feature ;
+ lv2:documentation """
+A feature which provides functions for use by the plugin to implement a
+worker method. To support this feature, the host must pass an LV2_Feature to
+LV2_Descriptor::instantiate() with URI LV2_WORKER__schedule and data pointed to
+an instance of LV2_Worker_Schedule.
+""" .
diff --git a/lv2/lv2plug.in/ns/ext/worker/wscript b/lv2/lv2plug.in/ns/ext/worker/wscript
new file mode 120000
index 0000000..7e2c01b
--- /dev/null
+++ b/lv2/lv2plug.in/ns/ext/worker/wscript
@@ -0,0 +1 @@
+../../../../../ext.wscript
\ No newline at end of file
--
cgit v1.2.1