NuPlayer: don't restart AudioSink when torn down due to pause timeout.

Bug: 17752358
Change-Id: I232d105480139bfc0b991bcd8e001930e577cf30
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index ca596fd..ea60c06 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -941,6 +941,8 @@
                 ALOGV("Tear down audio offload, fall back to s/w path");
                 int64_t positionUs;
                 CHECK(msg->findInt64("positionUs", &positionUs));
+                int32_t reason;
+                CHECK(msg->findInt32("reason", &reason));
                 closeAudioSink();
                 mAudioDecoder.clear();
                 ++mAudioDecoderGeneration;
@@ -952,7 +954,9 @@
                 mOffloadAudio = false;
 
                 performSeek(positionUs, false /* needNotify */);
-                instantiateDecoder(true /* audio */, &mAudioDecoder);
+                if (reason == Renderer::kDueToError) {
+                    instantiateDecoder(true /* audio */, &mAudioDecoder);
+                }
             }
             break;
         }
@@ -1019,6 +1023,11 @@
             } else {
                 ALOGW("resume called when source is gone or not set");
             }
+            // |mAudioDecoder| may have been released due to the pause timeout, so try to re-create
+            // it if needed.
+            if (mFlushingAudio != SHUT_DOWN) {
+                instantiateDecoder(true /* audio */, &mAudioDecoder);
+            }
             if (mRenderer != NULL) {
                 mRenderer->resume();
             } else {