summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-06-22 07:34:03 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-06-22 07:34:03 +0000
commita2208b3d26397b176050d199852fbeb66289b016 (patch)
treec901398bd132bafc2c6ffb93ba70bb99beb97d0e
parent65d827caf1e708cbb4052eefe8424a277d9219f8 (diff)
parent80e9890f30bb1048f46e14fc17b89b4f109cde9f (diff)
downloadcontexthub-a2208b3d26397b176050d199852fbeb66289b016.tar.gz
release-request-36fe639f-9404-4c33-86fb-47bc4ab2221f-for-git_oc-mr1-release-4124666 snap-temp-L64200000076596327
Change-Id: Ie30d2d8de1a137187b54ba4fcb48e3acaf2f6b46
-rw-r--r--contexthubhal/nanohubhal.cpp15
-rw-r--r--sensorhal/directchannel.cpp24
-rw-r--r--sensorhal/directchannel.h2
3 files changed, 32 insertions, 9 deletions
diff --git a/contexthubhal/nanohubhal.cpp b/contexthubhal/nanohubhal.cpp
index fa3c5f8f..7764253b 100644
--- a/contexthubhal/nanohubhal.cpp
+++ b/contexthubhal/nanohubhal.cpp
@@ -139,8 +139,11 @@ static void wait_on_dev_lock(pollfd &pfd) {
discard_inotify_evt(pfd);
while (access(NANOHUB_LOCK_FILE, F_OK) == 0) {
ALOGW("Nanohub is locked; blocking read thread");
- int ret = poll(&pfd, 1, 5000);
- if (ret > 0) {
+ int ret = TEMP_FAILURE_RETRY(poll(&pfd, 1, 5000));
+ if (ret < 0) {
+ ALOGE("poll returned with an error: %s", strerror(errno));
+ break;
+ } else if (ret > 0) {
discard_inotify_evt(pfd);
}
}
@@ -226,10 +229,12 @@ void* NanoHub::runDeviceRx()
setDebugFlags(property_get_int32("persist.nanohub.debug", 0));
while (1) {
- int ret = poll(myFds, numPollFds, -1);
- if (ret <= 0) {
- ALOGD("poll returned with an error: %s", strerror(errno));
+ int ret = TEMP_FAILURE_RETRY(poll(myFds, numPollFds, -1));
+ if (ret == 0)
continue;
+ else if (ret < 0) {
+ ALOGE("poll returned with an error: %s", strerror(errno));
+ break;
}
if (hasInotify) {
diff --git a/sensorhal/directchannel.cpp b/sensorhal/directchannel.cpp
index d0e719d6..8d87782d 100644
--- a/sensorhal/directchannel.cpp
+++ b/sensorhal/directchannel.cpp
@@ -79,7 +79,8 @@ ANDROID_SINGLETON_STATIC_INSTANCE(GrallocHalWrapper);
GrallocHalWrapper::GrallocHalWrapper()
: mError(NO_INIT), mVersion(-1),
mGrallocModule(nullptr), mAllocDevice(nullptr), mGralloc1Device(nullptr),
- mPfnRetain(nullptr), mPfnRelease(nullptr), mPfnLock(nullptr), mPfnUnlock(nullptr) {
+ mPfnRetain(nullptr), mPfnRelease(nullptr), mPfnLock(nullptr), mPfnUnlock(nullptr),
+ mUnregisterImplyDelete(false) {
const hw_module_t *module;
status_t err = ::hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
ALOGE_IF(err, "couldn't load %s module (%s)", GRALLOC_HARDWARE_MODULE_ID, strerror(-err));
@@ -106,7 +107,7 @@ GrallocHalWrapper::GrallocHalWrapper()
mGrallocModule = (gralloc_module_t *)module;
mVersion = 0;
break;
- case 1:
+ case 1: {
err = ::gralloc1_open(module, &mGralloc1Device);
if (err != NO_ERROR) {
ALOGE("cannot open gralloc1 device (%s)", strerror(-err));
@@ -135,10 +136,23 @@ GrallocHalWrapper::GrallocHalWrapper()
break;
}
+
+ int32_t caps[GRALLOC1_LAST_CAPABILITY];
+ uint32_t n_cap = GRALLOC1_LAST_CAPABILITY;
+ mGralloc1Device->getCapabilities(mGralloc1Device, &n_cap, caps);
+ for (size_t i = 0; i < n_cap; ++i) {
+ if (caps[i] == GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE) {
+ mUnregisterImplyDelete = true;
+ }
+ }
+ ALOGI("gralloc hal %ssupport RELEASE_IMPLY_DELETE",
+ mUnregisterImplyDelete ? "" : "does not ");
+
// successfully initialized gralloc1
mGrallocModule = (gralloc_module_t *)module;
mVersion = 1;
break;
+ }
default:
ALOGE("Unknown version, not supported");
break;
@@ -280,8 +294,10 @@ GrallocDirectChannel::~GrallocDirectChannel() {
mBase = nullptr;
}
GrallocHalWrapper::getInstance().unregisterBuffer(mNativeHandle);
- ::native_handle_close(mNativeHandle);
- ::native_handle_delete(mNativeHandle);
+ if (!GrallocHalWrapper::getInstance().unregisterImplyDelete()) {
+ ::native_handle_close(mNativeHandle);
+ ::native_handle_delete(mNativeHandle);
+ }
mNativeHandle = nullptr;
}
}
diff --git a/sensorhal/directchannel.h b/sensorhal/directchannel.h
index 192e35dc..4842ffcc 100644
--- a/sensorhal/directchannel.h
+++ b/sensorhal/directchannel.h
@@ -58,6 +58,7 @@ public:
int unregisterBuffer(const native_handle_t *handle);
int lock(const native_handle_t *handle, int usage, int l, int t, int w, int h, void **vaddr);
int unlock(const native_handle_t *handle);
+ bool unregisterImplyDelete() { return mUnregisterImplyDelete; }
private:
friend class Singleton<GrallocHalWrapper>;
GrallocHalWrapper();
@@ -76,6 +77,7 @@ private:
GRALLOC1_PFN_RELEASE mPfnRelease;
GRALLOC1_PFN_LOCK mPfnLock;
GRALLOC1_PFN_UNLOCK mPfnUnlock;
+ bool mUnregisterImplyDelete;
};
class GrallocDirectChannel : public DirectChannelBase {