diff options
author | James Dong <jdong@google.com> | 2011-07-24 14:40:08 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-24 14:40:08 -0700 |
commit | e432a0005180ba9ac2c1d7822c4761b475fddc51 (patch) | |
tree | 88ed405f2e6d39e93fc332536319836562321f27 | |
parent | d40e2c67ed6423355aeb1292b33c2f8a20b3c84d (diff) | |
parent | d9ac621f590c51bdc38b46d5aabba2dbc84cbd58 (diff) | |
download | frameworks_base-e432a0005180ba9ac2c1d7822c4761b475fddc51.zip frameworks_base-e432a0005180ba9ac2c1d7822c4761b475fddc51.tar.gz frameworks_base-e432a0005180ba9ac2c1d7822c4761b475fddc51.tar.bz2 |
Merge "Do not wait forever for output buffers in OMXCodec.cpp and error out in case time out happens"
-rw-r--r-- | include/media/stagefright/OMXCodec.h | 1 | ||||
-rwxr-xr-x | media/libstagefright/OMXCodec.cpp | 33 |
2 files changed, 24 insertions, 10 deletions
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h index 93933d9..2932744 100644 --- a/include/media/stagefright/OMXCodec.h +++ b/include/media/stagefright/OMXCodec.h @@ -329,6 +329,7 @@ private: void restorePatchedDataPointer(BufferInfo *info); status_t applyRotation(); + status_t waitForBufferFilled_l(); int64_t retrieveDecodingTimeUs(bool isCodecSpecific); diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 0a6f0bd..ac73351 100755 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -48,6 +48,10 @@ namespace android { +// Treat time out as an error if we have not received any output +// buffers after 3 seconds. +const static int64_t kBufferFilledEventTimeOutUs = 3000000000LL; + struct CodecInfo { const char *mime; const char *codec; @@ -3191,6 +3195,16 @@ void OMXCodec::setState(State newState) { mBufferFilled.signal(); } +status_t OMXCodec::waitForBufferFilled_l() { + status_t err = mBufferFilled.waitRelative(mLock, kBufferFilledEventTimeOutUs); + if (err != OK) { + LOGE("Timed out waiting for buffers from video encoder: %d/%d", + countBuffersWeOwn(mPortBuffers[kPortIndexInput]), + countBuffersWeOwn(mPortBuffers[kPortIndexOutput])); + } + return err; +} + void OMXCodec::setRawAudioFormat( OMX_U32 portIndex, int32_t sampleRate, int32_t numChannels) { @@ -3623,6 +3637,7 @@ sp<MetaData> OMXCodec::getFormat() { status_t OMXCodec::read( MediaBuffer **buffer, const ReadOptions *options) { + status_t err = OK; *buffer = NULL; Mutex::Autolock autoLock(mLock); @@ -3663,7 +3678,9 @@ status_t OMXCodec::read( if (seeking) { while (mState == RECONFIGURING) { - mBufferFilled.wait(mLock); + if ((err = waitForBufferFilled_l()) != OK) { + return err; + } } if (mState != EXECUTING) { @@ -3694,19 +3711,15 @@ status_t OMXCodec::read( } while (mSeekTimeUs >= 0) { - mBufferFilled.wait(mLock); + if ((err = waitForBufferFilled_l()) != OK) { + return err; + } } } while (mState != ERROR && !mNoMoreOutputData && mFilledBuffers.empty()) { - if (mIsEncoder) { - if (NO_ERROR != mBufferFilled.waitRelative(mLock, 3000000000LL)) { - LOGW("Timed out waiting for buffers from video encoder: %d/%d", - countBuffersWeOwn(mPortBuffers[kPortIndexInput]), - countBuffersWeOwn(mPortBuffers[kPortIndexOutput])); - } - } else { - mBufferFilled.wait(mLock); + if ((err = waitForBufferFilled_l()) != OK) { + return err; } } |