am 4e600be6: am 0c752509: Merge "widevine: return -EAGAIN sooner in non-blocking mode" into lmp-mr1-dev

* commit '4e600be65ab68461633ccd59915635984aaee32b':
  widevine: return -EAGAIN sooner in non-blocking mode
This commit is contained in:
Chong Zhang
2014-12-09 23:03:34 +00:00
committed by Android Git Automerger

View File

@@ -208,6 +208,7 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
*buffer = NULL; *buffer = NULL;
bool seekNextSync = false; bool seekNextSync = false;
bool seeking = false;
int64_t seekTimeUs; int64_t seekTimeUs;
@@ -215,6 +216,7 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
ReadOptions::SeekMode mode; ReadOptions::SeekMode mode;
if (options != NULL && options->getSeekTo(&seekTimeUs, &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 // When doing a seek, use a longer timeout since we need to set up a new connection
retryLimit = 1500; retryLimit = 1500;
@@ -251,9 +253,9 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
} }
MediaBuffer *mediaBuf = NULL; MediaBuffer *mediaBuf = NULL;
bool nonBlocking = (options != NULL && options->getNonBlocking());
status_t err = mGroup->acquire_buffer( status_t err = mGroup->acquire_buffer(&mediaBuf, nonBlocking);
&mediaBuf, options != NULL && options->getNonBlocking());
if (err != OK) { if (err != OK) {
CHECK(mediaBuf == NULL); CHECK(mediaBuf == NULL);
@@ -328,17 +330,20 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
#endif #endif
if (bytesRead == 0) { 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 // If no data received within the retry limit, return ERROR_IO
// This prevents the player from becoming unresponsive // This prevents the player from becoming unresponsive
mediaBuf->release(); mediaBuf->release();
float secondsBuffered = 0.0; if (retryCount > retryLimit) {
unsigned long bandwidth = 0; unsigned long bandwidth = 0;
WV_Info_TimeBuffered(mSession, &secondsBuffered); WV_Info_CurrentBandwidth(mSession, &bandwidth);
WV_Info_CurrentBandwidth(mSession, &bandwidth); ALOGI("Retry count exhausted: secondsBuffered=%5.2f, bandwidth=%ld",
ALOGI("Retry count exhausted: secondsBuffered=%5.2f, bandwidth=%ld", secondsBuffered, bandwidth);
secondsBuffered, bandwidth); }
if (secondsBuffered > 2.0) { if (secondsBuffered > 2.0) {
// If there's some data buffered but no packets are for // If there's some data buffered but no packets are for