Squashed commit of the following:

commit 63be8ceb8b2354fb997a277c0092abae015ecf10
Author: Andreas Huber <andih@google.com>
Date:   Fri Dec 17 13:45:34 2010 -0800

    Enable handling of discontinuities that involve potential format changes.

    Change-Id: I21848a113db8764abb54bdcf302b0923253eaf4d

commit d18a7f80ec09af382026809263dcbbfa9e7a9ec8
Author: Andreas Huber <andih@google.com>
Date:   Fri Dec 17 13:45:01 2010 -0800

    Signal whether or not a format change occured as part of the discontinuity.

    Change-Id: I06e64f542f4369549c9cebbb892dc612346ae43d

commit c400adbd5fdbd65cfef7aed9ec65bcaace4bb69b
Author: Andreas Huber <andih@google.com>
Date:   Fri Dec 17 13:44:46 2010 -0800

    A little more instrumentation of ACodec

    Change-Id: I07f4aeccbbd15cdd9f80f48c3f92ee984ef6d92b

commit 1d802ee01f47b3cdc5b89502cec7fbb595e197a3
Author: Andreas Huber <andih@google.com>
Date:   Fri Dec 17 13:43:58 2010 -0800

    Only sync audio/video queues if both types of media are actually present.

    Change-Id: Ic88edf9bb1ebd4034c08747cce9877a4e28e0d35

commit e402da39d9a4d8b75653a78f728e20a3ef0fb497
Author: Andreas Huber <andih@google.com>
Date:   Fri Dec 17 13:42:24 2010 -0800

    Disable the random seek for now.

    Change-Id: Iddd597b546e2f229e88214f9bdd6452bb188105e

Change-Id: I27c4d9ba916080be94ce6117dbb095e9022ed62b
diff --git a/media/libmediaplayerservice/nuplayer/DecoderWrapper.cpp b/media/libmediaplayerservice/nuplayer/DecoderWrapper.cpp
index 9738e33..4d4cd8d 100644
--- a/media/libmediaplayerservice/nuplayer/DecoderWrapper.cpp
+++ b/media/libmediaplayerservice/nuplayer/DecoderWrapper.cpp
@@ -151,6 +151,7 @@
             const sp<AMessage> &notify);
 
     void start();
+    void stop();
     void readMore(bool flush = false);
 
 protected:
@@ -189,6 +190,10 @@
     readMore();
 }
 
+void DecoderWrapper::WrapperReader::stop() {
+    CHECK_EQ(mDecoder->stop(), (status_t)OK);
+}
+
 void DecoderWrapper::WrapperReader::readMore(bool flush) {
     if (!flush && mEOS) {
         return;
@@ -351,6 +356,10 @@
             onSetup(msg);
             break;
 
+        case kWhatShutdown:
+            onShutdown();
+            break;
+
         case kWhatInputDataRequested:
         {
             postFillBuffer();
@@ -493,6 +502,25 @@
     ++mNumPendingDecodes;
 }
 
+void DecoderWrapper::onShutdown() {
+    mReaderLooper->stop();
+    mReaderLooper.clear();
+
+    mReader->stop();
+    mReader.clear();
+
+    mSource.clear();
+
+    mNumOutstandingInputBuffers = 0;
+    mNumOutstandingOutputBuffers = 0;
+    mNumPendingDecodes = 0;
+    mFlushing = false;
+
+    sp<AMessage> notify = mNotify->dup();
+    notify->setInt32("what", ACodec::kWhatShutdownCompleted);
+    notify->post();
+}
+
 void DecoderWrapper::postFillBuffer() {
     sp<AMessage> notify = mNotify->dup();
     notify->setInt32("what", ACodec::kWhatFillThisBuffer);