Commit 0701fed7 by tonihei Committed by Oliver Woodman

Use overflow-save add operation for blacklisting duration.

This allows to specify open-ended blacklisting with Long.MAX_VALUE.

PiperOrigin-RevId: 222550939
parent 028bd9df
...@@ -81,8 +81,6 @@ import java.util.List; ...@@ -81,8 +81,6 @@ import java.util.List;
+ "hls/TearsOfSteel.m3u8", "Tears of Steel (HLS)", MIME_TYPE_HLS)); + "hls/TearsOfSteel.m3u8", "Tears of Steel (HLS)", MIME_TYPE_HLS));
samples.add(new Sample("https://html5demos.com/assets/dizzy.mp4", "Dizzy (MP4)", samples.add(new Sample("https://html5demos.com/assets/dizzy.mp4", "Dizzy (MP4)",
MIME_TYPE_VIDEO_MP4)); MIME_TYPE_VIDEO_MP4));
SAMPLES = Collections.unmodifiableList(samples); SAMPLES = Collections.unmodifiableList(samples);
} }
......
...@@ -22,6 +22,7 @@ import com.google.android.exoplayer2.Format; ...@@ -22,6 +22,7 @@ import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.chunk.MediaChunk; import com.google.android.exoplayer2.source.chunk.MediaChunk;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
...@@ -160,7 +161,10 @@ public abstract class BaseTrackSelection implements TrackSelection { ...@@ -160,7 +161,10 @@ public abstract class BaseTrackSelection implements TrackSelection {
if (!canBlacklist) { if (!canBlacklist) {
return false; 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; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment