summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Jia <wjia@google.com>2015-07-07 14:29:25 -0700
committerWei Jia <wjia@google.com>2015-07-08 15:04:51 -0700
commitfd866b3aa0d97375de08f8888b95669026c83361 (patch)
tree8eeac1f0b7874d5c1daaea951134ccbcd2b151f9
parent065f6572752dca646b7d60df8e80b6d4ac159281 (diff)
downloadframeworks_av-fd866b3aa0d97375de08f8888b95669026c83361.zip
frameworks_av-fd866b3aa0d97375de08f8888b95669026c83361.tar.gz
frameworks_av-fd866b3aa0d97375de08f8888b95669026c83361.tar.bz2
SimpleSoftOMXComponent: change CHECK to error notification.
SoftAVCDec, SoftMPEG4: fix handling of zero-byte input buffer. ACodec: do not send empty input buffer without EOS to the omx component. Bug: 22199127 Change-Id: I0bbcf5778f969ba6e30d0db31770c4289e2b64a4
-rw-r--r--media/libstagefright/ACodec.cpp6
-rw-r--r--media/libstagefright/codecs/avcdec/SoftAVCDec.cpp16
-rw-r--r--media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp33
-rw-r--r--media/libstagefright/omx/SimpleSoftOMXComponent.cpp10
4 files changed, 49 insertions, 16 deletions
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 7452e4b..7d7c2a6 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -4864,6 +4864,12 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) {
case RESUBMIT_BUFFERS:
{
if (buffer != NULL && !mCodec->mPortEOS[kPortIndexInput]) {
+ // Do not send empty input buffer w/o EOS to the component.
+ if (buffer->size() == 0 && !eos) {
+ postFillThisBuffer(info);
+ break;
+ }
+
int64_t timeUs;
CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
diff --git a/media/libstagefright/codecs/avcdec/SoftAVCDec.cpp b/media/libstagefright/codecs/avcdec/SoftAVCDec.cpp
index f3af777..8cf6b1f 100644
--- a/media/libstagefright/codecs/avcdec/SoftAVCDec.cpp
+++ b/media/libstagefright/codecs/avcdec/SoftAVCDec.cpp
@@ -627,6 +627,11 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
if (!inQueue.empty()) {
inInfo = *inQueue.begin();
inHeader = inInfo->mHeader;
+ if (inHeader == NULL) {
+ inQueue.erase(inQueue.begin());
+ inInfo->mOwnedByUs = false;
+ continue;
+ }
} else {
break;
}
@@ -638,14 +643,21 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
outHeader->nTimeStamp = 0;
outHeader->nOffset = 0;
- if (inHeader != NULL && (inHeader->nFlags & OMX_BUFFERFLAG_EOS)) {
- mReceivedEOS = true;
+ if (inHeader != NULL) {
if (inHeader->nFilledLen == 0) {
inQueue.erase(inQueue.begin());
inInfo->mOwnedByUs = false;
notifyEmptyBufferDone(inHeader);
+
+ if (!(inHeader->nFlags & OMX_BUFFERFLAG_EOS)) {
+ continue;
+ }
+
+ mReceivedEOS = true;
inHeader = NULL;
setFlushMode();
+ } else if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) {
+ mReceivedEOS = true;
}
}
diff --git a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
index ede645c..0c1a149 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
+++ b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
@@ -103,34 +103,41 @@ void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) {
while (!inQueue.empty() && outQueue.size() == kNumOutputBuffers) {
BufferInfo *inInfo = *inQueue.begin();
OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;
+ if (inHeader == NULL) {
+ inQueue.erase(inQueue.begin());
+ inInfo->mOwnedByUs = false;
+ continue;
+ }
PortInfo *port = editPortInfo(1);
OMX_BUFFERHEADERTYPE *outHeader =
port->mBuffers.editItemAt(mNumSamplesOutput & 1).mHeader;
- if ((inHeader->nFlags & OMX_BUFFERFLAG_EOS) && inHeader->nFilledLen == 0) {
+ if (inHeader->nFilledLen == 0) {
inQueue.erase(inQueue.begin());
inInfo->mOwnedByUs = false;
notifyEmptyBufferDone(inHeader);
++mInputBufferCount;
- outHeader->nFilledLen = 0;
- outHeader->nFlags = OMX_BUFFERFLAG_EOS;
+ if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) {
+ outHeader->nFilledLen = 0;
+ outHeader->nFlags = OMX_BUFFERFLAG_EOS;
- List<BufferInfo *>::iterator it = outQueue.begin();
- while ((*it)->mHeader != outHeader) {
- ++it;
- }
+ List<BufferInfo *>::iterator it = outQueue.begin();
+ while ((*it)->mHeader != outHeader) {
+ ++it;
+ }
- BufferInfo *outInfo = *it;
- outInfo->mOwnedByUs = false;
- outQueue.erase(it);
- outInfo = NULL;
+ BufferInfo *outInfo = *it;
+ outInfo->mOwnedByUs = false;
+ outQueue.erase(it);
+ outInfo = NULL;
- notifyFillBufferDone(outHeader);
- outHeader = NULL;
+ notifyFillBufferDone(outHeader);
+ outHeader = NULL;
+ }
return;
}
diff --git a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
index 04303c4..e6a0c49 100644
--- a/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
+++ b/media/libstagefright/omx/SimpleSoftOMXComponent.cpp
@@ -505,7 +505,15 @@ void SimpleSoftOMXComponent::onPortFlush(
CHECK_LT(portIndex, mPorts.size());
PortInfo *port = &mPorts.editItemAt(portIndex);
- CHECK_EQ((int)port->mTransition, (int)PortInfo::NONE);
+ // Ideally, the port should not in transitioning state when flushing.
+ // However, in error handling case, e.g., the client can't allocate buffers
+ // when it tries to re-enable the port, the port will be stuck in ENABLING.
+ // The client will then transition the component from Executing to Idle,
+ // which leads to flushing ports. At this time, it should be ok to notify
+ // the client of the error and still clear all buffers on the port.
+ if (port->mTransition != PortInfo::NONE) {
+ notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
+ }
for (size_t i = 0; i < port->mBuffers.size(); ++i) {
BufferInfo *buffer = &port->mBuffers.editItemAt(i);