summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2011-01-10 12:09:09 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-01-10 12:09:09 -0800
commit7b8a803497450bb90b9c4f5ba3426bf984fad274 (patch)
tree74e28c69edf407830c632b5a1dd2e8fc7344b416 /media
parent9cfc9eff42a0700029c39e89c38b52488845ad63 (diff)
parent32c8335c6b6eb87a88e9193db1a5aab29175d043 (diff)
downloadframeworks_av-7b8a803497450bb90b9c4f5ba3426bf984fad274.zip
frameworks_av-7b8a803497450bb90b9c4f5ba3426bf984fad274.tar.gz
frameworks_av-7b8a803497450bb90b9c4f5ba3426bf984fad274.tar.bz2
am 13d1cb56: Merge "Avoid deadlock in OMX::freeNode by making sure OMXCodecObserver does not hold the last reference of OMXCodec object - do not merge" into gingerbread
* commit '13d1cb56dfdfc89888de6a0389b0fe6cf7e36c27': Avoid deadlock in OMX::freeNode by making sure OMXCodecObserver does not hold the last reference of OMXCodec object - do not merge
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/OMXCodec.cpp4
-rw-r--r--media/libstagefright/omx/OMX.cpp12
2 files changed, 11 insertions, 5 deletions
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 980da77..b5d00bf 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -234,7 +234,9 @@ struct OMXCodecObserver : public BnOMXObserver {
sp<OMXCodec> codec = mTarget.promote();
if (codec.get() != NULL) {
+ Mutex::Autolock autoLock(codec->mLock);
codec->on_message(msg);
+ codec.clear();
}
}
@@ -1672,8 +1674,6 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
}
void OMXCodec::on_message(const omx_message &msg) {
- Mutex::Autolock autoLock(mLock);
-
switch (msg.type) {
case omx_message::EVENT:
{
diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp
index f19c16a..2ba63f7 100644
--- a/media/libstagefright/omx/OMX.cpp
+++ b/media/libstagefright/omx/OMX.cpp
@@ -89,6 +89,9 @@ OMX::CallbackDispatcher::~CallbackDispatcher() {
mQueueChanged.signal();
}
+ // Don't call join on myself
+ CHECK(mThread != pthread_self());
+
void *dummy;
pthread_join(mThread, &dummy);
}
@@ -249,9 +252,12 @@ status_t OMX::freeNode(node_id node) {
status_t err = instance->freeNode(mMaster);
- index = mDispatchers.indexOfKey(node);
- CHECK(index >= 0);
- mDispatchers.removeItemsAt(index);
+ {
+ Mutex::Autolock autoLock(mLock);
+ index = mDispatchers.indexOfKey(node);
+ CHECK(index >= 0);
+ mDispatchers.removeItemsAt(index);
+ }
return err;
}