From 0b8cd8b0cf1489f8f7c0b2c4d7ea8fea70ca93a1 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Fri, 7 Oct 2011 10:00:38 -0700 Subject: Specifying -1 for both low and highwater marks would not actually do the right thing before this change. Also make it more consistent in that specifying -1 for the keepalive settings specifies the default. Change-Id: I086f530fbf42abce66d1c8e61157215cb474e044 --- media/libstagefright/NuCachedSource2.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp index 2cacfa73..9adb841d 100644 --- a/media/libstagefright/NuCachedSource2.cpp +++ b/media/libstagefright/NuCachedSource2.cpp @@ -598,11 +598,10 @@ void NuCachedSource2::updateCacheParamsFromSystemProperty() { void NuCachedSource2::updateCacheParamsFromString(const char *s) { ssize_t lowwaterMarkKb, highwaterMarkKb; - unsigned keepAliveSecs; + int keepAliveSecs; - if (sscanf(s, "%ld/%ld/%u", - &lowwaterMarkKb, &highwaterMarkKb, &keepAliveSecs) != 3 - || lowwaterMarkKb >= highwaterMarkKb) { + if (sscanf(s, "%ld/%ld/%d", + &lowwaterMarkKb, &highwaterMarkKb, &keepAliveSecs) != 3) { LOGE("Failed to parse cache parameters from '%s'.", s); return; } @@ -619,7 +618,18 @@ void NuCachedSource2::updateCacheParamsFromString(const char *s) { mHighwaterThresholdBytes = kDefaultHighWaterThreshold; } - mKeepAliveIntervalUs = keepAliveSecs * 1000000ll; + if (mLowwaterThresholdBytes >= mHighwaterThresholdBytes) { + LOGE("Illegal low/highwater marks specified, reverting to defaults."); + + mLowwaterThresholdBytes = kDefaultLowWaterThreshold; + mHighwaterThresholdBytes = kDefaultHighWaterThreshold; + } + + if (keepAliveSecs >= 0) { + mKeepAliveIntervalUs = keepAliveSecs * 1000000ll; + } else { + mKeepAliveIntervalUs = kDefaultKeepAliveIntervalUs; + } LOGV("lowwater = %d bytes, highwater = %d bytes, keepalive = %lld us", mLowwaterThresholdBytes, -- cgit v1.2.3