From 9a442c1b9a051edc6d4ceb0daad2d0a8433e7b0b Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 25 Aug 2011 12:21:26 -0700 Subject: When encountering a discontinuity, flush(clear) all content enqueued up to that point except previously enqueued discontinuities. Change-Id: Id04a559dc062fa4a5c80c599ad74bf81a543de01 related-to-bug: 5201378 --- .../libstagefright/mpeg2ts/AnotherPacketSource.cpp | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'media/libstagefright/mpeg2ts') diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index 2e66a2c..ce07e32 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -136,24 +136,28 @@ void AnotherPacketSource::queueAccessUnit(const sp &buffer) { void AnotherPacketSource::queueDiscontinuity( ATSParser::DiscontinuityType type, const sp &extra) { - sp buffer = new ABuffer(0); - buffer->meta()->setInt32("discontinuity", static_cast(type)); - buffer->meta()->setMessage("extra", extra); - Mutex::Autolock autoLock(mLock); -#if 0 - if (type == ATSParser::DISCONTINUITY_SEEK - || type == ATSParser::DISCONTINUITY_FORMATCHANGE) { - // XXX Fix this: This will also clear any pending discontinuities, - // If there's a pending DISCONTINUITY_FORMATCHANGE and the new - // discontinuity is "just" a DISCONTINUITY_SEEK, this will effectively - // downgrade the type of discontinuity received by the client. + // Leave only discontinuities in the queue. + List >::iterator it = mBuffers.begin(); + while (it != mBuffers.end()) { + sp oldBuffer = *it; + + int32_t oldDiscontinuityType; + if (!oldBuffer->meta()->findInt32( + "discontinuity", &oldDiscontinuityType)) { + it = mBuffers.erase(it); + continue; + } - mBuffers.clear(); - mEOSResult = OK; + ++it; } -#endif + + mEOSResult = OK; + + sp buffer = new ABuffer(0); + buffer->meta()->setInt32("discontinuity", static_cast(type)); + buffer->meta()->setMessage("extra", extra); mBuffers.push_back(buffer); mCondition.signal(); -- cgit v1.1