diff options
author | David Robillard <d@drobilla.net> | 2022-08-08 18:38:36 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-17 13:50:49 -0400 |
commit | 9ca96aaa57bf101d7b92f3250bac56e356361030 (patch) | |
tree | b35bf631444eb3be2653c6902a0ce361183cc300 | |
parent | 147d8d8ae845f0c1ae4f2ad97b6e2f48228d97b7 (diff) | |
download | jalv-9ca96aaa57bf101d7b92f3250bac56e356361030.tar.gz jalv-9ca96aaa57bf101d7b92f3250bac56e356361030.tar.bz2 jalv-9ca96aaa57bf101d7b92f3250bac56e356361030.zip |
Simplify atom buffer allocation code
-rw-r--r-- | src/jalv.c | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -263,25 +263,24 @@ jalv_create_ports(Jalv* jalv) void jalv_allocate_port_buffers(Jalv* jalv) { + const LV2_URID atom_Chunk = jalv->map.map( + jalv->map.handle, lilv_node_as_string(jalv->nodes.atom_Chunk)); + + const LV2_URID atom_Sequence = jalv->map.map( + jalv->map.handle, lilv_node_as_string(jalv->nodes.atom_Sequence)); + for (uint32_t i = 0; i < jalv->num_ports; ++i) { struct Port* const port = &jalv->ports[i]; - switch (port->type) { - case TYPE_EVENT: { + if (port->type == TYPE_EVENT) { lv2_evbuf_free(port->evbuf); - const size_t buf_size = - (port->buf_size > 0) ? port->buf_size : jalv->midi_buf_size; - port->evbuf = lv2_evbuf_new( - buf_size, - jalv->map.map(jalv->map.handle, - lilv_node_as_string(jalv->nodes.atom_Chunk)), - jalv->map.map(jalv->map.handle, - lilv_node_as_string(jalv->nodes.atom_Sequence))); + + const size_t size = port->buf_size ? port->buf_size : jalv->midi_buf_size; + + port->evbuf = lv2_evbuf_new(size, atom_Chunk, atom_Sequence); + lilv_instance_connect_port( jalv->instance, i, lv2_evbuf_get_buffer(port->evbuf)); } - default: - break; - } } } |