Loading media/libmediaplayerservice/nuplayer/GenericSource.cpp +5 −1 Original line number Original line Diff line number Diff line Loading @@ -1005,7 +1005,9 @@ status_t NuPlayer::GenericSource::dequeueAccessUnit( status_t result = track->mPackets->dequeueAccessUnit(accessUnit); status_t result = track->mPackets->dequeueAccessUnit(accessUnit); if (!track->mPackets->hasBufferAvailable(&finalResult)) { // start pulling in more buffers if we only have one (or no) buffer left // so that decoder has less chance of being starved if (track->mPackets->getAvailableBufferCount(&finalResult) < 2) { postReadBuffer(audio? MEDIA_TRACK_TYPE_AUDIO : MEDIA_TRACK_TYPE_VIDEO); postReadBuffer(audio? MEDIA_TRACK_TYPE_AUDIO : MEDIA_TRACK_TYPE_VIDEO); } } Loading Loading @@ -1458,6 +1460,8 @@ void NuPlayer::GenericSource::readBuffer( track = &mVideoTrack; track = &mVideoTrack; if (mIsWidevine) { if (mIsWidevine) { maxBuffers = 2; maxBuffers = 2; } else { maxBuffers = 4; } } break; break; case MEDIA_TRACK_TYPE_AUDIO: case MEDIA_TRACK_TYPE_AUDIO: Loading media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +14 −0 Original line number Original line Diff line number Diff line Loading @@ -394,6 +394,20 @@ bool AnotherPacketSource::hasDataBufferAvailable(status_t *finalResult) { return false; 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) { int64_t AnotherPacketSource::getBufferedDurationUs(status_t *finalResult) { Mutex::Autolock autoLock(mLock); Mutex::Autolock autoLock(mLock); *finalResult = mEOSResult; *finalResult = mEOSResult; Loading media/libstagefright/mpeg2ts/AnotherPacketSource.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -49,6 +49,10 @@ struct AnotherPacketSource : public MediaSource { // Returns true if we have packets that's not discontinuities // Returns true if we have packets that's not discontinuities bool hasDataBufferAvailable(status_t *finalResult); 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 // Returns the difference between the last and the first queued // presentation timestamps since the last discontinuity (if any). // presentation timestamps since the last discontinuity (if any). int64_t getBufferedDurationUs(status_t *finalResult); int64_t getBufferedDurationUs(status_t *finalResult); Loading Loading
media/libmediaplayerservice/nuplayer/GenericSource.cpp +5 −1 Original line number Original line Diff line number Diff line Loading @@ -1005,7 +1005,9 @@ status_t NuPlayer::GenericSource::dequeueAccessUnit( status_t result = track->mPackets->dequeueAccessUnit(accessUnit); status_t result = track->mPackets->dequeueAccessUnit(accessUnit); if (!track->mPackets->hasBufferAvailable(&finalResult)) { // start pulling in more buffers if we only have one (or no) buffer left // so that decoder has less chance of being starved if (track->mPackets->getAvailableBufferCount(&finalResult) < 2) { postReadBuffer(audio? MEDIA_TRACK_TYPE_AUDIO : MEDIA_TRACK_TYPE_VIDEO); postReadBuffer(audio? MEDIA_TRACK_TYPE_AUDIO : MEDIA_TRACK_TYPE_VIDEO); } } Loading Loading @@ -1458,6 +1460,8 @@ void NuPlayer::GenericSource::readBuffer( track = &mVideoTrack; track = &mVideoTrack; if (mIsWidevine) { if (mIsWidevine) { maxBuffers = 2; maxBuffers = 2; } else { maxBuffers = 4; } } break; break; case MEDIA_TRACK_TYPE_AUDIO: case MEDIA_TRACK_TYPE_AUDIO: Loading
media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +14 −0 Original line number Original line Diff line number Diff line Loading @@ -394,6 +394,20 @@ bool AnotherPacketSource::hasDataBufferAvailable(status_t *finalResult) { return false; 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) { int64_t AnotherPacketSource::getBufferedDurationUs(status_t *finalResult) { Mutex::Autolock autoLock(mLock); Mutex::Autolock autoLock(mLock); *finalResult = mEOSResult; *finalResult = mEOSResult; Loading
media/libstagefright/mpeg2ts/AnotherPacketSource.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -49,6 +49,10 @@ struct AnotherPacketSource : public MediaSource { // Returns true if we have packets that's not discontinuities // Returns true if we have packets that's not discontinuities bool hasDataBufferAvailable(status_t *finalResult); 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 // Returns the difference between the last and the first queued // presentation timestamps since the last discontinuity (if any). // presentation timestamps since the last discontinuity (if any). int64_t getBufferedDurationUs(status_t *finalResult); int64_t getBufferedDurationUs(status_t *finalResult); Loading