aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-08-10 23:02:16 -0400
committerDavid Robillard <d@drobilla.net>2022-08-17 13:51:24 -0400
commitaa4939f8128c2904ec548bbc80db8407ef4b464f (patch)
treeebf63ceb91d51cda2dbcba5707262d4c8f37317a /src
parent7dfdb1744c99d874f7672250cd90b1b9d8d904f2 (diff)
downloadjalv-aa4939f8128c2904ec548bbc80db8407ef4b464f.tar.gz
jalv-aa4939f8128c2904ec548bbc80db8407ef4b464f.tar.bz2
jalv-aa4939f8128c2904ec548bbc80db8407ef4b464f.zip
Use an aligned buffer for reading UI events
Diffstat (limited to 'src')
-rw-r--r--src/jalv.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/jalv.c b/src/jalv.c
index b224ea9..e2c162f 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -571,8 +571,15 @@ jalv_apply_ui_events(Jalv* jalv, uint32_t nframes)
break;
}
- char buffer[MSG_BUFFER_SIZE];
- if (zix_ring_read(jalv->ui_to_plugin, buffer, ev.size) != ev.size) {
+ struct {
+ union {
+ LV2_Atom atom;
+ float control;
+ } head;
+ uint8_t body[MSG_BUFFER_SIZE];
+ } buffer;
+
+ if (zix_ring_read(jalv->ui_to_plugin, &buffer, ev.size) != ev.size) {
jalv_log(JALV_LOG_ERR, "Failed to read from UI ring buffer\n");
break;
}
@@ -581,10 +588,10 @@ jalv_apply_ui_events(Jalv* jalv, uint32_t nframes)
struct Port* const port = &jalv->ports[ev.index];
if (ev.protocol == 0) {
assert(ev.size == sizeof(float));
- port->control = *(float*)buffer;
+ port->control = buffer.head.control;
} else if (ev.protocol == jalv->urids.atom_eventTransfer) {
LV2_Evbuf_Iterator e = lv2_evbuf_end(port->evbuf);
- const LV2_Atom* const atom = (const LV2_Atom*)buffer;
+ const LV2_Atom* const atom = &buffer.head.atom;
lv2_evbuf_write(
&e, nframes, 0, atom->type, atom->size, LV2_ATOM_BODY_CONST(atom));
} else {