diff options
author | Andreas Huber <andih@google.com> | 2009-08-27 10:08:39 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2009-08-27 10:41:13 -0700 |
commit | 42978e55fe438ecdc1b0bac5bf31c2aadbd9e78d (patch) | |
tree | 32c5794bd120a0367469b27d6387e13522648cde /media | |
parent | 650b872c5aa54d94ef7a8e4a89daab11af15d5e0 (diff) | |
download | frameworks_base-42978e55fe438ecdc1b0bac5bf31c2aadbd9e78d.zip frameworks_base-42978e55fe438ecdc1b0bac5bf31c2aadbd9e78d.tar.gz frameworks_base-42978e55fe438ecdc1b0bac5bf31c2aadbd9e78d.tar.bz2 |
An attempt to fix a deadlock between OMXCodec::start and upstream ::read
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/OMXCodec.cpp | 20 |
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; } |