From 746805d30bf9df8a6501d895cab7cfbdbd8b8563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 7 Aug 2025 12:32:17 +0200 Subject: [PATCH] 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 c01a2977a5d531e36e10ac29e7ed69c3dcbfa999) --- spa/plugins/libcamera/libcamera-source.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spa/plugins/libcamera/libcamera-source.cpp b/spa/plugins/libcamera/libcamera-source.cpp index e83debfe9..874ed4885 100644 --- a/spa/plugins/libcamera/libcamera-source.cpp +++ b/spa/plugins/libcamera/libcamera-source.cpp @@ -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;