Refactor camera initialization support of gralloc.
Switch to a factory model so that initialization can
fail when the gralloc module can't be found or isn't supported.
BUG: 30140438
Change-Id: I6e0a62a207797aef96c532cff7632c1a4da8818f
diff --git a/modules/camera/3_4/V4L2CameraHAL.cpp b/modules/camera/3_4/V4L2CameraHAL.cpp
index 6696ba5..40797e9 100644
--- a/modules/camera/3_4/V4L2CameraHAL.cpp
+++ b/modules/camera/3_4/V4L2CameraHAL.cpp
@@ -95,8 +95,12 @@
bus = reinterpret_cast<char*>(cap.bus_info);
if (buses.insert(bus).second) {
HAL_LOGV("Found unique bus at %s.", node.c_str());
- std::unique_ptr<V4L2Camera> cam(new V4L2Camera(id++, node));
- mCameras.push_back(std::move(cam));
+ std::unique_ptr<V4L2Camera> cam(V4L2Camera::NewV4L2Camera(id++, node));
+ if (cam) {
+ mCameras.push_back(std::move(cam));
+ } else {
+ HAL_LOGE("Failed to initialize camera at %s.", node.c_str());
+ }
}
}
TEMP_FAILURE_RETRY(close(fd));