Merge "Report WOULD_BLOCK if buffer is non-empty instead of ERROR_IO" into lmp-dev

automerge: 30e4ba6

* commit '30e4ba61bd8be252ce1f1ab72b5875cbbaa75305':
  Report WOULD_BLOCK if buffer is non-empty instead of ERROR_IO
This commit is contained in:
Jeff Tinker
2014-10-05 03:15:06 +00:00
committed by android-build-merger

View File

@@ -202,21 +202,13 @@ std::string usecToNPT(int64_t time)
status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
{
Mutex::Autolock autoLock(mLock);
//ALOGD("WVMMediaSource::read %s", (mESSelector == WV_EsSelector_Video) ? "video" : "audio");
CHECK(mStarted);
*buffer = NULL;
bool seekNextSync = false;
#if 0
// The sync bits aren't working right yet on live streams, so need to disable this
// for now.
if (mIsLiveStream && mNewSegment && (mESSelector == WV_EsSelector_Video)) {
seekNextSync = true;
mNewSegment = false;
}
#endif
int64_t seekTimeUs;
int retryLimit = 500; // Limit on number of retries before timeout, 10ms per retry
@@ -340,6 +332,21 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
// If no data received within the retry limit, return ERROR_IO
// This prevents the player from becoming unresponsive
mediaBuf->release();
float secondsBuffered = 0.0;
unsigned long bandwidth = 0;
WV_Info_TimeBuffered(mSession, &secondsBuffered);
WV_Info_CurrentBandwidth(mSession, &bandwidth);
ALOGI("Retry count exhausted: secondsBuffered=%5.2f, bandwidth=%ld",
secondsBuffered, bandwidth);
if (secondsBuffered > 2.0) {
// If there's some data buffered but no packets are for
// this track, the buffer may be full of data for another track
// with no room to demux in more packets. Return the non-blocking
// result in this case.
return WOULD_BLOCK;
}
return ERROR_IO;
} else {
// Didn't get anything, sleep a bit so we don't hog the CPU then try again