In order to clear the V4L2VideoDevice cache, we must call V4L2VideoDevice::releaseBuffers() when stopping the camera. To do this without releasing the allocated buffers, we have to rework the internal buffer allocation logic. Remove calls to V4L2VideoDevice::importBuffers() and releaseBuffers() from within the RPi::Stream class. Instead, move these calls to the PipelineHandlerBase class, where we can call releaseBuffers(), i.e. clear the V4L2VideoDevice cache unconditionally on stop without de-allocating the internal buffers. The code in Stream::clearBuffers() can be then moved into releaseBuffers() which will actually de-allocate the internal buffers when required. Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/265 Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> # rpi4 Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>