diff options
author | David Robillard <d@drobilla.net> | 2022-08-10 23:02:16 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-17 13:51:24 -0400 |
commit | aa4939f8128c2904ec548bbc80db8407ef4b464f (patch) | |
tree | ebf63ceb91d51cda2dbcba5707262d4c8f37317a /src | |
parent | 7dfdb1744c99d874f7672250cd90b1b9d8d904f2 (diff) | |
download | jalv-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.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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 { |