From f97e131d962d400f5d16facc17fcc19b2bf092b4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 19 Mar 2025 13:10:15 +0100 Subject: [PATCH] netjack2: fix the large midi events offset The midi events have their large data offsets relative to the start of the buffer and the large data is at the end of the buffer. Because we copied it down, right after the events, but we didn't adjust the offsets, calculate a correction offset when unpacking the events. --- src/modules/module-netjack2/peer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/module-netjack2/peer.c b/src/modules/module-netjack2/peer.c index c1e658d3c..3f62532fc 100644 --- a/src/modules/module-netjack2/peer.c +++ b/src/modules/module-netjack2/peer.c @@ -317,6 +317,8 @@ static inline void netjack2_to_midi(float *dst, uint32_t size, struct nj2_midi_b struct spa_pod_builder b = { 0, }; uint32_t i; struct spa_pod_frame f; + size_t offset = size - buf->write_pos - + sizeof(*buf) - (buf->event_count * sizeof(struct nj2_midi_event)); spa_pod_builder_init(&b, dst, size); spa_pod_builder_push_sequence(&b, &f, 0); @@ -326,8 +328,8 @@ static inline void netjack2_to_midi(float *dst, uint32_t size, struct nj2_midi_b if (ev->size <= MIDI_INLINE_MAX) data = ev->buffer; - else if (ev->offset > buf->write_pos) - data = SPA_PTROFF(buf, ev->offset - buf->write_pos, void); + else if (ev->offset > offset) + data = SPA_PTROFF(buf, ev->offset - offset, void); else continue;