NuPlayer: Fix failure to stop audio playback

Don't stop audio sink if gapless - it's not necessary and has
a side effect of resetting the AudioTrack frames written
without resetting the AudioSink frames written.

Bug: 18787619
Change-Id: I71063b9e3aad9a6dfd7d46ea614e107c815e4c57
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
index 21b74ee..d6a828b 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
@@ -638,10 +638,13 @@
 
             mAudioQueue.erase(mAudioQueue.begin());
             entry = NULL;
-            // Need to stop the track here, because that will play out the last
-            // little bit at the end of the file. Otherwise short files won't play.
-            mAudioSink->stop();
-            mNumFramesWritten = 0;
+            if (mAudioSink->needsTrailingPadding()) {
+                // If we're not in gapless playback (i.e. through setNextPlayer), we
+                // need to stop the track here, because that will play out the last
+                // little bit at the end of the file. Otherwise short files won't play.
+                mAudioSink->stop();
+                mNumFramesWritten = 0;
+            }
             return false;
         }