The audio track was accidentally not participating in the prefetch since it wasn't started at the time prepare() was called. Also, properly report the cached duration even near the end when the source has no more data to fetch.

Change-Id: I66a92fec24c9bfb25f1c186f1c877127bae2b4f9
related-to-bug: 2444425
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index b8a50bf..e00ba470 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -410,6 +410,9 @@
 
     if (mDurationUs >= 0) {
         int64_t cachedDurationUs = mPrefetcher->getCachedDurationUs();
+
+        LOGV("cache holds %.2f secs worth of data.", cachedDurationUs / 1E6);
+
         int64_t positionUs = 0;
         if (mVideoSource != NULL) {
             positionUs = mVideoTimeUs;
@@ -486,7 +489,11 @@
             if (mAudioSink != NULL) {
                 mAudioPlayer = new AudioPlayer(mAudioSink);
                 mAudioPlayer->setSource(mAudioSource);
-                status_t err = mAudioPlayer->start();
+
+                // We've already started the MediaSource in order to enable
+                // the prefetcher to read its data.
+                status_t err = mAudioPlayer->start(
+                        true /* sourceAlreadyStarted */);
 
                 if (err != OK) {
                     delete mAudioPlayer;
@@ -734,6 +741,8 @@
         }
     }
 
+    mAudioSource->start();
+
     return mAudioSource != NULL ? OK : UNKNOWN_ERROR;
 }