aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-19 08:41:18 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-19 08:41:18 +0100
commite8299357c6734a7d44f43384d7e59643e2e2764a (patch)
tree1bcd216facf73f99b81c754d9adb6c0d5cdf4e37
parent914a279624f7252b5981c988f583d17d119c0918 (diff)
downloadprops.lv2-e8299357c6734a7d44f43384d7e59643e2e2764a.tar.xz
add magic header to check for props worker jobs.
-rw-r--r--props.h31
-rw-r--r--test/props.c2
-rw-r--r--test/props.ttl5
3 files changed, 32 insertions, 6 deletions
diff --git a/props.h b/props.h
index 312e98d..35081eb 100644
--- a/props.h
+++ b/props.h
@@ -46,6 +46,7 @@ typedef struct _props_def_t props_def_t;
typedef struct _props_impl_t props_impl_t;
typedef struct _props_work_t props_work_t;
typedef struct _props_t props_t;
+typedef union _props_magic_t props_magic_t;
// function callbacks
typedef void (*props_event_cb_t)(
@@ -101,7 +102,13 @@ struct _props_impl_t {
bool stashing;
};
+union _props_magic_t {
+ uint8_t u64;
+ uint8_t u8 [8];
+};
+
struct _props_work_t {
+ props_magic_t magic;
LV2_URID property;
LV2_URID size;
LV2_URID type;
@@ -212,6 +219,10 @@ props_work_response(props_t *props, uint32_t size, const void *body);
* API END
*****************************************************************************/
+static const props_magic_t props_magic = {
+ .u8 = {'p', 'r', 'o', 'p', 's', 'l', 'v', '2'}
+};
+
static inline void
_impl_spin_lock(props_impl_t *impl)
{
@@ -889,6 +900,7 @@ _props_schedule(const LV2_Worker_Schedule *work_sched, LV2_URID property,
props_work_t *job = malloc(sz);
if(job)
{
+ job->magic = props_magic;
job->property = property;
job->type = type;
job->size = size;
@@ -980,14 +992,25 @@ static inline LV2_Worker_Status
props_work(props_t *props, LV2_Worker_Respond_Function respond,
LV2_Worker_Respond_Handle worker, uint32_t size, const void *body)
{
- return respond(worker, size, body);
+ const props_work_t *job = body;
+
+ if(job && (job->magic.u64 == props_magic.u64) )
+ {
+ const LV2_Worker_Status stat = respond(worker, size, body);
+ (void)stat;
+
+ return LV2_WORKER_SUCCESS;
+ }
+
+ return LV2_WORKER_ERR_UNKNOWN;
}
static inline LV2_Worker_Status
props_work_response(props_t *props, uint32_t size, const void *body)
{
const props_work_t *job = body;
- if(job)
+
+ if(job && (job->magic.u64 == props_magic.u64) )
{
props_impl_t *impl = _props_impl_search(props, job->property);
if(impl)
@@ -998,9 +1021,11 @@ props_work_response(props_t *props, uint32_t size, const void *body)
if(def->event_cb && (def->event_mask & PROP_EVENT_RESTORE) )
def->event_cb(props->data, NULL, 0, PROP_EVENT_RESTORE, impl);
}
+
+ return LV2_WORKER_SUCCESS;
}
- return LV2_WORKER_SUCCESS;
+ return LV2_WORKER_ERR_UNKNOWN;
}
#ifdef __cplusplus
diff --git a/test/props.c b/test/props.c
index e4b27d8..a34d2b7 100644
--- a/test/props.c
+++ b/test/props.c
@@ -374,7 +374,7 @@ _work_response(LV2_Handle instance, uint32_t size, const void *body)
return props_work_response(&handle->props, size, body);
}
-LV2_Worker_Interface work_iface = {
+static const LV2_Worker_Interface work_iface = {
.work = _work,
.work_response = _work_response,
.end_run = NULL
diff --git a/test/props.ttl b/test/props.ttl
index 3f6b188..68d6b43 100644
--- a/test/props.ttl
+++ b/test/props.ttl
@@ -24,6 +24,7 @@
@prefix state: <http://lv2plug.in/ns/ext/state#> .
@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
@prefix log: <http://lv2plug.in/ns/ext/log#> .
+@prefix work: <http://lv2plug.in/ns/ext/worker#> .
@prefix units: <http://lv2plug.in/ns/extensions/units#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@@ -106,9 +107,9 @@ props:test
doap:name "Props Test" ;
doap:license lic:Artistic-2.0 ;
lv2:project proj:props ;
- lv2:extensionData state:interface ;
- lv2:requiredFeature urid:map, log:log, state:loadDefaultState ;
+ lv2:requiredFeature urid:map, log:log, state:loadDefaultState, work:schedule ;
lv2:optionalFeature lv2:isLive, lv2:hardRTCapable, state:threadSafeRestore ;
+ lv2:extensionData state:interface, work:interface ;
lv2:port [
# sink event port