android: camera_device: Create struct to track per stream buffer

The Camera3RequestDescriptor structure stores, for each stream, the
camera3_stream_buffer_t and the libcamera FrameBuffer in two separate
vectors. This complicates buffer handling, as the code needs to keep
both vectors in sync. Create a new structure to group all data about
per-stream buffers to simplify this.

As a side effect, we need to create a local vector of
camera3_stream_buffer_t in CameraDevice::sendCaptureResults() as the
camera3_stream_buffer_t instances stored in the new structure in
Camera3RequestDescriptor are not contiguous anymore. This is a small
price to pay for easier handling of buffers, and will be refactored in
subsequent commits anyway.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
This commit is contained in:
Umang Jain 2021-10-19 17:17:55 +05:30
parent 1976179623
commit 573fcb94d6
3 changed files with 55 additions and 44 deletions

View file

@ -23,15 +23,10 @@ Camera3RequestDescriptor::Camera3RequestDescriptor(
/* Copy the camera3 request stream information for later access. */
const uint32_t numBuffers = camera3Request->num_output_buffers;
buffers_.resize(numBuffers);
for (uint32_t i = 0; i < numBuffers; i++)
buffers_[i] = camera3Request->output_buffers[i];
/*
* FrameBuffer instances created by wrapping a camera3 provided dmabuf
* are emplaced in this vector of unique_ptr<> for lifetime management.
*/
frameBuffers_.reserve(numBuffers);
buffers_[i].buffer = camera3Request->output_buffers[i];
/* Clone the controls associated with the camera3 request. */
settings_ = CameraMetadata(camera3Request->settings);