From fcf044a9c5624395d24eb6181e67163ce169458b Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Tue, 14 Jul 2015 15:58:51 -0700 Subject: NuPlayer: pull more video buffers in advance in GenericSource pull 4 video buffers at a time, and start pulling when we're down to 1 buffers to avoid starving the decoder. bug: 22320866 Change-Id: I10914dc092f3830ecb6296e2d9ebf9064ff7a5dc --- media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 14 ++++++++++++++ media/libstagefright/mpeg2ts/AnotherPacketSource.h | 4 ++++ 2 files changed, 18 insertions(+) (limited to 'media/libstagefright/mpeg2ts') diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index 0878a1b..cabde32 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -394,6 +394,20 @@ bool AnotherPacketSource::hasDataBufferAvailable(status_t *finalResult) { return false; } +size_t AnotherPacketSource::getAvailableBufferCount(status_t *finalResult) { + Mutex::Autolock autoLock(mLock); + + *finalResult = OK; + if (!mEnabled) { + return 0; + } + if (!mBuffers.empty()) { + return mBuffers.size(); + } + *finalResult = mEOSResult; + return 0; +} + int64_t AnotherPacketSource::getBufferedDurationUs(status_t *finalResult) { Mutex::Autolock autoLock(mLock); *finalResult = mEOSResult; diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.h b/media/libstagefright/mpeg2ts/AnotherPacketSource.h index eb9dc9b..28a0e89 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.h +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.h @@ -49,6 +49,10 @@ struct AnotherPacketSource : public MediaSource { // Returns true if we have packets that's not discontinuities bool hasDataBufferAvailable(status_t *finalResult); + // Returns the number of available buffers. finalResult is always OK + // if this method returns non-0, or the final result if it returns 0. + size_t getAvailableBufferCount(status_t *finalResult); + // Returns the difference between the last and the first queued // presentation timestamps since the last discontinuity (if any). int64_t getBufferedDurationUs(status_t *finalResult); -- cgit v1.1