Skip to content

Commit

Permalink
Use overflow-save add operation for blacklisting duration.
Browse files Browse the repository at this point in the history
This allows to specify open-ended blacklisting with Long.MAX_VALUE.

PiperOrigin-RevId: 222550939
  • Loading branch information
tonihei authored and ojw28 committed Nov 23, 2018
1 parent 56e4860 commit f8a3c13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
.setMimeType(MIME_TYPE_VIDEO_MP4)
.setMedia("https://html5demos.com/assets/dizzy.mp4")
.buildAndClear());

SAMPLES = Collections.unmodifiableList(samples);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.chunk.MediaChunk;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -160,7 +161,10 @@ public final boolean blacklist(int index, long blacklistDurationMs) {
if (!canBlacklist) {
return false;
}
blacklistUntilTimes[index] = Math.max(blacklistUntilTimes[index], nowMs + blacklistDurationMs);
blacklistUntilTimes[index] =
Math.max(
blacklistUntilTimes[index],
Util.addWithOverflowDefault(nowMs, blacklistDurationMs, Long.MAX_VALUE));
return true;
}

Expand Down

0 comments on commit f8a3c13

Please sign in to comment.