Merge "Don't report 100% buffered when the stream ends prematurely." into honeycomb

This commit is contained in:
Bryan Mawhinney
2011-01-18 11:30:30 -08:00
committed by Android (Google) Code Review
3 changed files with 15 additions and 11 deletions

View File

@@ -520,8 +520,10 @@ bool AwesomePlayer::getCachedDuration_l(int64_t *durationUs, bool *eos) {
*durationUs = mRTSPController->getQueueDurationUs(eos); *durationUs = mRTSPController->getQueueDurationUs(eos);
return true; return true;
} else if (mCachedSource != NULL && getBitrate(&bitrate)) { } else if (mCachedSource != NULL && getBitrate(&bitrate)) {
size_t cachedDataRemaining = mCachedSource->approxDataRemaining(eos); status_t finalStatus;
size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&finalStatus);
*durationUs = cachedDataRemaining * 8000000ll / bitrate; *durationUs = cachedDataRemaining * 8000000ll / bitrate;
*eos = (finalStatus != OK);
return true; return true;
} }
@@ -564,11 +566,14 @@ void AwesomePlayer::onBufferingUpdate() {
mBufferingEventPending = false; mBufferingEventPending = false;
if (mCachedSource != NULL) { if (mCachedSource != NULL) {
bool eos; status_t finalStatus;
size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&eos); size_t cachedDataRemaining = mCachedSource->approxDataRemaining(&finalStatus);
bool eos = (finalStatus != OK);
if (eos) { if (eos) {
notifyListener_l(MEDIA_BUFFERING_UPDATE, 100); if (finalStatus == ERROR_END_OF_STREAM) {
notifyListener_l(MEDIA_BUFFERING_UPDATE, 100);
}
if (mFlags & PREPARING) { if (mFlags & PREPARING) {
LOGV("cache has reached EOS, prepare is done."); LOGV("cache has reached EOS, prepare is done.");
finishAsyncPrepare_l(); finishAsyncPrepare_l();

View File

@@ -393,13 +393,13 @@ size_t NuCachedSource2::cachedSize() {
return mCacheOffset + mCache->totalSize(); return mCacheOffset + mCache->totalSize();
} }
size_t NuCachedSource2::approxDataRemaining(bool *eos) { size_t NuCachedSource2::approxDataRemaining(status_t *finalStatus) {
Mutex::Autolock autoLock(mLock); Mutex::Autolock autoLock(mLock);
return approxDataRemaining_l(eos); return approxDataRemaining_l(finalStatus);
} }
size_t NuCachedSource2::approxDataRemaining_l(bool *eos) { size_t NuCachedSource2::approxDataRemaining_l(status_t *finalStatus) {
*eos = (mFinalStatus != OK); *finalStatus = mFinalStatus;
off64_t lastBytePosCached = mCacheOffset + mCache->totalSize(); off64_t lastBytePosCached = mCacheOffset + mCache->totalSize();
if (mLastAccessPos < lastBytePosCached) { if (mLastAccessPos < lastBytePosCached) {
return lastBytePosCached - mLastAccessPos; return lastBytePosCached - mLastAccessPos;
@@ -488,4 +488,3 @@ String8 NuCachedSource2::getUri() {
return mSource->getUri(); return mSource->getUri();
} }
} // namespace android } // namespace android

View File

@@ -43,7 +43,7 @@ struct NuCachedSource2 : public DataSource {
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
size_t cachedSize(); size_t cachedSize();
size_t approxDataRemaining(bool *eos); size_t approxDataRemaining(status_t *finalStatus);
void resumeFetchingIfNecessary(); void resumeFetchingIfNecessary();
@@ -92,7 +92,7 @@ private:
ssize_t readInternal(off64_t offset, void *data, size_t size); ssize_t readInternal(off64_t offset, void *data, size_t size);
status_t seekInternal_l(off64_t offset); status_t seekInternal_l(off64_t offset);
size_t approxDataRemaining_l(bool *eos); size_t approxDataRemaining_l(status_t *finalStatus);
void restartPrefetcherIfNecessary_l(bool ignoreLowWaterThreshold = false); void restartPrefetcherIfNecessary_l(bool ignoreLowWaterThreshold = false);
DISALLOW_EVIL_CONSTRUCTORS(NuCachedSource2); DISALLOW_EVIL_CONSTRUCTORS(NuCachedSource2);