spa: libcamera: source: reset ring buffer when stopping

Presently, the ring buffer of completed requests is only cleared
when the buffers are removed from the port. This is not entirely
correct since pause/start commands do not clear the buffers but
they stop the camera. As a consequence, it is possible that some
completed requests stay in the ring buffer, causing them to be
mistakenly processed when the camera is started next.

So reset the ring buffer after the camera is stopped, the same time
as the queue of free buffers is cleared.
This commit is contained in:
Barnabás Pőcze 2025-08-07 12:32:17 +02:00
parent 72fd462090
commit c01a2977a5

View file

@ -363,7 +363,6 @@ int spa_libcamera_clear_buffers(struct impl *impl, struct port *port)
}
port->n_buffers = 0;
impl->completed_requests_rb = SPA_RINGBUFFER_INIT();
return 0;
}
@ -1390,6 +1389,7 @@ int spa_libcamera_stream_off(struct impl *impl)
impl->source.fd = -1;
}
impl->completed_requests_rb = SPA_RINGBUFFER_INIT();
spa_list_init(&port->queue);
return 0;