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.

(cherry picked from commit c01a2977a5)
This commit is contained in:
Barnabás Pőcze 2025-08-07 12:32:17 +02:00 committed by Robert Mader
parent 1d0a1cbf12
commit 746805d30b

View file

@ -362,7 +362,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;
}
@ -1388,6 +1387,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;