@@ -598,11 +598,10 @@ void NuCachedSource2::updateCacheParamsFromSystemProperty() {
598598
599599void NuCachedSource2::updateCacheParamsFromString (const char *s) {
600600 ssize_t lowwaterMarkKb, highwaterMarkKb;
601- unsigned keepAliveSecs;
601+ int keepAliveSecs;
602602
603- if (sscanf (s, " %ld/%ld/%u" ,
604- &lowwaterMarkKb, &highwaterMarkKb, &keepAliveSecs) != 3
605- || lowwaterMarkKb >= highwaterMarkKb) {
603+ if (sscanf (s, " %ld/%ld/%d" ,
604+ &lowwaterMarkKb, &highwaterMarkKb, &keepAliveSecs) != 3 ) {
606605 LOGE (" Failed to parse cache parameters from '%s'." , s);
607606 return ;
608607 }
@@ -619,7 +618,18 @@ void NuCachedSource2::updateCacheParamsFromString(const char *s) {
619618 mHighwaterThresholdBytes = kDefaultHighWaterThreshold ;
620619 }
621620
622- mKeepAliveIntervalUs = keepAliveSecs * 1000000ll ;
621+ if (mLowwaterThresholdBytes >= mHighwaterThresholdBytes ) {
622+ LOGE (" Illegal low/highwater marks specified, reverting to defaults." );
623+
624+ mLowwaterThresholdBytes = kDefaultLowWaterThreshold ;
625+ mHighwaterThresholdBytes = kDefaultHighWaterThreshold ;
626+ }
627+
628+ if (keepAliveSecs >= 0 ) {
629+ mKeepAliveIntervalUs = keepAliveSecs * 1000000ll ;
630+ } else {
631+ mKeepAliveIntervalUs = kDefaultKeepAliveIntervalUs ;
632+ }
623633
624634 LOGV (" lowwater = %d bytes, highwater = %d bytes, keepalive = %lld us" ,
625635 mLowwaterThresholdBytes ,
0 commit comments