Merge "NuPlayer: reports paused position in paused state." into lmp-mr1-dev
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
index 08c49f2..2ea6d70 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
@@ -676,10 +676,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;
}
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index d922dc0..2eb7e5c 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -999,6 +999,9 @@
int64_t duration;
int32_t samplerate;
+ if (!mLastTrack) {
+ return ERROR_MALFORMED;
+ }
if (mLastTrack->meta->findInt64(kKeyDuration, &duration) &&
mLastTrack->meta->findInt32(kKeySampleRate, &samplerate)) {
diff --git a/media/libstagefright/OggExtractor.cpp b/media/libstagefright/OggExtractor.cpp
index 6219053..b8868aa 100644
--- a/media/libstagefright/OggExtractor.cpp
+++ b/media/libstagefright/OggExtractor.cpp
@@ -76,7 +76,7 @@
status_t seekToTime(int64_t timeUs);
status_t seekToOffset(off64_t offset);
- status_t readNextPacket(MediaBuffer **buffer);
+ status_t readNextPacket(MediaBuffer **buffer, bool conf);
status_t init();
@@ -185,7 +185,7 @@
}
MediaBuffer *packet;
- status_t err = mExtractor->mImpl->readNextPacket(&packet);
+ status_t err = mExtractor->mImpl->readNextPacket(&packet, /* conf = */ false);
if (err != OK) {
return err;
@@ -457,7 +457,7 @@
return sizeof(header) + page->mNumSegments + totalSize;
}
-status_t MyVorbisExtractor::readNextPacket(MediaBuffer **out) {
+status_t MyVorbisExtractor::readNextPacket(MediaBuffer **out, bool conf) {
*out = NULL;
MediaBuffer *buffer = NULL;
@@ -523,10 +523,8 @@
mFirstPacketInPage = false;
}
- if (mVi.rate) {
- // Rate may not have been initialized yet if we're currently
- // reading the configuration packets...
- // Fortunately, the timestamp doesn't matter for those.
+ // ignore timestamp for configuration packets
+ if (!conf) {
int32_t curBlockSize = packetBlockSize(buffer);
if (mCurrentPage.mPrevPacketSize < 0) {
mCurrentPage.mPrevPacketSize = curBlockSize;
@@ -605,7 +603,7 @@
MediaBuffer *packet;
status_t err;
- if ((err = readNextPacket(&packet)) != OK) {
+ if ((err = readNextPacket(&packet, /* conf = */ true)) != OK) {
return err;
}
ALOGV("read packet of size %zu\n", packet->range_length());
@@ -616,7 +614,7 @@
return err;
}
- if ((err = readNextPacket(&packet)) != OK) {
+ if ((err = readNextPacket(&packet, /* conf = */ true)) != OK) {
return err;
}
ALOGV("read packet of size %zu\n", packet->range_length());
@@ -627,7 +625,7 @@
return err;
}
- if ((err = readNextPacket(&packet)) != OK) {
+ if ((err = readNextPacket(&packet, /* conf = */ true)) != OK) {
return err;
}
ALOGV("read packet of size %zu\n", packet->range_length());