From 68a5c369d8844da98ac735f5158c2c66cd7f39ed Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 29 Feb 2012 03:16:10 +0000 Subject: Simplify atom:AtomPort buffers to point directly at Atoms. --- plugins/eg-sampler.lv2/sampler.c | 29 +++++++++++++++++------------ plugins/eg-sampler.lv2/uris.h | 2 ++ 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c index b7851cc..e141aeb 100644 --- a/plugins/eg-sampler.lv2/sampler.c +++ b/plugins/eg-sampler.lv2/sampler.c @@ -87,9 +87,9 @@ typedef struct { Sample* sample; /* Ports */ - float* output_port; - LV2_Atom_Port_Buffer* control_port; - LV2_Atom_Port_Buffer* notify_port; + float* output_port; + LV2_Atom_Sequence* control_port; + LV2_Atom_Sequence* notify_port; /* URIs */ SamplerURIs uris; @@ -218,10 +218,10 @@ connect_port(LV2_Handle instance, switch (port) { case SAMPLER_CONTROL: - plugin->control_port = (LV2_Atom_Port_Buffer*)data; + plugin->control_port = (LV2_Atom_Sequence*)data; break; case SAMPLER_RESPONSE: - plugin->notify_port = (LV2_Atom_Port_Buffer*)data; + plugin->notify_port = (LV2_Atom_Sequence*)data; break; case SAMPLER_OUT: plugin->output_port = (float*)data; @@ -329,7 +329,7 @@ run(LV2_Handle instance, float* output = plugin->output_port; /* Read incoming events */ - LV2_SEQUENCE_FOREACH((LV2_Atom_Sequence*)plugin->control_port->data, i) { + LV2_SEQUENCE_FOREACH(plugin->control_port, i) { LV2_Atom_Event* const ev = lv2_sequence_iter_get(i); if (ev->body.type == uris->midi_Event) { uint8_t* const data = (uint8_t* const)(ev + 1); @@ -382,13 +382,18 @@ run(LV2_Handle instance, } /* Set up forge to write directly to notify output port buffer */ - LV2_Atom* seq = plugin->notify_port->data; + const uint32_t notify_capacity = plugin->notify_port->atom.size; + + LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)plugin->notify_port; + seq->atom.type = uris->atom_Sequence; + seq->atom.size = seq->body.unit = seq->body.pad = 0; + + lv2_atom_forge_set_buffer(&plugin->forge, + LV2_ATOM_CONTENTS(LV2_Atom_Sequence, seq), + notify_capacity); + LV2_Atom_Forge_Frame seq_frame; - lv2_atom_forge_push(&plugin->forge, &seq_frame, seq); - lv2_atom_forge_set_buffer( - &plugin->forge, - LV2_ATOM_CONTENTS(LV2_Atom_Sequence, seq), - plugin->notify_port->capacity); + lv2_atom_forge_push(&plugin->forge, &seq_frame, &seq->atom); /* Read messages from worker thread */ SampleMessage m; diff --git a/plugins/eg-sampler.lv2/uris.h b/plugins/eg-sampler.lv2/uris.h index 8d0a983..cec1700 100644 --- a/plugins/eg-sampler.lv2/uris.h +++ b/plugins/eg-sampler.lv2/uris.h @@ -31,6 +31,7 @@ typedef struct { LV2_URID atom_Blank; LV2_URID atom_Path; LV2_URID atom_Resource; + LV2_URID atom_Sequence; LV2_URID atom_eventTransfer; LV2_URID eg_applySample; LV2_URID eg_file; @@ -46,6 +47,7 @@ map_sampler_uris(LV2_URID_Map* map, SamplerURIs* uris) uris->atom_Blank = map->map(map->handle, LV2_ATOM__Blank); uris->atom_Path = map->map(map->handle, LV2_ATOM__Path); uris->atom_Resource = map->map(map->handle, LV2_ATOM__Resource); + uris->atom_Sequence = map->map(map->handle, LV2_ATOM__Sequence); uris->atom_eventTransfer = map->map(map->handle, LV2_ATOM__eventTransfer); uris->eg_applySample = map->map(map->handle, EG_SAMPLER__applySample); uris->eg_file = map->map(map->handle, EG_SAMPLER__file); -- cgit v1.2.1