diff options
author | David Robillard <d@drobilla.net> | 2024-11-21 18:13:50 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-11-24 19:11:53 -0500 |
commit | 15324bd2bb040f9dc62769b9355bb31b57a9ae0e (patch) | |
tree | 1fa0bb4a068f972a2909f3488bd3a40d8a1d95cf /src/process_setup.c | |
parent | 2a5bc1ca7aee36cd763ac10c894b84eef347fe25 (diff) | |
download | jalv-15324bd2bb040f9dc62769b9355bb31b57a9ae0e.tar.gz jalv-15324bd2bb040f9dc62769b9355bb31b57a9ae0e.tar.bz2 jalv-15324bd2bb040f9dc62769b9355bb31b57a9ae0e.zip |
Move process thread setup code to a separate file
Towards more cleanly separating the audio thread code from the rest of the
application.
Diffstat (limited to 'src/process_setup.c')
-rw-r--r-- | src/process_setup.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/process_setup.c b/src/process_setup.c new file mode 100644 index 0000000..3f64d02 --- /dev/null +++ b/src/process_setup.c @@ -0,0 +1,46 @@ +// Copyright 2016-2024 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +#include "process_setup.h" + +#include "jalv.h" +#include "lv2_evbuf.h" +#include "port.h" +#include "types.h" +#include "urids.h" + +#include <lilv/lilv.h> + +#include <stddef.h> +#include <stdint.h> + +void +jalv_allocate_port_buffers(Jalv* const jalv) +{ + const JalvURIDs* const urids = &jalv->urids; + + for (uint32_t i = 0; i < jalv->num_ports; ++i) { + JalvPort* const port = &jalv->ports[i]; + if (port->type == TYPE_EVENT) { + const size_t size = + port->buf_size ? port->buf_size : jalv->settings.midi_buf_size; + + lv2_evbuf_free(port->evbuf); + port->evbuf = + lv2_evbuf_new(size, urids->atom_Chunk, urids->atom_Sequence); + + lv2_evbuf_reset(port->evbuf, port->flow == FLOW_INPUT); + lilv_instance_connect_port( + jalv->instance, i, lv2_evbuf_get_buffer(port->evbuf)); + } + } +} + +void +jalv_free_port_buffers(Jalv* const jalv) +{ + for (uint32_t i = 0; i < jalv->num_ports; ++i) { + lv2_evbuf_free(jalv->ports[i].evbuf); + lilv_instance_connect_port(jalv->instance, i, NULL); + } +} |