Report WOULD_BLOCK if buffer is non-empty instead of ERROR_IO
Bug: 17423087 Change-Id: I4b1c5ead919649be3b820f63a030acac729fb06e
This commit is contained in:
committed by
Lajos Molnar
parent
138160ddea
commit
e82044e05d
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user