merge in jb-mr2-release history after reset to jb-mr2-dev
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp
index 9ea3ea7..f09ce75 100644
--- a/media/libmedia/ToneGenerator.cpp
+++ b/media/libmedia/ToneGenerator.cpp
@@ -986,7 +986,7 @@
             // If the start time is valid, make sure that the number of audio samples produced
             // corresponds at least to the time between the start and stop commands.
             // This is needed in case of cold start of the output stream.
-            if ((mStartTime. tv_sec != 0) && (clock_gettime(CLOCK_MONOTONIC, &stopTime) == 0)) {
+            if ((mStartTime.tv_sec != 0) && (clock_gettime(CLOCK_MONOTONIC, &stopTime) == 0)) {
                 time_t sec = stopTime.tv_sec - mStartTime.tv_sec;
                 long nsec = stopTime.tv_nsec - mStartTime.tv_nsec;
                 long durationMs;
@@ -1000,7 +1000,7 @@
                 } else {
                     // mSamplingRate is always > 1000
                     sec = sec * 1000 + nsec / 1000000; // duration in milliseconds
-                    mMaxSmp = (sec * mSamplingRate) / 1000;
+                    mMaxSmp = (unsigned int)(((int64_t)sec * mSamplingRate) / 1000);
                 }
                 ALOGV("stopTone() forcing mMaxSmp to %d, total for far %d", mMaxSmp,  mTotalSmp);
             } else {
diff --git a/media/libmediaplayerservice/MediaPlayerFactory.cpp b/media/libmediaplayerservice/MediaPlayerFactory.cpp
index 1fb8b1a..90aed39 100644
--- a/media/libmediaplayerservice/MediaPlayerFactory.cpp
+++ b/media/libmediaplayerservice/MediaPlayerFactory.cpp
@@ -206,7 +206,8 @@
             return 0.0;
 
         if (!strncasecmp("http://", url, 7)
-                || !strncasecmp("https://", url, 8)) {
+                || !strncasecmp("https://", url, 8)
+                || !strncasecmp("file://", url, 7)) {
             size_t len = strlen(url);
             if (len >= 5 && !strcasecmp(".m3u8", &url[len - 5])) {
                 return kOurScore;
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 5387e1a..46d0a5a 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -161,7 +161,8 @@
 
 static bool IsHTTPLiveURL(const char *url) {
     if (!strncasecmp("http://", url, 7)
-            || !strncasecmp("https://", url, 8)) {
+            || !strncasecmp("https://", url, 8)
+            || !strncasecmp("file://", url, 7)) {
         size_t len = strlen(url);
         if (len >= 5 && !strcasecmp(".m3u8", &url[len - 5])) {
             return true;
@@ -833,14 +834,6 @@
 
     (*decoder)->configure(format);
 
-    int64_t durationUs;
-    if (mDriver != NULL && mSource->getDuration(&durationUs) == OK) {
-        sp<NuPlayerDriver> driver = mDriver.promote();
-        if (driver != NULL) {
-            driver->notifyDuration(durationUs);
-        }
-    }
-
     return OK;
 }
 
@@ -1271,6 +1264,14 @@
             if (driver != NULL) {
                 driver->notifyPrepareCompleted(err);
             }
+
+            int64_t durationUs;
+            if (mDriver != NULL && mSource->getDuration(&durationUs) == OK) {
+                sp<NuPlayerDriver> driver = mDriver.promote();
+                if (driver != NULL) {
+                    driver->notifyDuration(durationUs);
+                }
+            }
             break;
         }
 
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index 962b01c..505bdb3 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -631,22 +631,20 @@
             if (index < mPlaylist->size()) {
                 int32_t newSeqNumber = firstSeqNumberInPlaylist + index;
 
-                if (newSeqNumber != mSeqNumber) {
-                    ALOGI("seeking to seq no %d", newSeqNumber);
+                ALOGI("seeking to seq no %d", newSeqNumber);
 
-                    mSeqNumber = newSeqNumber;
+                mSeqNumber = newSeqNumber;
 
-                    mDataSource->reset();
+                mDataSource->reset();
 
-                    // reseting the data source will have had the
-                    // side effect of discarding any previously queued
-                    // bandwidth change discontinuity.
-                    // Therefore we'll need to treat these seek
-                    // discontinuities as involving a bandwidth change
-                    // even if they aren't directly.
-                    seekDiscontinuity = true;
-                    bandwidthChanged = true;
-                }
+                // reseting the data source will have had the
+                // side effect of discarding any previously queued
+                // bandwidth change discontinuity.
+                // Therefore we'll need to treat these seek
+                // discontinuities as involving a bandwidth change
+                // even if they aren't directly.
+                seekDiscontinuity = true;
+                bandwidthChanged = true;
             }
         }
 
diff --git a/media/libstagefright/matroska/MatroskaExtractor.cpp b/media/libstagefright/matroska/MatroskaExtractor.cpp
index 7fc7037..b304749 100644
--- a/media/libstagefright/matroska/MatroskaExtractor.cpp
+++ b/media/libstagefright/matroska/MatroskaExtractor.cpp
@@ -263,8 +263,8 @@
                     mCluster, nextCluster, pos, len);
             ALOGV("ParseNext returned %ld", res);
 
-            if (res > 0) {
-                // EOF
+            if (res != 0) {
+                // EOF or error
 
                 mCluster = NULL;
                 break;
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index 8568dfc..df87db4 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -704,7 +704,8 @@
         mData.putUInt32(info.mAssociationDesc);
         mData.putUInt32(info.mSequenceNumber);
         mData.putString(info.mName);
-        mData.putEmptyString();    // date created
+        formatDateTime(info.mDateCreated, date, sizeof(date));
+        mData.putString(date);   // date created
         formatDateTime(info.mDateModified, date, sizeof(date));
         mData.putString(date);   // date modified
         mData.putEmptyString();   // keywords