summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2011-01-10 08:55:02 -0800
committerJames Dong <jdong@google.com>2011-01-10 08:57:50 -0800
commit681e89c08264af948735d00552c4bd08180b06b4 (patch)
tree411b93b4f29c85ca922bbb6544320a54fab08fcb /media
parentaa6b9f55d60702211dd2d08403c7296347f0bd7d (diff)
downloadframeworks_base-681e89c08264af948735d00552c4bd08180b06b4.zip
frameworks_base-681e89c08264af948735d00552c4bd08180b06b4.tar.gz
frameworks_base-681e89c08264af948735d00552c4bd08180b06b4.tar.bz2
Avoid deadlock in OMX::freeNode by making sure OMXCodecObserver does not hold the last reference of OMXCodec object
bug - 3336424 Change-Id: I4c79b66a900c527e3ae6a833f76d5da1b75c5a89
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 8efd963..7750a9d 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -235,7 +235,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();
}
}
@@ -1845,8 +1847,6 @@ OMXCodec::BufferInfo* OMXCodec::dequeueBufferFromNativeWindow() {
}
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 4e9920b..3638f41 100644
--- a/media/libstagefright/omx/OMX.cpp
+++ b/media/libstagefright/omx/OMX.cpp
@@ -86,6 +86,9 @@ OMX::CallbackDispatcher::~CallbackDispatcher() {
mQueueChanged.signal();
}
+ // Don't call join on myself
+ CHECK(mThread != pthread_self());
+
void *dummy;
pthread_join(mThread, &dummy);
}
@@ -246,9 +249,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;
}