mirror of
https://github.com/androidx/media.git
synced 2025-05-06 23:20:42 +08:00
Verify MediaSources passed to set/addMediaSources are non-null.
Even though they are annotated as non-null, Java users can pass in null values. So we should verify the input to fail fast. PiperOrigin-RevId: 306425487
This commit is contained in:
parent
76ad0bc4ff
commit
6a491e1294
@ -397,6 +397,9 @@ import java.util.concurrent.TimeoutException;
|
||||
@Override
|
||||
public void addMediaSources(int index, List<MediaSource> mediaSources) {
|
||||
Assertions.checkArgument(index >= 0);
|
||||
for (int i = 0; i < mediaSources.size(); i++) {
|
||||
Assertions.checkArgument(mediaSources.get(i) != null);
|
||||
}
|
||||
int currentWindowIndex = getCurrentWindowIndex();
|
||||
long currentPositionMs = getCurrentPosition();
|
||||
Timeline oldTimeline = getCurrentTimeline();
|
||||
@ -966,10 +969,13 @@ import java.util.concurrent.TimeoutException;
|
||||
}
|
||||
|
||||
private void setMediaSourcesInternal(
|
||||
List<MediaSource> mediaItems,
|
||||
List<MediaSource> mediaSources,
|
||||
int startWindowIndex,
|
||||
long startPositionMs,
|
||||
boolean resetToDefaultPosition) {
|
||||
for (int i = 0; i < mediaSources.size(); i++) {
|
||||
Assertions.checkArgument(mediaSources.get(i) != null);
|
||||
}
|
||||
int currentWindowIndex = getCurrentWindowIndexInternal();
|
||||
long currentPositionMs = getCurrentPosition();
|
||||
pendingOperationAcks++;
|
||||
@ -978,7 +984,7 @@ import java.util.concurrent.TimeoutException;
|
||||
/* fromIndex= */ 0, /* toIndexExclusive= */ mediaSourceHolders.size());
|
||||
}
|
||||
List<MediaSourceList.MediaSourceHolder> holders =
|
||||
addMediaSourceHolders(/* index= */ 0, mediaItems);
|
||||
addMediaSourceHolders(/* index= */ 0, mediaSources);
|
||||
PlaybackInfo playbackInfo = maskTimeline();
|
||||
Timeline timeline = playbackInfo.timeline;
|
||||
if (!timeline.isEmpty() && startWindowIndex >= timeline.getWindowCount()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user