aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-11-16 15:10:02 -0500
committerDavid Robillard <d@drobilla.net>2024-11-24 19:03:26 -0500
commit22c37a1bbd0c8473e36d4638770ee79a19792038 (patch)
tree93a9387ceef1df01dede63986abc44d6e988347e
parent25593e614eb3ef6a62a603aa4704d9a4ff49364d (diff)
downloadjalv-22c37a1bbd0c8473e36d4638770ee79a19792038.tar.gz
jalv-22c37a1bbd0c8473e36d4638770ee79a19792038.tar.bz2
jalv-22c37a1bbd0c8473e36d4638770ee79a19792038.zip
Factor out process_silent() from Jack process callback
-rw-r--r--src/jack.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/jack.c b/src/jack.c
index c4d8411..93a6d3e 100644
--- a/src/jack.c
+++ b/src/jack.c
@@ -109,6 +109,25 @@ forge_position(LV2_Atom_Forge* const forge,
}
}
+static int
+process_silent(Jalv* const jalv, const jack_nframes_t nframes)
+{
+ for (uint32_t p = 0U; p < jalv->num_ports; ++p) {
+ JalvPort* const port = &jalv->ports[p];
+ jack_port_t* const jport = (jack_port_t*)jalv->ports[p].sys_port;
+ if (jport && port->flow == FLOW_OUTPUT) {
+ void* const buf = jack_port_get_buffer(jport, nframes);
+ if (port->type == TYPE_EVENT) {
+ jack_midi_clear_buffer(buf);
+ } else {
+ memset(buf, '\0', nframes * sizeof(float));
+ }
+ }
+ }
+
+ return 0;
+}
+
/// Jack process callback
static REALTIME int
jack_process_cb(jack_nframes_t nframes, void* data)
@@ -149,18 +168,7 @@ jack_process_cb(jack_nframes_t nframes, void* data)
zix_sem_post(&jalv->paused);
break;
case JALV_PAUSED:
- for (uint32_t p = 0; p < jalv->num_ports; ++p) {
- jack_port_t* jport = jalv->ports[p].sys_port;
- if (jport && jalv->ports[p].flow == FLOW_OUTPUT) {
- void* buf = jack_port_get_buffer(jport, nframes);
- if (jalv->ports[p].type == TYPE_EVENT) {
- jack_midi_clear_buffer(buf);
- } else {
- memset(buf, '\0', nframes * sizeof(float));
- }
- }
- }
- return 0;
+ return process_silent(jalv, nframes);
}
// Prepare port buffers