Merge "widevine: return -EAGAIN sooner in non-blocking mode" into lmp-mr1-dev
This commit is contained in:
@@ -208,6 +208,7 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
|
||||
*buffer = NULL;
|
||||
bool seekNextSync = false;
|
||||
bool seeking = false;
|
||||
|
||||
int64_t seekTimeUs;
|
||||
|
||||
@@ -215,6 +216,7 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
|
||||
ReadOptions::SeekMode mode;
|
||||
if (options != NULL && options->getSeekTo(&seekTimeUs, &mode)) {
|
||||
seeking = true;
|
||||
|
||||
// When doing a seek, use a longer timeout since we need to set up a new connection
|
||||
retryLimit = 1500;
|
||||
@@ -251,9 +253,9 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
}
|
||||
|
||||
MediaBuffer *mediaBuf = NULL;
|
||||
bool nonBlocking = (options != NULL && options->getNonBlocking());
|
||||
|
||||
status_t err = mGroup->acquire_buffer(
|
||||
&mediaBuf, options != NULL && options->getNonBlocking());
|
||||
status_t err = mGroup->acquire_buffer(&mediaBuf, nonBlocking);
|
||||
|
||||
if (err != OK) {
|
||||
CHECK(mediaBuf == NULL);
|
||||
@@ -328,17 +330,20 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
#endif
|
||||
|
||||
if (bytesRead == 0) {
|
||||
if (retryCount++ >= retryLimit) {
|
||||
float secondsBuffered = 0.0;
|
||||
WV_Info_TimeBuffered(mSession, &secondsBuffered);
|
||||
if (retryCount++ >= retryLimit
|
||||
|| (secondsBuffered > 2.0 && nonBlocking && !seeking)) {
|
||||
// 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 (retryCount > retryLimit) {
|
||||
unsigned long bandwidth = 0;
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user