From 8c583f8e20c6a050055154231f4280b007528b85 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 20 Jul 2024 16:41:41 +0200 Subject: [PATCH] Use 64bit alignment for LV2 event buffer #9748 --- libs/ardour/lv2_evbuf.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libs/ardour/lv2_evbuf.cc b/libs/ardour/lv2_evbuf.cc index 8681ec7e60..816f383963 100644 --- a/libs/ardour/lv2_evbuf.cc +++ b/libs/ardour/lv2_evbuf.cc @@ -26,6 +26,7 @@ #include #endif +#include "pbd/malign.h" #include "ardour/lv2_evbuf.h" using namespace ARDOUR; @@ -48,9 +49,16 @@ ARDOUR::lv2_evbuf_new (uint32_t capacity, uint32_t atom_Chunk, uint32_t atom_Sequence) { - // FIXME: memory must be 64-bit aligned - LV2_Evbuf* evbuf = (LV2_Evbuf*)malloc( - sizeof(LV2_Evbuf) + sizeof(LV2_Atom_Sequence) + capacity); + LV2_Evbuf* evbuf; + + int err = cache_aligned_malloc ((void**) &evbuf, sizeof(LV2_Evbuf) + sizeof(LV2_Atom_Sequence) + capacity); + + if (err) { + //fatal << string_compose (_("Memory allocation error: (%1)"), strerror (err)) << endmsg; + abort (); + return 0; + } + evbuf->capacity = capacity; evbuf->atom_Chunk = atom_Chunk; evbuf->atom_Sequence = atom_Sequence; @@ -61,7 +69,7 @@ ARDOUR::lv2_evbuf_new (uint32_t capacity, void ARDOUR::lv2_evbuf_free (LV2_Evbuf* evbuf) { - free(evbuf); + cache_aligned_free (evbuf); } void