summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/OMXCodec.cpp
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2011-07-15 15:25:36 -0700
committerJames Dong <jdong@google.com>2011-07-15 15:32:21 -0700
commita57a9a491272aa884494b2ec7854960827a73742 (patch)
treef3a37638b79d9083ecd09dce607086155c84cdf8 /media/libstagefright/OMXCodec.cpp
parent4378ace44b9de477608a6c2fbf7134bc0345555f (diff)
downloadframeworks_av-a57a9a491272aa884494b2ec7854960827a73742.zip
frameworks_av-a57a9a491272aa884494b2ec7854960827a73742.tar.gz
frameworks_av-a57a9a491272aa884494b2ec7854960827a73742.tar.bz2
Do not wait forever for output buffers in OMXCodec.cpp and error out in case time out happens
o Deal with vendor codec hang bug Change-Id: Ic8449afd43045f09a9e0bd3d1be9a320e59ccabe
Diffstat (limited to 'media/libstagefright/OMXCodec.cpp')
-rwxr-xr-xmedia/libstagefright/OMXCodec.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 5cab60e..78349a6 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;
@@ -3184,6 +3188,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) {
@@ -3616,6 +3630,7 @@ sp<MetaData> OMXCodec::getFormat() {
status_t OMXCodec::read(
MediaBuffer **buffer, const ReadOptions *options) {
+ status_t err = OK;
*buffer = NULL;
Mutex::Autolock autoLock(mLock);
@@ -3656,7 +3671,9 @@ status_t OMXCodec::read(
if (seeking) {
while (mState == RECONFIGURING) {
- mBufferFilled.wait(mLock);
+ if ((err = waitForBufferFilled_l()) != OK) {
+ return err;
+ }
}
if (mState != EXECUTING) {
@@ -3687,19 +3704,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;
}
}