@@ -1033,9 +1033,18 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer)
{
std::vector<FrameBuffer::Plane> planes;
- for (unsigned int i = 0; i < 3; i++) {
+ for (int i = 0; i < camera3buffer->numFds; i++) {
FrameBuffer::Plane plane;
plane.fd = FileDescriptor(camera3buffer->data[i]);
+
+ /* numFds is seemingly always 4... */
+ if (!plane.fd.isValid()) {
+ LOG(HAL, Debug) << "Created an invalid plane... ("
+ << camera3buffer->data[i] << ") "
+ << i << "/" << camera3buffer->numFds;
+ continue;
+ }
+
/*
* Setting length to zero here is OK as the length is only used
* to map the memory of the plane. Libcamera do not need to poke
The camera3buffer describes the number of filedescriptors given. Don't try to construct more planes than that. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> --- We always try to create 3 planes, and we never check if the FileDescriptor is valid. Instead, use the numFds provided by the camera3buffer, but check to see if the FileDescriptor was valid before adding the plane to the FrameBuffer. I have a further check in a later patch which skips planes where the camera3buffer->data[i] is already set to -1, so we know it's invalid, and this removes the warning below, leaving us with two planes created for all buffers tested using the Camera app. src/android/camera_device.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)