summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-08-27 11:18:36 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-08-27 11:18:36 -0700
commite0daf8043fd4a9be995ff737d217b7b3514d4519 (patch)
tree76db0b20479c65d625e8f18dc6180ec215e1e704 /media
parent6ff90cf2b3148b51e6f900e2e86bcd1a2afb26d7 (diff)
parent42978e55fe438ecdc1b0bac5bf31c2aadbd9e78d (diff)
downloadframeworks_base-e0daf8043fd4a9be995ff737d217b7b3514d4519.zip
frameworks_base-e0daf8043fd4a9be995ff737d217b7b3514d4519.tar.gz
frameworks_base-e0daf8043fd4a9be995ff737d217b7b3514d4519.tar.bz2
Merge change 22921 into eclair
* changes: An attempt to fix a deadlock between OMXCodec::start and upstream ::read
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/OMXCodec.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 90ebd7e..38b5e5b 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -634,6 +634,7 @@ OMXCodec::OMXCodec(
mSource(source),
mCodecSpecificDataIndex(0),
mState(LOADED),
+ mInitialBufferSubmit(true),
mSignalledEOS(false),
mNoMoreOutputData(false),
mSeekTimeUs(-1) {
@@ -666,7 +667,7 @@ OMXCodec::~OMXCodec() {
}
status_t OMXCodec::init() {
- Mutex::Autolock autoLock(mLock);
+ // mLock is held.
CHECK_EQ(mState, LOADED);
@@ -1107,8 +1108,11 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) {
setState(EXECUTING);
- drainInputBuffers();
- fillOutputBuffers();
+ // Buffers will be submitted to the component in the first
+ // call to OMXCodec::read as mInitialBufferSubmit is true at
+ // this point. This ensures that this on_message call returns,
+ // releases the lock and ::init can notice the state change and
+ // itself return.
break;
}
@@ -1603,6 +1607,8 @@ void OMXCodec::clearCodecSpecificData() {
}
status_t OMXCodec::start(MetaData *) {
+ Mutex::Autolock autoLock(mLock);
+
if (mState != LOADED) {
return UNKNOWN_ERROR;
}
@@ -1618,6 +1624,7 @@ status_t OMXCodec::start(MetaData *) {
}
mCodecSpecificDataIndex = 0;
+ mInitialBufferSubmit = true;
mSignalledEOS = false;
mNoMoreOutputData = false;
mSeekTimeUs = -1;
@@ -1699,6 +1706,13 @@ status_t OMXCodec::read(
Mutex::Autolock autoLock(mLock);
+ if (mInitialBufferSubmit) {
+ mInitialBufferSubmit = false;
+
+ drainInputBuffers();
+ fillOutputBuffers();
+ }
+
if (mState != EXECUTING && mState != RECONFIGURING) {
return UNKNOWN_ERROR;
}