spa: libcamera: source: remove stale data from buffers

When clearing the buffers, remove the stale pointers and file descriptors
as accidental reuse of those is problematic and potentially difficult to
diagnose. Do this for every data plane.

Also clear the node's `buffer` structures to remove any references to
the provided `spa_buffer` objects and related metadata.
This commit is contained in:
Barnabás Pőcze 2025-08-13 15:37:51 +02:00
parent bf327d3dfb
commit b82160c2e7

View file

@ -374,13 +374,18 @@ err:
int spa_libcamera_clear_buffers(struct port *port)
{
for (std::size_t i = 0; i < port->n_buffers; i++) {
struct buffer *b;
struct spa_data *d;
buffer *b = &port->buffers[i];
spa_buffer *sb = b->outbuf;
b = &port->buffers[i];
d = b->outbuf->datas;
for (std::size_t j = 0; j < sb->n_datas; j++) {
auto *d = &sb->datas[j];
d[0].type = SPA_ID_INVALID;
d->type = SPA_ID_INVALID;
d->data = nullptr;
d->fd = -1;
}
*b = {};
}
port->n_buffers = 0;