mirror of
https://github.com/androidx/media.git
synced 2025-05-07 15:40:37 +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
|
@Override
|
||||||
public void addMediaSources(int index, List<MediaSource> mediaSources) {
|
public void addMediaSources(int index, List<MediaSource> mediaSources) {
|
||||||
Assertions.checkArgument(index >= 0);
|
Assertions.checkArgument(index >= 0);
|
||||||
|
for (int i = 0; i < mediaSources.size(); i++) {
|
||||||
|
Assertions.checkArgument(mediaSources.get(i) != null);
|
||||||
|
}
|
||||||
int currentWindowIndex = getCurrentWindowIndex();
|
int currentWindowIndex = getCurrentWindowIndex();
|
||||||
long currentPositionMs = getCurrentPosition();
|
long currentPositionMs = getCurrentPosition();
|
||||||
Timeline oldTimeline = getCurrentTimeline();
|
Timeline oldTimeline = getCurrentTimeline();
|
||||||
@ -966,10 +969,13 @@ import java.util.concurrent.TimeoutException;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setMediaSourcesInternal(
|
private void setMediaSourcesInternal(
|
||||||
List<MediaSource> mediaItems,
|
List<MediaSource> mediaSources,
|
||||||
int startWindowIndex,
|
int startWindowIndex,
|
||||||
long startPositionMs,
|
long startPositionMs,
|
||||||
boolean resetToDefaultPosition) {
|
boolean resetToDefaultPosition) {
|
||||||
|
for (int i = 0; i < mediaSources.size(); i++) {
|
||||||
|
Assertions.checkArgument(mediaSources.get(i) != null);
|
||||||
|
}
|
||||||
int currentWindowIndex = getCurrentWindowIndexInternal();
|
int currentWindowIndex = getCurrentWindowIndexInternal();
|
||||||
long currentPositionMs = getCurrentPosition();
|
long currentPositionMs = getCurrentPosition();
|
||||||
pendingOperationAcks++;
|
pendingOperationAcks++;
|
||||||
@ -978,7 +984,7 @@ import java.util.concurrent.TimeoutException;
|
|||||||
/* fromIndex= */ 0, /* toIndexExclusive= */ mediaSourceHolders.size());
|
/* fromIndex= */ 0, /* toIndexExclusive= */ mediaSourceHolders.size());
|
||||||
}
|
}
|
||||||
List<MediaSourceList.MediaSourceHolder> holders =
|
List<MediaSourceList.MediaSourceHolder> holders =
|
||||||
addMediaSourceHolders(/* index= */ 0, mediaItems);
|
addMediaSourceHolders(/* index= */ 0, mediaSources);
|
||||||
PlaybackInfo playbackInfo = maskTimeline();
|
PlaybackInfo playbackInfo = maskTimeline();
|
||||||
Timeline timeline = playbackInfo.timeline;
|
Timeline timeline = playbackInfo.timeline;
|
||||||
if (!timeline.isEmpty() && startWindowIndex >= timeline.getWindowCount()) {
|
if (!timeline.isEmpty() && startWindowIndex >= timeline.getWindowCount()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user