diff options
author | Andreas Huber <andih@google.com> | 2011-08-25 12:21:26 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2011-08-25 13:37:34 -0700 |
commit | 9a442c1b9a051edc6d4ceb0daad2d0a8433e7b0b (patch) | |
tree | d64a141b01e4355335e755174b9cb30997f35d3a /media/libstagefright/mpeg2ts | |
parent | 934d865a807e149b97d11b54c674d421b51bbe8a (diff) | |
download | frameworks_av-9a442c1b9a051edc6d4ceb0daad2d0a8433e7b0b.zip frameworks_av-9a442c1b9a051edc6d4ceb0daad2d0a8433e7b0b.tar.gz frameworks_av-9a442c1b9a051edc6d4ceb0daad2d0a8433e7b0b.tar.bz2 |
When encountering a discontinuity, flush(clear) all content enqueued up to that
point except previously enqueued discontinuities.
Change-Id: Id04a559dc062fa4a5c80c599ad74bf81a543de01
related-to-bug: 5201378
Diffstat (limited to 'media/libstagefright/mpeg2ts')
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
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<ABuffer> &buffer) { void AnotherPacketSource::queueDiscontinuity( ATSParser::DiscontinuityType type, const sp<AMessage> &extra) { - sp<ABuffer> buffer = new ABuffer(0); - buffer->meta()->setInt32("discontinuity", static_cast<int32_t>(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<sp<ABuffer> >::iterator it = mBuffers.begin(); + while (it != mBuffers.end()) { + sp<ABuffer> 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<ABuffer> buffer = new ABuffer(0); + buffer->meta()->setInt32("discontinuity", static_cast<int32_t>(type)); + buffer->meta()->setMessage("extra", extra); mBuffers.push_back(buffer); mCondition.signal(); |