Merge "MediaCodec: handle errors during flushing." into lmp-dev
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 814adab..76f730f 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -722,7 +722,7 @@
                         mFlags |= kFlagSawMediaServerDie;
                     }
 
-                    bool sendErrorReponse = true;
+                    bool sendErrorResponse = true;
 
                     switch (mState) {
                         case INITIALIZING:
@@ -749,7 +749,7 @@
                             // Ignore the error, assuming we'll still get
                             // the shutdown complete notification.
 
-                            sendErrorReponse = false;
+                            sendErrorResponse = false;
 
                             if (mFlags & kFlagSawMediaServerDie) {
                                 // MediaServer died, there definitely won't
@@ -780,7 +780,7 @@
                         case FLUSHED:
                         case STARTED:
                         {
-                            sendErrorReponse = false;
+                            sendErrorResponse = false;
 
                             setStickyError(err);
                             postActivityNotificationIfPossible();
@@ -805,7 +805,7 @@
 
                         default:
                         {
-                            sendErrorReponse = false;
+                            sendErrorResponse = false;
 
                             setStickyError(err);
                             postActivityNotificationIfPossible();
@@ -831,7 +831,7 @@
                         }
                     }
 
-                    if (sendErrorReponse) {
+                    if (sendErrorResponse) {
                         PostReplyWithError(mReplyID, err);
                     }
                     break;
@@ -1118,7 +1118,11 @@
 
                 case CodecBase::kWhatFlushCompleted:
                 {
-                    CHECK_EQ(mState, FLUSHING);
+                    if (mState != FLUSHING) {
+                        ALOGW("received FlushCompleted message in state %d",
+                                mState);
+                        break;
+                    }
 
                     if (mFlags & kFlagIsAsync) {
                         setState(FLUSHED);