diff options
author | David Robillard <d@drobilla.net> | 2024-11-16 14:59:31 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-11-24 19:03:19 -0500 |
commit | 25593e614eb3ef6a62a603aa4704d9a4ff49364d (patch) | |
tree | 78140112afa4d764aaeb687104b36fdbc688e0ac | |
parent | 23c175f6b91cfe1a21c7218b27901a600aa5af86 (diff) | |
download | jalv-25593e614eb3ef6a62a603aa4704d9a4ff49364d.tar.gz jalv-25593e614eb3ef6a62a603aa4704d9a4ff49364d.tar.bz2 jalv-25593e614eb3ef6a62a603aa4704d9a4ff49364d.zip |
Factor out jalv_write_get_message() from process callbacks
-rw-r--r-- | src/jack.c | 6 | ||||
-rw-r--r-- | src/portaudio.c | 7 | ||||
-rw-r--r-- | src/process.c | 13 | ||||
-rw-r--r-- | src/process.h | 11 |
4 files changed, 26 insertions, 11 deletions
@@ -182,11 +182,7 @@ jack_process_cb(jack_nframes_t nframes, void* data) if (jalv->request_update) { // Plugin state has changed, request an update - const LV2_Atom_Object get = { - {sizeof(LV2_Atom_Object_Body), jalv->urids.atom_Object}, - {0, jalv->urids.patch_Get}}; - lv2_evbuf_write( - &iter, 0, 0, get.atom.type, get.atom.size, LV2_ATOM_BODY_CONST(&get)); + jalv_write_get_message(&iter, &jalv->urids); } if (port->sys_port) { diff --git a/src/portaudio.c b/src/portaudio.c index 869385c..d509d04 100644 --- a/src/portaudio.c +++ b/src/portaudio.c @@ -11,7 +11,6 @@ #include "types.h" #include "lilv/lilv.h" -#include "lv2/atom/atom.h" #include "zix/attributes.h" #include <portaudio.h> @@ -55,12 +54,8 @@ pa_process_cb(const void* inputs, if (jalv->request_update) { // Plugin state has changed, request an update - const LV2_Atom_Object get = { - {sizeof(LV2_Atom_Object_Body), jalv->urids.atom_Object}, - {0, jalv->urids.patch_Get}}; LV2_Evbuf_Iterator iter = lv2_evbuf_begin(port->evbuf); - lv2_evbuf_write( - &iter, 0, 0, get.atom.type, get.atom.size, LV2_ATOM_BODY(&get)); + jalv_write_get_message(&iter, &jalv->urids); } } else if (port->type == TYPE_EVENT) { // Clear event output for plugin to write to diff --git a/src/process.c b/src/process.c index d069851..2b5a11e 100644 --- a/src/process.c +++ b/src/process.c @@ -18,6 +18,19 @@ #include <assert.h> #include <stddef.h> +int +jalv_write_get_message(LV2_Evbuf_Iterator* const iter, + const JalvURIDs* const urids) +{ + const LV2_Atom_Object get = { + {sizeof(LV2_Atom_Object_Body), urids->atom_Object}, + {0U, urids->patch_Get}, + }; + + return lv2_evbuf_write( + iter, 0, 0, get.atom.type, get.atom.size, LV2_ATOM_BODY_CONST(&get)); +} + static int ring_error(const char* const message) { diff --git a/src/process.h b/src/process.h index 366d30e..35acd24 100644 --- a/src/process.h +++ b/src/process.h @@ -5,7 +5,9 @@ #define JALV_PROCESS_H #include "attributes.h" +#include "lv2_evbuf.h" #include "types.h" +#include "urids.h" #include <stdbool.h> #include <stdint.h> @@ -15,6 +17,15 @@ JALV_BEGIN_DECLS // Code and data used in the realtime process thread /** + Write a patch:Get message to an event buffer. + + This is used to request an update of plugin state when it has changed or the + UI needs updating for whatever reason. +*/ +int +jalv_write_get_message(LV2_Evbuf_Iterator* iter, const JalvURIDs* urids); + +/** Run the plugin for a block of frames. Applies any pending messages from the UI, runs the plugin instance, and |