OSDN Git Service

Fix SoftAAC2 flush
authorMarco Nelissen <marcone@google.com>
Thu, 25 Sep 2014 21:25:18 +0000 (14:25 -0700)
committerMarco Nelissen <marcone@google.com>
Thu, 25 Sep 2014 21:26:33 +0000 (14:26 -0700)
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

media/libstagefright/codecs/aacdec/SoftAAC2.cpp

index fb27dca..e701e9e 100644 (file)
@@ -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++;
         }