aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2016-11-22 12:08:30 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2016-11-22 12:08:30 +0100
commit1c72b1fba8492e27d0d6d52b24ecf7f22c3b6851 (patch)
tree809088db215c59c036a7490afecdebbc9644ccf2 /include
parentdeb9eb603ff505390cada7152999d52cd4c0d56f (diff)
downloadsynthpod-1c72b1fba8492e27d0d6d52b24ecf7f22c3b6851.tar.xz
streamline appending of atom events.
Diffstat (limited to 'include')
-rw-r--r--include/synthpod_private.h25
1 files changed, 12 insertions, 13 deletions
diff --git a/include/synthpod_private.h b/include/synthpod_private.h
index 9657b39a..6a08782c 100644
--- a/include/synthpod_private.h
+++ b/include/synthpod_private.h
@@ -1870,23 +1870,22 @@ _preset_reload(LilvWorld *world, reg_t *regs, const LilvPlugin *plugin,
return presets;
}
-static inline LV2_Atom_Forge_Ref
-_lv2_atom_forge_sequence_append(LV2_Atom_Forge *forge, LV2_Atom_Forge_Frame *frame,
- uint8_t *buf, uint32_t size)
+static inline LV2_Atom_Event*
+_lv2_atom_sequence_append_atom(LV2_Atom_Sequence *seq, uint32_t capacity,
+ int64_t frames, const LV2_Atom *atom)
{
- assert(buf);
- buf = ASSUME_ALIGNED(buf);
- assert(buf);
- LV2_Atom_Sequence *seq = (LV2_Atom_Sequence *)buf;
+ const uint32_t total_size = sizeof(LV2_Atom_Event) + atom->size;
- lv2_atom_forge_set_buffer(forge, buf, size);
- LV2_Atom_Forge_Ref ref = (LV2_Atom_Forge_Ref)&seq->atom;
- ref = lv2_atom_forge_push(forge, frame, ref);
- forge->offset = sizeof(LV2_Atom) + lv2_atom_pad_size(seq->atom.size); //TODO test
+ if(capacity - seq->atom.size < total_size)
+ return NULL;
- //printf("_lv2_atom_forge_sequence_append: %u\n", forge->offset);
+ LV2_Atom_Event* ev = lv2_atom_sequence_end(&seq->body, seq->atom.size);
+ ev->time.frames = frames;
+ memcpy(&ev->body, atom, lv2_atom_total_size(atom));
- return ref;
+ seq->atom.size += lv2_atom_pad_size(total_size);
+
+ return ev;
}
static inline int