From 88fc1b0ef4ffa50dc98c028b3bc65c79964cc3ec Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Thu, 13 Nov 2014 17:07:40 -0800 Subject: [PATCH 1/2] Fix issue #18356768: some app process may hang at Runtime#exit... ...in Parcel destructor Don't use a Mutux object, just use simple posix mutex primitives, to avoid static init/destroy order problems. Change-Id: Ic012d94297564c0a55d58869f8276d7d10545fbc --- include/private/binder/Static.h | 5 ----- libs/binder/Parcel.cpp | 36 ++++++++++++++++++++------------- libs/binder/Static.cpp | 6 ------ 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/include/private/binder/Static.h b/include/private/binder/Static.h index eeb37d79a..d10464680 100644 --- a/include/private/binder/Static.h +++ b/include/private/binder/Static.h @@ -34,11 +34,6 @@ extern Vector gTextBuffers; extern Mutex gProcessMutex; extern sp gProcess; -// For Parcel.cpp -extern Mutex gParcelGlobalAllocSizeLock; -extern size_t gParcelGlobalAllocSize; -extern size_t gParcelGlobalAllocCount; - // For IServiceManager.cpp extern Mutex gDefaultServiceManagerLock; extern sp gDefaultServiceManager; diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 98a3dd7be..e7589b1a5 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -75,6 +75,10 @@ struct small_flat_data namespace android { +static pthread_mutex_t gParcelGlobalAllocSizeLock = PTHREAD_MUTEX_INITIALIZER; +static size_t gParcelGlobalAllocSize = 0; +static size_t gParcelGlobalAllocCount = 0; + void acquire_object(const sp& proc, const flat_binder_object& obj, const void* who) { @@ -305,13 +309,17 @@ Parcel::~Parcel() } size_t Parcel::getGlobalAllocSize() { - AutoMutex _l(gParcelGlobalAllocSizeLock); - return gParcelGlobalAllocSize; + pthread_mutex_lock(&gParcelGlobalAllocSizeLock); + size_t size = gParcelGlobalAllocSize; + pthread_mutex_unlock(&gParcelGlobalAllocSizeLock); + return size; } size_t Parcel::getGlobalAllocCount() { - AutoMutex _l(gParcelGlobalAllocSizeLock); - return gParcelGlobalAllocCount; + pthread_mutex_lock(&gParcelGlobalAllocSizeLock); + size_t count = gParcelGlobalAllocCount; + pthread_mutex_unlock(&gParcelGlobalAllocSizeLock); + return count; } const uint8_t* Parcel::data() const @@ -1511,10 +1519,10 @@ void Parcel::freeDataNoInit() releaseObjects(); if (mData) { LOG_ALLOC("Parcel %p: freeing with %zu capacity", this, mDataCapacity); - gParcelGlobalAllocSizeLock.lock(); + pthread_mutex_lock(&gParcelGlobalAllocSizeLock); gParcelGlobalAllocSize -= mDataCapacity; gParcelGlobalAllocCount--; - gParcelGlobalAllocSizeLock.unlock(); + pthread_mutex_unlock(&gParcelGlobalAllocSizeLock); free(mData); } if (mObjects) free(mObjects); @@ -1546,10 +1554,10 @@ status_t Parcel::restartWrite(size_t desired) if (data) { LOG_ALLOC("Parcel %p: restart from %zu to %zu capacity", this, mDataCapacity, desired); - gParcelGlobalAllocSizeLock.lock(); + pthread_mutex_lock(&gParcelGlobalAllocSizeLock); gParcelGlobalAllocSize += desired; gParcelGlobalAllocSize -= mDataCapacity; - gParcelGlobalAllocSizeLock.unlock(); + pthread_mutex_unlock(&gParcelGlobalAllocSizeLock); mData = data; mDataCapacity = desired; } @@ -1630,10 +1638,10 @@ status_t Parcel::continueWrite(size_t desired) mOwner = NULL; LOG_ALLOC("Parcel %p: taking ownership of %zu capacity", this, desired); - gParcelGlobalAllocSizeLock.lock(); + pthread_mutex_lock(&gParcelGlobalAllocSizeLock); gParcelGlobalAllocSize += desired; gParcelGlobalAllocCount++; - gParcelGlobalAllocSizeLock.unlock(); + pthread_mutex_unlock(&gParcelGlobalAllocSizeLock); mData = data; mObjects = objects; @@ -1671,10 +1679,10 @@ status_t Parcel::continueWrite(size_t desired) if (data) { LOG_ALLOC("Parcel %p: continue from %zu to %zu capacity", this, mDataCapacity, desired); - gParcelGlobalAllocSizeLock.lock(); + pthread_mutex_lock(&gParcelGlobalAllocSizeLock); gParcelGlobalAllocSize += desired; gParcelGlobalAllocSize -= mDataCapacity; - gParcelGlobalAllocSizeLock.unlock(); + pthread_mutex_unlock(&gParcelGlobalAllocSizeLock); mData = data; mDataCapacity = desired; } else if (desired > mDataCapacity) { @@ -1706,10 +1714,10 @@ status_t Parcel::continueWrite(size_t desired) } LOG_ALLOC("Parcel %p: allocating with %zu capacity", this, desired); - gParcelGlobalAllocSizeLock.lock(); + pthread_mutex_lock(&gParcelGlobalAllocSizeLock); gParcelGlobalAllocSize += desired; gParcelGlobalAllocCount++; - gParcelGlobalAllocSizeLock.unlock(); + pthread_mutex_unlock(&gParcelGlobalAllocSizeLock); mData = data; mDataSize = mDataPos = 0; diff --git a/libs/binder/Static.cpp b/libs/binder/Static.cpp index b870c342d..cd9509f70 100644 --- a/libs/binder/Static.cpp +++ b/libs/binder/Static.cpp @@ -90,12 +90,6 @@ public: static LibBinderIPCtStatics gIPCStatics; -// ------------ Parcel.cpp - -Mutex gParcelGlobalAllocSizeLock; -size_t gParcelGlobalAllocSize = 0; -size_t gParcelGlobalAllocCount = 0; - // ------------ IServiceManager.cpp Mutex gDefaultServiceManagerLock; From 76d4c5cf733bbc15026611d555eb1497e5ab25d4 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Thu, 6 Nov 2014 10:47:41 -0800 Subject: [PATCH 2/2] omx: add (temporary) index for automatic video frc support Bug: 17383204 Change-Id: I9b22da03ea3f2a7d9dd85042fff442d2414cbc26 --- include/media/openmax/OMX_AsString.h | 2 +- include/media/openmax/OMX_IndexExt.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/media/openmax/OMX_AsString.h b/include/media/openmax/OMX_AsString.h index 18e1e52ec..0f177a126 100644 --- a/include/media/openmax/OMX_AsString.h +++ b/include/media/openmax/OMX_AsString.h @@ -520,7 +520,7 @@ inline static const char *asString(OMX_INDEXEXTTYPE i, const char *def = "??") { case OMX_IndexParamVideoAndroidVp8Encoder: return "ParamVideoAndroidVp8Encoder"; case OMX_IndexParamVideoHevc: return "ParamVideoHevc"; // case OMX_IndexParamSliceSegments: return "ParamSliceSegments"; -// case OMX_IndexConfigAutoFramerateConversion: return "ConfigAutoFramerateConversion"; + case OMX_IndexConfigAutoFramerateConversion: return "ConfigAutoFramerateConversion"; default: return asString((OMX_INDEXTYPE)i, def); } } diff --git a/include/media/openmax/OMX_IndexExt.h b/include/media/openmax/OMX_IndexExt.h index 6cd774bd8..699efcbea 100644 --- a/include/media/openmax/OMX_IndexExt.h +++ b/include/media/openmax/OMX_IndexExt.h @@ -81,6 +81,7 @@ typedef enum OMX_INDEXEXTTYPE { /* Other configurations */ OMX_IndexExtOtherStartUnused = OMX_IndexKhronosExtensions + 0x00800000, + OMX_IndexConfigAutoFramerateConversion, /**< reference: OMX_CONFIG_BOOLEANTYPE */ /* Time configurations */ OMX_IndexExtTimeStartUnused = OMX_IndexKhronosExtensions + 0x00900000,