Skip to content

Commit 41c95f3

Browse files
theandi666Android (Google) Code Review
authored andcommitted
Merge "Specifying -1 for both low and highwater marks would not actually do the right thing"
2 parents 851a14e + b987d87 commit 41c95f3

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

media/libstagefright/NuCachedSource2.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,10 @@ void NuCachedSource2::updateCacheParamsFromSystemProperty() {
598598

599599
void 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

Comments
 (0)