Commit 59083c9f by olly Committed by Oliver Woodman

Suppress rawtypes warning when instantiating generic array

Change FakeAdaptiveMediaPeriod back to this style for consistency.

PiperOrigin-RevId: 284967667
parent a00e7dfe
......@@ -818,7 +818,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
/* initializationData= */ null);
}
@SuppressWarnings("unchecked")
// We won't assign the array to a variable that erases the generic type, and then write into it.
@SuppressWarnings({"unchecked", "rawtypes"})
private static ChunkSampleStream<DashChunkSource>[] newSampleStreamArray(int length) {
return new ChunkSampleStream[length];
}
......
......@@ -277,7 +277,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
return new TrackGroupArray(trackGroups);
}
@SuppressWarnings("unchecked")
// We won't assign the array to a variable that erases the generic type, and then write into it.
@SuppressWarnings({"unchecked", "rawtypes"})
private static ChunkSampleStream<SsChunkSource>[] newSampleStreamArray(int length) {
return new ChunkSampleStream[length];
}
......
......@@ -45,7 +45,7 @@ public class FakeAdaptiveMediaPeriod extends FakeMediaPeriod
private final long durationUs;
private Callback callback;
private List<ChunkSampleStream<FakeChunkSource>> sampleStreams;
private ChunkSampleStream<FakeChunkSource>[] sampleStreams;
private SequenceableLoader sequenceableLoader;
public FakeAdaptiveMediaPeriod(
......@@ -60,7 +60,7 @@ public class FakeAdaptiveMediaPeriod extends FakeMediaPeriod
this.chunkSourceFactory = chunkSourceFactory;
this.transferListener = transferListener;
this.durationUs = durationUs;
this.sampleStreams = new ArrayList<>();
this.sampleStreams = newSampleStreamArray(0);
this.sequenceableLoader = new CompositeSequenceableLoader(new SequenceableLoader[0]);
}
......@@ -94,9 +94,8 @@ public class FakeAdaptiveMediaPeriod extends FakeMediaPeriod
validStreams.add((ChunkSampleStream<FakeChunkSource>) stream);
}
}
this.sampleStreams = validStreams;
this.sequenceableLoader =
new CompositeSequenceableLoader(sampleStreams.toArray(new SequenceableLoader[0]));
this.sampleStreams = validStreams.toArray(newSampleStreamArray(validStreams.size()));
this.sequenceableLoader = new CompositeSequenceableLoader(sampleStreams);
return returnPositionUs;
}
......@@ -166,4 +165,10 @@ public class FakeAdaptiveMediaPeriod extends FakeMediaPeriod
public void onContinueLoadingRequested(ChunkSampleStream<FakeChunkSource> source) {
callback.onContinueLoadingRequested(this);
}
// We won't assign the array to a variable that erases the generic type, and then write into it.
@SuppressWarnings({"unchecked", "rawtypes"})
private static ChunkSampleStream<FakeChunkSource>[] newSampleStreamArray(int length) {
return new ChunkSampleStream[length];
}
}
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