From f9eea898284e7f1f673aa66c64f5b1408b666867 Mon Sep 17 00:00:00 2001 From: Jeffrey Tinker Date: Tue, 29 Mar 2011 08:32:29 -0700 Subject: [PATCH] Partial fix for 4181654 hang in seeking after seeking to the end Also prevents player from becoming unresponsive as described in 3510047. Change-Id: I3350990c46641e48c34e9a64598157c8af77dcc5 --- proprietary/wvm/WVMMediaSource.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/proprietary/wvm/WVMMediaSource.cpp b/proprietary/wvm/WVMMediaSource.cpp index cb2df116..48b9f3ca 100644 --- a/proprietary/wvm/WVMMediaSource.cpp +++ b/proprietary/wvm/WVMMediaSource.cpp @@ -195,6 +195,7 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options) int64_t keyTime; bool syncFrame; + int retryLimit = 0; // Pull full access units. Since we aren't sure how big they might be, // start with initial buffer size, then allocate a larger buffer if we @@ -233,9 +234,16 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options) } if (bytesRead == 0) { - // Didn't get anything, sleep a bit so we don't hog the CPU then try again - usleep(10000); - continue; + if (retryLimit++ >= 500) { + // If no data received within the retry limit, return ERROR_IO + // This prevents the player from becoming unresponsive + mediaBuf->release(); + return ERROR_IO; + } else { + // Didn't get anything, sleep a bit so we don't hog the CPU then try again + usleep(10000); + continue; + } } #define PCR_HZ 90000