[libcamera-devel] [PATCH v2 07/12] android: camera_device: Only construct required planes
Kieran Bingham
kieran.bingham at ideasonboard.com
Mon Aug 3 18:18:11 CEST 2020
The camera3buffer describes the number of filedescriptors given.
Don't try to construct more planes than that.
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
src/android/camera_device.cpp | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 388945b1075c..78b0246e40f0 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1022,9 +1022,20 @@ 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++) {
+ /* Skip unused planes. */
+ if (camera3buffer->data[i] == -1)
+ break;
+
FrameBuffer::Plane plane;
plane.fd = FileDescriptor(camera3buffer->data[i]);
+ if (!plane.fd.isValid()) {
+ LOG(HAL, Error) << "Failed to obtain FileDescriptor ("
+ << camera3buffer->data[i] << ") "
+ << " on plane " << i;
+ break;
+ }
+
/*
* 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
--
2.25.1
More information about the libcamera-devel
mailing list