From ca6630c6065a9c93dde7b08b267c4d18314f935e Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Thu, 16 Oct 2014 09:19:35 -0700 Subject: Don't signal an error at the end of a short file Just signaling EOS is sufficient Bug: 17933838 Change-Id: I04a1af57378115731febe7cacb35af5e55d5db83 --- media/libstagefright/codecs/aacdec/SoftAAC2.cpp | 30 +++++++++---------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp index 7209cb3..495bad0 100644 --- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp +++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp @@ -929,30 +929,22 @@ void SoftAAC2::onQueueFilled(OMX_U32 /* portIndex */) { } if (mEndOfInput) { - if (outputDelayRingBufferSamplesAvailable() > 0 - && outputDelayRingBufferSamplesAvailable() - < mStreamInfo->frameSize * mStreamInfo->numChannels) { - ALOGE("not a complete frame of samples available"); - mSignalledError = true; - notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); - return; - } - - if (mEndOfInput && !outQueue.empty() && outputDelayRingBufferSamplesAvailable() == 0) { + int ringBufAvail = outputDelayRingBufferSamplesAvailable(); + if (!outQueue.empty() + && ringBufAvail < mStreamInfo->frameSize * mStreamInfo->numChannels) { if (!mEndOfOutput) { - // send empty block signaling EOS + // send partial or empty block signaling EOS mEndOfOutput = true; BufferInfo *outInfo = *outQueue.begin(); OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; - if (outHeader->nOffset != 0) { - ALOGE("outHeader->nOffset != 0 is not handled"); - mSignalledError = true; - notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); - return; + INT_PCM *outBuffer = reinterpret_cast(outHeader->pBuffer + + outHeader->nOffset); + int32_t ns = outputDelayRingBufferGetSamples(outBuffer, ringBufAvail); + if (ns < 0) { + ns = 0; } - - outHeader->nFilledLen = 0; + outHeader->nFilledLen = ns; outHeader->nFlags = OMX_BUFFERFLAG_EOS; outHeader->nTimeStamp = mBufferTimestamps.itemAt(0); @@ -991,7 +983,7 @@ void SoftAAC2::onPortFlushCompleted(OMX_U32 portIndex) { } int32_t ns = outputDelayRingBufferGetSamples(0, avail); if (ns != avail) { - ALOGE("not a complete frame of samples available"); + ALOGW("not a complete frame of samples available"); break; } mOutputBufferCount++; -- cgit v1.1