From a584a1f33002f9fefda29842f0ec5f58316252af Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 15 Nov 2024 11:56:18 -0500 Subject: Avoid querying the lilv model in the process callback --- src/jack.c | 3 +-- src/jalv.c | 8 ++++++++ src/port.h | 19 ++++++++++--------- 3 files changed, 19 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/jack.c b/src/jack.c index fd7a6f1..7971987 100644 --- a/src/jack.c +++ b/src/jack.c @@ -202,8 +202,7 @@ jack_process_cb(jack_nframes_t nframes, void* data) for (uint32_t p = 0; p < jalv->num_ports; ++p) { struct Port* const port = &jalv->ports[p]; if (port->flow == FLOW_OUTPUT && port->type == TYPE_CONTROL && - lilv_port_has_property( - jalv->plugin, port->lilv_port, jalv->nodes.lv2_reportsLatency)) { + port->reports_latency) { if (jalv->plugin_latency != port->control) { jalv->plugin_latency = port->control; jack_recompute_total_latencies(client); diff --git a/src/jalv.c b/src/jalv.c index bb40963..23a3698 100644 --- a/src/jalv.c +++ b/src/jalv.c @@ -210,6 +210,7 @@ create_port(Jalv* jalv, uint32_t port_index, float default_value) die("Mandatory port has unknown data type"); } + // Set buffer size LilvNode* min_size = lilv_port_get(jalv->plugin, port->lilv_port, jalv->nodes.rsz_minimumSize); if (min_size && lilv_node_is_int(min_size)) { @@ -218,6 +219,13 @@ create_port(Jalv* jalv, uint32_t port_index, float default_value) MAX(jalv->opts.buffer_size, port->buf_size * N_BUFFER_CYCLES); } lilv_node_free(min_size); + + // Set reports_latency flag + if (port->flow == FLOW_OUTPUT && port->type == TYPE_CONTROL && + lilv_port_has_property( + jalv->plugin, port->lilv_port, jalv->nodes.lv2_reportsLatency)) { + port->reports_latency = true; + } } /// Create port structures from data (via create_port()) for all ports diff --git a/src/port.h b/src/port.h index 5b3e0c9..7ca80b1 100644 --- a/src/port.h +++ b/src/port.h @@ -19,15 +19,16 @@ enum PortFlow { FLOW_UNKNOWN, FLOW_INPUT, FLOW_OUTPUT }; enum PortType { TYPE_UNKNOWN, TYPE_CONTROL, TYPE_AUDIO, TYPE_EVENT, TYPE_CV }; struct Port { - const LilvPort* lilv_port; ///< LV2 port - enum PortType type; ///< Data type - enum PortFlow flow; ///< Data flow direction - void* sys_port; ///< For audio/MIDI ports, otherwise NULL - LV2_Evbuf* evbuf; ///< For MIDI ports, otherwise NULL - void* widget; ///< Control widget, if applicable - size_t buf_size; ///< Custom buffer size, or 0 - uint32_t index; ///< Port index - float control; ///< For control ports, otherwise 0.0f + const LilvPort* lilv_port; ///< LV2 port + enum PortType type; ///< Data type + enum PortFlow flow; ///< Data flow direction + void* sys_port; ///< For audio/MIDI ports, otherwise NULL + LV2_Evbuf* evbuf; ///< For MIDI ports, otherwise NULL + void* widget; ///< Control widget, if applicable + size_t buf_size; ///< Custom buffer size, or 0 + uint32_t index; ///< Port index + float control; ///< For control ports, otherwise 0.0f + bool reports_latency; ///< For control port outputs }; JALV_END_DECLS -- cgit v1.2.1