Merge "I accidentally broken passion encoding while working around problems with the sholes encoder." into kraken
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp
index 76a9715..b50d4d2 100644
--- a/camera/CameraParameters.cpp
+++ b/camera/CameraParameters.cpp
@@ -122,6 +122,7 @@
 const char CameraParameters::SCENE_MODE_SPORTS[] = "sports";
 const char CameraParameters::SCENE_MODE_PARTY[] = "party";
 const char CameraParameters::SCENE_MODE_CANDLELIGHT[] = "candlelight";
+const char CameraParameters::SCENE_MODE_BARCODE[] = "barcode";
 
 // Formats for setPreviewFormat and setPictureFormat.
 const char CameraParameters::PIXEL_FORMAT_YUV422SP[] = "yuv422sp";
@@ -135,6 +136,7 @@
 const char CameraParameters::FOCUS_MODE_INFINITY[] = "infinity";
 const char CameraParameters::FOCUS_MODE_MACRO[] = "macro";
 const char CameraParameters::FOCUS_MODE_FIXED[] = "fixed";
+const char CameraParameters::FOCUS_MODE_EDOF[] = "edof";
 
 CameraParameters::CameraParameters()
                 : mMap()
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index a7568d7..3b0e9e5 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -289,6 +289,9 @@
     static const char SCENE_MODE_SPORTS[];
     static const char SCENE_MODE_PARTY[];
     static const char SCENE_MODE_CANDLELIGHT[];
+    // Applications are looking for a barcode. Camera driver will be optimized
+    // for barcode reading.
+    static const char SCENE_MODE_BARCODE[];
 
     // Formats for setPreviewFormat and setPictureFormat.
     static const char PIXEL_FORMAT_YUV422SP[];
@@ -309,6 +312,10 @@
     // focus, which is usually at hyperfocal distance. Applications should
     // not call CameraHardwareInterface.autoFocus in this mode.
     static const char FOCUS_MODE_FIXED[];
+    // Extended depth of field (EDOF). Focusing is done digitally and
+    // continuously. Applications should not call
+    // CameraHardwareInterface.autoFocus in this mode.
+    static const char FOCUS_MODE_EDOF[];
 
 private:
     DefaultKeyedVector<String8,String8>    mMap;
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 63dfa67..c1987dc 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -444,6 +444,8 @@
         notifyListener_l(MEDIA_BUFFERING_UPDATE, percentage * 100.0);
 
         postBufferingEvent_l();
+    } else {
+        LOGE("Not sending buffering status because duration is unknown.");
     }
 }
 
@@ -552,8 +554,6 @@
         seekAudioIfNecessary_l();
     }
 
-    postBufferingEvent_l();
-
     if (mFlags & AT_EOS) {
         // Legacy behaviour, if a stream finishes playing and then
         // is started again, we play from the start...
@@ -1225,6 +1225,8 @@
     mFlags |= PREPARED;
     mAsyncPrepareEvent = NULL;
     mPreparedCondition.broadcast();
+
+    postBufferingEvent_l();
 }
 
 status_t AwesomePlayer::suspend() {
diff --git a/media/libstagefright/codecs/aacdec/AACDecoder.cpp b/media/libstagefright/codecs/aacdec/AACDecoder.cpp
index 2ed8ef1..ae23691 100644
--- a/media/libstagefright/codecs/aacdec/AACDecoder.cpp
+++ b/media/libstagefright/codecs/aacdec/AACDecoder.cpp
@@ -203,25 +203,32 @@
 
     Int decoderErr = PVMP4AudioDecodeFrame(mConfig, mDecoderBuf);
 
+    size_t numOutBytes =
+        mConfig->frameLength * sizeof(int16_t) * mConfig->desiredChannels;
+
     if (decoderErr != MP4AUDEC_SUCCESS) {
-        LOGE("AAC decoder returned error %d", decoderErr);
+        LOGW("AAC decoder returned error %d, substituting silence", decoderErr);
 
-        buffer->release();
-        buffer = NULL;
+        memset(buffer->data(), 0, numOutBytes);
 
-        return ERROR_MALFORMED;
-    }
-
-    buffer->set_range(
-            0, mConfig->frameLength * sizeof(int16_t) * mConfig->desiredChannels);
-
-    mInputBuffer->set_range(
-            mInputBuffer->range_offset() + mConfig->inputBufferUsedLength,
-            mInputBuffer->range_length() - mConfig->inputBufferUsedLength);
-
-    if (mInputBuffer->range_length() == 0) {
+        // Discard input buffer.
         mInputBuffer->release();
         mInputBuffer = NULL;
+
+        // fall through
+    }
+
+    buffer->set_range(0, numOutBytes);
+
+    if (mInputBuffer != NULL) {
+        mInputBuffer->set_range(
+                mInputBuffer->range_offset() + mConfig->inputBufferUsedLength,
+                mInputBuffer->range_length() - mConfig->inputBufferUsedLength);
+
+        if (mInputBuffer->range_length() == 0) {
+            mInputBuffer->release();
+            mInputBuffer = NULL;
+        }
     }
 
     buffer->meta_data()->setInt64(