merge in klp-factoryrom-release history after reset to klp-release
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 5c3abd0..2e55c4f 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -2366,10 +2366,6 @@
 
     while (countBuffersOwnedByNativeWindow() > (size_t)minUndequeuedBufs
             && dequeueBufferFromNativeWindow() != NULL) {
-        // these buffers will be submitted as regular buffers; account for this
-        if (mStoreMetaDataInOutputBuffers && mMetaDataBuffersToSubmit > 0) {
-            --mMetaDataBuffersToSubmit;
-        }
     }
 }
 
@@ -4004,9 +4000,10 @@
 }
 
 void ACodec::ExecutingState::submitOutputBuffers() {
-    submitRegularOutputBuffers();
     if (mCodec->mStoreMetaDataInOutputBuffers) {
         submitOutputMetaBuffers();
+    } else {
+        submitRegularOutputBuffers();
     }
 }
 
diff --git a/services/audioflinger/PlaybackTracks.h b/services/audioflinger/PlaybackTracks.h
index f7ad6b1..0308b99 100644
--- a/services/audioflinger/PlaybackTracks.h
+++ b/services/audioflinger/PlaybackTracks.h
@@ -117,10 +117,7 @@
     enum {FS_INVALID, FS_FILLING, FS_FILLED, FS_ACTIVE};
     mutable uint8_t     mFillingUpStatus;
     int8_t              mRetryCount;
-
-    // see comment at AudioFlinger::PlaybackThread::Track::~Track for why this can't be const
-    sp<IMemory>         mSharedBuffer;
-
+    const sp<IMemory>   mSharedBuffer;
     bool                mResetDone;
     const audio_stream_type_t mStreamType;
     int                 mName;      // track name on the normal mixer,
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 3a5dc35..821e4a5 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -364,16 +364,6 @@
 AudioFlinger::PlaybackThread::Track::~Track()
 {
     ALOGV("PlaybackThread::Track destructor");
-
-    // The destructor would clear mSharedBuffer,
-    // but it will not push the decremented reference count,
-    // leaving the client's IMemory dangling indefinitely.
-    // This prevents that leak.
-    if (mSharedBuffer != 0) {
-        mSharedBuffer.clear();
-        // flush the binder command buffer
-        IPCThreadState::self()->flushCommands();
-    }
 }
 
 void AudioFlinger::PlaybackThread::Track::destroy()