Commit 2eca2614 by Googler Committed by christosts

Update SampleQueue.sourceId to be a long rather than an int.

This simplifies usage of 64-bit sequence numbers.

PiperOrigin-RevId: 508107588
parent 07ff4816
......@@ -79,7 +79,7 @@ public class SampleQueue implements TrackOutput {
@Nullable private DrmSession currentDrmSession;
private int capacity;
private int[] sourceIds;
private long[] sourceIds;
private long[] offsets;
private int[] sizes;
private int[] flags;
......@@ -100,7 +100,7 @@ public class SampleQueue implements TrackOutput {
private boolean upstreamFormatAdjustmentRequired;
@Nullable private Format unadjustedUpstreamFormat;
@Nullable private Format upstreamFormat;
private int upstreamSourceId;
private long upstreamSourceId;
private boolean upstreamAllSamplesAreSyncSamples;
private boolean loggedUnexpectedNonSyncSample;
......@@ -166,7 +166,7 @@ public class SampleQueue implements TrackOutput {
sampleDataQueue = new SampleDataQueue(allocator);
extrasHolder = new SampleExtrasHolder();
capacity = SAMPLE_CAPACITY_INCREMENT;
sourceIds = new int[capacity];
sourceIds = new long[capacity];
offsets = new long[capacity];
timesUs = new long[capacity];
flags = new int[capacity];
......@@ -238,7 +238,7 @@ public class SampleQueue implements TrackOutput {
*
* @param sourceId The source identifier.
*/
public final void sourceId(int sourceId) {
public final void sourceId(long sourceId) {
upstreamSourceId = sourceId;
}
......@@ -316,7 +316,7 @@ public class SampleQueue implements TrackOutput {
*
* @return The source id.
*/
public final synchronized int peekSourceId() {
public final synchronized long peekSourceId() {
int relativeReadIndex = getRelativeIndex(readPosition);
return hasNextSample() ? sourceIds[relativeReadIndex] : upstreamSourceId;
}
......@@ -826,7 +826,7 @@ public class SampleQueue implements TrackOutput {
if (length == capacity) {
// Increase the capacity.
int newCapacity = capacity + SAMPLE_CAPACITY_INCREMENT;
int[] newSourceIds = new int[newCapacity];
long[] newSourceIds = new long[newCapacity];
long[] newOffsets = new long[newCapacity];
long[] newTimesUs = new long[newCapacity];
int[] newFlags = new int[newCapacity];
......
......@@ -71,6 +71,7 @@ import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.Util;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.primitives.Ints;
import java.io.EOFException;
import java.io.IOException;
import java.util.ArrayList;
......@@ -664,7 +665,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
Format format = Assertions.checkNotNull(formatHolder.format);
if (sampleQueueIndex == primarySampleQueueIndex) {
// Fill in primary sample format with information from the track format.
int chunkUid = sampleQueues[sampleQueueIndex].peekSourceId();
int chunkUid = Ints.checkedCast(sampleQueues[sampleQueueIndex].peekSourceId());
int chunkIndex = 0;
while (chunkIndex < mediaChunks.size() && mediaChunks.get(chunkIndex).uid != chunkUid) {
chunkIndex++;
......
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