From 7e87bd9b34e4d8ab36d353aa8d8d48260a3ee200 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 10 May 2024 11:33:44 +0200 Subject: [PATCH] alsa-seq: try to not overflow the output buffer Keep some room in the output buffer to store the worst case event and save it for the next cycle. --- spa/plugins/alsa/alsa-seq.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spa/plugins/alsa/alsa-seq.c b/spa/plugins/alsa/alsa-seq.c index 78faf2d1e..189e4332b 100644 --- a/spa/plugins/alsa/alsa-seq.c +++ b/spa/plugins/alsa/alsa-seq.c @@ -553,6 +553,13 @@ static int process_read(struct seq_state *state) spa_pod_builder_bytes(&port->builder, data, size); snd_seq_free_event(ev); + + /* make sure we can fit at least one control event of max size otherwise + * we keep the event in the queue and try to copy it in the next cycle */ + if (port->builder.state.offset + + sizeof(struct spa_pod_control) + + MAX_EVENT_SIZE > port->buffer->buf->datas[0].maxsize) + break; } /* prepare a buffer on each port, some ports might have their