From: Marco Nelissen Date: Thu, 25 Sep 2014 21:25:18 +0000 (-0700) Subject: Fix SoftAAC2 flush X-Git-Tag: android-x86-6.0-r1~852^2~281^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4edf384a512748b871f24e4c03afaa3c1151ca23;p=android-x86%2Fframeworks-av.git Fix SoftAAC2 flush If there were less than a full frame worth of samples in the ring buffer, then flush would loop forever trying to empty the ring buffer. Bug: 17646525 Change-Id: I68ec87352a91ce3a96d05e9b3f60a6e7975f9156 --- diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp index fb27dca41b..e701e9efef 100644 --- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp +++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp @@ -974,11 +974,15 @@ void SoftAAC2::onPortFlushCompleted(OMX_U32 portIndex) { mDecodedSizes.clear(); mLastInHeader = NULL; } else { - while (outputDelayRingBufferSamplesAvailable() > 0) { - int32_t ns = outputDelayRingBufferGetSamples(0, - mStreamInfo->frameSize * mStreamInfo->numChannels); - if (ns != mStreamInfo->frameSize * mStreamInfo->numChannels) { + int avail; + while ((avail = outputDelayRingBufferSamplesAvailable()) > 0) { + if (avail > mStreamInfo->frameSize * mStreamInfo->numChannels) { + avail = mStreamInfo->frameSize * mStreamInfo->numChannels; + } + int32_t ns = outputDelayRingBufferGetSamples(0, avail); + if (ns != avail) { ALOGE("not a complete frame of samples available"); + break; } mOutputBufferCount++; }