Merge "Camera1 shim: If there's no flash, the keys need to be null." into lmp-dev
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index ef4abd4..ca596fd 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -559,7 +559,7 @@
                         static_cast<NativeWindowWrapper *>(obj.get())));
 
             if (obj != NULL) {
-                if (mStarted && mVideoDecoder != NULL) {
+                if (mStarted && mSource->getFormat(false /* audio */) != NULL) {
                     // Issue a seek to refresh the video screen only if started otherwise
                     // the extractor may not yet be started and will assert.
                     // If the video decoder is not set (perhaps audio only in this case)
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
index fb27dca..e701e9e 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
+++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
@@ -974,11 +974,15 @@
         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++;
         }