Merge "Close acquire fence fd after camera capture"
diff --git a/modules/camera/3_4/v4l2_camera.cpp b/modules/camera/3_4/v4l2_camera.cpp
index 3e5b859..2bc0c9f 100644
--- a/modules/camera/3_4/v4l2_camera.cpp
+++ b/modules/camera/3_4/v4l2_camera.cpp
@@ -295,32 +295,36 @@
bool V4L2Camera::dequeueRequestBuffers() {
// Dequeue a buffer.
uint32_t result_index;
- int res = device_->DequeueBuffer(&result_index);
- if (res) {
- if (res == -EAGAIN) {
- // EAGAIN just means nothing to dequeue right now.
- // Wait until something is available before looping again.
- std::unique_lock<std::mutex> lock(in_flight_lock_);
- while (in_flight_.empty()) {
- buffers_in_flight_.wait(lock);
+ int res;
+
+ {
+ std::lock_guard<std::mutex> guard(in_flight_lock_);
+ res = device_->DequeueBuffer(&result_index);
+ if (!res) {
+ // Find the associated request and complete it.
+ auto index_request = in_flight_.find(result_index);
+ if (index_request != in_flight_.end()) {
+ completeRequest(index_request->second, 0);
+ in_flight_.erase(index_request);
+ } else {
+ HAL_LOGW(
+ "Dequeued non in-flight buffer index %d. "
+ "This buffer may have been flushed from the HAL but not the device.",
+ index_request->first);
}
- } else {
- HAL_LOGW("Device failed to dequeue buffer: %d", res);
+ return true;
}
- return true;
}
- // Find the associated request and complete it.
- std::lock_guard<std::mutex> guard(in_flight_lock_);
- auto index_request = in_flight_.find(result_index);
- if (index_request != in_flight_.end()) {
- completeRequest(index_request->second, 0);
- in_flight_.erase(index_request);
+ if (res == -EAGAIN) {
+ // EAGAIN just means nothing to dequeue right now.
+ // Wait until something is available before looping again.
+ std::unique_lock<std::mutex> lock(in_flight_lock_);
+ while (in_flight_.empty()) {
+ buffers_in_flight_.wait(lock);
+ }
} else {
- HAL_LOGW(
- "Dequeued non in-flight buffer index %d. "
- "This buffer may have been flushed from the HAL but not the device.",
- index_request->first);
+ HAL_LOGW("Device failed to dequeue buffer: %d", res);
}
return true;
}
diff --git a/modules/camera/3_4/v4l2_wrapper.cpp b/modules/camera/3_4/v4l2_wrapper.cpp
index 3fafffd..b5a1c71 100644
--- a/modules/camera/3_4/v4l2_wrapper.cpp
+++ b/modules/camera/3_4/v4l2_wrapper.cpp
@@ -535,6 +535,7 @@
std::lock_guard<std::mutex> guard(buffer_queue_lock_);
for (int i = 0; i < buffers_.size(); ++i) {
if (!buffers_[i]) {
+ buffers_[i] = true;
index = i;
break;
}
@@ -557,6 +558,9 @@
// and fill out remaining fields.
if (IoctlLocked(VIDIOC_QUERYBUF, &device_buffer) < 0) {
HAL_LOGE("QUERYBUF fails: %s", strerror(errno));
+ // Return buffer index.
+ std::lock_guard<std::mutex> guard(buffer_queue_lock_);
+ buffers_[index] = false;
return -ENODEV;
}
@@ -565,18 +569,20 @@
gralloc_->lock(camera_buffer, format_->bytes_per_line(), &device_buffer);
if (res) {
HAL_LOGE("Gralloc failed to lock buffer.");
+ // Return buffer index.
+ std::lock_guard<std::mutex> guard(buffer_queue_lock_);
+ buffers_[index] = false;
return res;
}
if (IoctlLocked(VIDIOC_QBUF, &device_buffer) < 0) {
HAL_LOGE("QBUF fails: %s", strerror(errno));
gralloc_->unlock(&device_buffer);
+ // Return buffer index.
+ std::lock_guard<std::mutex> guard(buffer_queue_lock_);
+ buffers_[index] = false;
return -ENODEV;
}
- // Mark the buffer as in flight.
- std::lock_guard<std::mutex> guard(buffer_queue_lock_);
- buffers_[index] = true;
-
if (enqueued_index) {
*enqueued_index = index;
}
diff --git a/modules/sensors/Android.mk b/modules/sensors/Android.mk
index 9942d39..da85e2e 100644
--- a/modules/sensors/Android.mk
+++ b/modules/sensors/Android.mk
@@ -17,7 +17,6 @@
LOCAL_PATH := $(call my-dir)
ifeq ($(USE_SENSOR_MULTI_HAL),true)
-ifneq ($(PRODUCT_FULL_TREBLE),true)
include $(CLEAR_VARS)
@@ -45,10 +44,6 @@
include $(BUILD_SHARED_LIBRARY)
-else
-$(warning Treble enabled device have built-in sensor multihal support. \
- USE_SENSOR_MULTI_HAL should not be set.)
-endif # PRODUCT_FULL_TREBLE
endif # USE_SENSOR_MULTI_HAL
include $(call all-makefiles-under, $(LOCAL_PATH))