am 9ec965e4: am b78599b7: Merge change Ia67d5388 into eclair-mr2

Merge commit '9ec965e4fb242c9c570e43980425b8f275eb2159'

* commit '9ec965e4fb242c9c570e43980425b8f275eb2159':
  remote destructors are not synchronously executed by the binder...
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index a7a0a12..973815b 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -20,6 +20,7 @@
 
 #include "include/AwesomePlayer.h"
 
+#include <binder/IPCThreadState.h>
 #include <media/stagefright/AudioPlayer.h>
 #include <media/stagefright/DataSource.h>
 #include <media/stagefright/FileSource.h>
@@ -313,6 +314,12 @@
         CHECK(meta->findInt32(kKeyWidth, &decodedWidth));
         CHECK(meta->findInt32(kKeyHeight, &decodedHeight));
 
+        mVideoRenderer.clear();
+
+        // Must ensure that mVideoRenderer's destructor is actually executed
+        // before creating a new one.
+        IPCThreadState::self()->flushCommands();
+
         mVideoRenderer =
             mClient.interface()->createRenderer(
                     mISurface, component,
@@ -530,6 +537,12 @@
                 return;
             }
 
+            if (mVideoBuffer->range_length() == 0) {
+                mVideoBuffer->release();
+                mVideoBuffer = NULL;
+                continue;
+            }
+
             break;
         }
     }