diff options
| author | 2009-08-25 14:26:05 -0700 | |
|---|---|---|
| committer | 2009-08-25 14:26:05 -0700 | |
| commit | 404cc418be3eeaef93729fab51a0124ed65e1adc (patch) | |
| tree | 1b63086bed495522df346c5de0bc5557ec88c0cf | |
| parent | 4804c3e23b0bb8e77b690df177ebd4d6fb949aa8 (diff) | |
Make sure not to ask for more buffers when we know that there won't be any, added a quirk for the aac decoder.
| -rw-r--r-- | include/media/stagefright/OMXCodec.h | 9 | ||||
| -rw-r--r-- | media/libstagefright/OMXCodec.cpp | 40 |
2 files changed, 44 insertions, 5 deletions
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h index 0b941180affa..e4f6a4e8d887 100644 --- a/include/media/stagefright/OMXCodec.h +++ b/include/media/stagefright/OMXCodec.h @@ -82,6 +82,7 @@ private: kWantsNALFragments = 2, kRequiresLoadedToIdleAfterAllocation = 4, kRequiresAllocateBufferOnInputPorts = 8, + kRequiresFlushCompleteEmulation = 16, }; struct BufferInfo { @@ -165,7 +166,13 @@ private: void drainInputBuffers(); void fillOutputBuffers(); - void flushPortAsync(OMX_U32 portIndex); + // Returns true iff a flush was initiated and a completion event is + // upcoming, false otherwise (A flush was not necessary as we own all + // the buffers on that port). + // This method will ONLY ever return false for a component with quirk + // "kRequiresFlushCompleteEmulation". + bool flushPortAsync(OMX_U32 portIndex); + void disablePortAsync(OMX_U32 portIndex); void enablePortAsync(OMX_U32 portIndex); diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index ec9f6d319d57..fec6cfb83d02 100644 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -193,6 +193,7 @@ sp<OMXCodec> OMXCodec::Create( } if (!strcmp(componentName, "OMX.TI.AAC.decode")) { quirks |= kNeedsFlushBeforeDisable; + quirks |= kRequiresFlushCompleteEmulation; } if (!strncmp(componentName, "OMX.qcom.video.encoder.", 23)) { quirks |= kRequiresLoadedToIdleAfterAllocation; @@ -1163,21 +1164,38 @@ void OMXCodec::onPortSettingsChanged(OMX_U32 portIndex) { setState(RECONFIGURING); if (mQuirks & kNeedsFlushBeforeDisable) { - flushPortAsync(portIndex); + if (!flushPortAsync(portIndex)) { + onCmdComplete(OMX_CommandFlush, portIndex); + } } else { disablePortAsync(portIndex); } } -void OMXCodec::flushPortAsync(OMX_U32 portIndex) { +bool OMXCodec::flushPortAsync(OMX_U32 portIndex) { CHECK(mState == EXECUTING || mState == RECONFIGURING); + LOGV("flushPortAsync(%ld): we own %d out of %d buffers already.", + portIndex, countBuffersWeOwn(mPortBuffers[portIndex]), + mPortBuffers[portIndex].size()); + CHECK_EQ(mPortStatus[portIndex], ENABLED); mPortStatus[portIndex] = SHUTTING_DOWN; + if ((mQuirks & kRequiresFlushCompleteEmulation) + && countBuffersWeOwn(mPortBuffers[portIndex]) + == mPortBuffers[portIndex].size()) { + // No flush is necessary and this component fails to send a + // flush-complete event in this case. + + return false; + } + status_t err = mOMX->send_command(mNode, OMX_CommandFlush, portIndex); CHECK_EQ(err, OK); + + return true; } void OMXCodec::disablePortAsync(OMX_U32 portIndex) { @@ -1323,6 +1341,12 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { void OMXCodec::fillOutputBuffer(BufferInfo *info) { CHECK_EQ(info->mOwnedByComponent, false); + if (mNoMoreOutputData) { + LOGV("There is no more output data available, not " + "calling fillOutputBuffer"); + return; + } + LOGV("Calling fill_buffer on buffer %p", info->mBuffer); mOMX->fill_buffer(mNode, info->mBuffer); @@ -1648,8 +1672,16 @@ status_t OMXCodec::read( CHECK_EQ(mState, EXECUTING); - flushPortAsync(kPortIndexInput); - flushPortAsync(kPortIndexOutput); + bool emulateInputFlushCompletion = !flushPortAsync(kPortIndexInput); + bool emulateOutputFlushCompletion = !flushPortAsync(kPortIndexOutput); + + if (emulateInputFlushCompletion) { + onCmdComplete(OMX_CommandFlush, kPortIndexInput); + } + + if (emulateOutputFlushCompletion) { + onCmdComplete(OMX_CommandFlush, kPortIndexOutput); + } } while (mState != ERROR && !mNoMoreOutputData && mFilledBuffers.empty()) { |