summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2011-08-31 16:44:43 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-31 16:44:43 -0700
commitafbb70b48e348410279816639eeb61f8a33064d2 (patch)
tree054523ddfbabde91bf58ebc081d8d3070fc3e5de
parent5a0a47a006008232d9962f2d8e6da8b7b79a4cdd (diff)
parentea8c9b1bd9cd416b51b0040763af501004110fe7 (diff)
downloadframeworks_base-afbb70b48e348410279816639eeb61f8a33064d2.zip
frameworks_base-afbb70b48e348410279816639eeb61f8a33064d2.tar.gz
frameworks_base-afbb70b48e348410279816639eeb61f8a33064d2.tar.bz2
Merge "Discontinuities are only signalled on streams that have been identified, i.e."
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp13
-rw-r--r--media/libstagefright/mpeg2ts/ATSParser.cpp45
2 files changed, 26 insertions, 32 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 1f08a91..ee77f47 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -663,6 +663,19 @@ void NuPlayer::renderBuffer(bool audio, const sp<AMessage> &msg) {
sp<AMessage> reply;
CHECK(msg->findMessage("reply", &reply));
+ if (IsFlushingState(audio ? mFlushingAudio : mFlushingVideo)) {
+ // We're currently attempting to flush the decoder, in order
+ // to complete this, the decoder wants all its buffers back,
+ // so we don't want any output buffers it sent us (from before
+ // we initiated the flush) to be stuck in the renderer's queue.
+
+ LOGV("we're still flushing the %s decoder, sending its output buffer"
+ " right back.", audio ? "audio" : "video");
+
+ reply->post();
+ return;
+ }
+
sp<RefBase> obj;
CHECK(msg->findObject("buffer", &obj));
diff --git a/media/libstagefright/mpeg2ts/ATSParser.cpp b/media/libstagefright/mpeg2ts/ATSParser.cpp
index 74a3b32..0b7dc3d 100644
--- a/media/libstagefright/mpeg2ts/ATSParser.cpp
+++ b/media/libstagefright/mpeg2ts/ATSParser.cpp
@@ -111,8 +111,6 @@ private:
sp<ABuffer> mBuffer;
sp<AnotherPacketSource> mSource;
bool mPayloadStarted;
- DiscontinuityType mPendingDiscontinuity;
- sp<AMessage> mPendingDiscontinuityExtra;
ElementaryStreamQueue *mQueue;
@@ -125,9 +123,6 @@ private:
void extractAACFrames(const sp<ABuffer> &buffer);
- void deferDiscontinuity(
- DiscontinuityType type, const sp<AMessage> &extra);
-
DISALLOW_EVIL_CONSTRUCTORS(Stream);
};
@@ -347,12 +342,8 @@ ATSParser::Stream::Stream(
: mProgram(program),
mElementaryPID(elementaryPID),
mStreamType(streamType),
- mBuffer(new ABuffer(192 * 1024)),
mPayloadStarted(false),
- mPendingDiscontinuity(DISCONTINUITY_NONE),
mQueue(NULL) {
- mBuffer->setRange(0, 0);
-
switch (mStreamType) {
case STREAMTYPE_H264:
mQueue = new ElementaryStreamQueue(ElementaryStreamQueue::H264);
@@ -382,6 +373,11 @@ ATSParser::Stream::Stream(
}
LOGV("new stream PID 0x%02x, type 0x%02x", elementaryPID, streamType);
+
+ if (mQueue != NULL) {
+ mBuffer = new ABuffer(192 * 1024);
+ mBuffer->setRange(0, 0);
+ }
}
ATSParser::Stream::~Stream() {
@@ -391,6 +387,10 @@ ATSParser::Stream::~Stream() {
void ATSParser::Stream::parse(
unsigned payload_unit_start_indicator, ABitReader *br) {
+ if (mQueue == NULL) {
+ return;
+ }
+
if (payload_unit_start_indicator) {
if (mPayloadStarted) {
// Otherwise we run the danger of receiving the trailing bytes
@@ -429,6 +429,10 @@ void ATSParser::Stream::parse(
void ATSParser::Stream::signalDiscontinuity(
DiscontinuityType type, const sp<AMessage> &extra) {
+ if (mQueue == NULL) {
+ return;
+ }
+
mPayloadStarted = false;
mBuffer->setRange(0, 0);
@@ -453,8 +457,6 @@ void ATSParser::Stream::signalDiscontinuity(
if (mSource != NULL) {
mSource->queueDiscontinuity(type, extra);
- } else {
- deferDiscontinuity(type, extra);
}
break;
}
@@ -465,15 +467,6 @@ void ATSParser::Stream::signalDiscontinuity(
}
}
-void ATSParser::Stream::deferDiscontinuity(
- DiscontinuityType type, const sp<AMessage> &extra) {
- if (type > mPendingDiscontinuity) {
- // Only upgrade discontinuities.
- mPendingDiscontinuity = type;
- mPendingDiscontinuityExtra = extra;
- }
-}
-
void ATSParser::Stream::signalEOS(status_t finalResult) {
if (mSource != NULL) {
mSource->signalEOS(finalResult);
@@ -658,10 +651,6 @@ void ATSParser::Stream::onPayloadData(
const uint8_t *data, size_t size) {
LOGV("onPayloadData mStreamType=0x%02x", mStreamType);
- if (mQueue == NULL) {
- return;
- }
-
CHECK(PTS_DTS_flags == 2 || PTS_DTS_flags == 3);
int64_t timeUs = mProgram->convertPTSToTimestamp(PTS);
@@ -681,14 +670,6 @@ void ATSParser::Stream::onPayloadData(
mElementaryPID, mStreamType);
mSource = new AnotherPacketSource(meta);
-
- if (mPendingDiscontinuity != DISCONTINUITY_NONE) {
- mSource->queueDiscontinuity(
- mPendingDiscontinuity, mPendingDiscontinuityExtra);
- mPendingDiscontinuity = DISCONTINUITY_NONE;
- mPendingDiscontinuityExtra.clear();
- }
-
mSource->queueAccessUnit(accessUnit);
}
} else if (mQueue->getFormat() != NULL) {