module-profiler: make sure we don't overrun the flush buffer

Check that the node profiler data fits in the flush buffer.
This commit is contained in:
Wim Taymans 2023-08-01 18:14:53 +02:00
parent 0cbcf88eaa
commit 121228bde8

View file

@ -134,12 +134,14 @@ static void do_flush_event(void *data, uint64_t count)
pw_log_trace("%p avail %d", impl, avail); pw_log_trace("%p avail %d", impl, avail);
if (avail > 0) { if (avail > 0) {
spa_ringbuffer_read_data(&n->buffer, n->data, DATA_BUFFER, if (total + avail < FLUSH_BUFFER) {
idx % DATA_BUFFER, spa_ringbuffer_read_data(&n->buffer, n->data, DATA_BUFFER,
SPA_PTROFF(p, sizeof(struct spa_pod_struct) + total, void), idx % DATA_BUFFER,
avail); SPA_PTROFF(p, sizeof(struct spa_pod_struct) + total, void),
avail);
total += avail;
}
spa_ringbuffer_read_update(&n->buffer, idx + avail); spa_ringbuffer_read_update(&n->buffer, idx + avail);
total += avail;
} }
} }