aboutsummaryrefslogtreecommitdiff
path: root/atom_inspector.c
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2016-04-05 17:13:34 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2016-04-05 17:13:34 +0200
commitbfbbc743fb933409a3ead2af8c744b30c694dc86 (patch)
tree51321e28fdbade33fdcab1f5e7002fa5a306eb32 /atom_inspector.c
parentb33ed708ac837a25f25ec4d5e1425e39333b6f29 (diff)
downloadsherlock.lv2-bfbbc743fb933409a3ead2af8c744b30c694dc86.tar.xz
sync frame counter to time source.
Diffstat (limited to 'atom_inspector.c')
-rw-r--r--atom_inspector.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/atom_inspector.c b/atom_inspector.c
index 0bfedba..227e847 100644
--- a/atom_inspector.c
+++ b/atom_inspector.c
@@ -29,7 +29,10 @@ struct _handle_t {
LV2_Atom_Sequence *notify;
LV2_Atom_Forge forge;
- uint64_t offset;
+ LV2_URID time_position;
+ LV2_URID time_frame;
+
+ int64_t frame;
};
static LV2_Handle
@@ -52,6 +55,9 @@ instantiate(const LV2_Descriptor* descriptor, double rate,
return NULL;
}
+ handle->time_position = handle->map->map(handle->map->handle, LV2_TIME__Position);
+ handle->time_frame = handle->map->map(handle->map->handle, LV2_TIME__frame);
+
lv2_atom_forge_init(&handle->forge, handle->map);
return handle;
@@ -87,6 +93,22 @@ run(LV2_Handle instance, uint32_t nsamples)
LV2_Atom_Forge_Frame frame;
LV2_Atom_Forge_Ref ref;
+ LV2_ATOM_SEQUENCE_FOREACH(handle->control_in, ev)
+ {
+ const LV2_Atom_Object *obj = (const LV2_Atom_Object *)&ev->body;
+
+ if(lv2_atom_forge_is_object_type(forge, obj->atom.type))
+ {
+ if(obj->body.otype == handle->time_position)
+ {
+ const LV2_Atom_Long *time_frame = NULL;
+ lv2_atom_object_get(obj, handle->time_frame, &time_frame, NULL);
+ if(time_frame)
+ handle->frame = time_frame->body - ev->time.frames;
+ }
+ }
+ }
+
// size of input sequence
size_t size = sizeof(LV2_Atom) + handle->control_in->atom.size;
@@ -114,7 +136,7 @@ run(LV2_Handle instance, uint32_t nsamples)
if(ref)
ref = lv2_atom_forge_tuple(forge, &tup_frame);
if(ref)
- ref = lv2_atom_forge_long(forge, handle->offset);
+ ref = lv2_atom_forge_long(forge, handle->frame);
if(ref)
ref = lv2_atom_forge_int(forge, nsamples);
if(ref)
@@ -131,7 +153,7 @@ run(LV2_Handle instance, uint32_t nsamples)
else
lv2_atom_sequence_clear(handle->notify);
- handle->offset += nsamples;
+ handle->frame += nsamples;
}
static void