28
28
import com .google .android .exoplayer2 .upstream .TransferListener ;
29
29
import com .google .android .exoplayer2 .util .Assertions ;
30
30
import com .google .android .exoplayer2 .util .Util ;
31
- import java .io .IOException ;
32
31
import java .util .ArrayList ;
33
32
import java .util .Arrays ;
34
33
import java .util .Collection ;
@@ -468,7 +467,7 @@ protected void enableInternal() {
468
467
public MediaPeriod createPeriod (MediaPeriodId id , Allocator allocator , long startPositionUs ) {
469
468
Object mediaSourceHolderUid = getMediaSourceHolderUid (id .periodUid );
470
469
MediaPeriodId childMediaPeriodId = id .copyWithPeriodUid (getChildPeriodUid (id .periodUid ));
471
- MediaSourceHolder holder = mediaSourceByUid .get (mediaSourceHolderUid );
470
+ @ Nullable MediaSourceHolder holder = mediaSourceByUid .get (mediaSourceHolderUid );
472
471
if (holder == null ) {
473
472
// Stale event. The media source has already been removed.
474
473
holder = new MediaSourceHolder (new DummyMediaSource (), useLazyPreparation );
@@ -555,7 +554,7 @@ private void addPublicMediaSources(
555
554
@ Nullable Handler handler ,
556
555
@ Nullable Runnable onCompletionAction ) {
557
556
Assertions .checkArgument ((handler == null ) == (onCompletionAction == null ));
558
- Handler playbackThreadHandler = this .playbackThreadHandler ;
557
+ @ Nullable Handler playbackThreadHandler = this .playbackThreadHandler ;
559
558
for (MediaSource mediaSource : mediaSources ) {
560
559
Assertions .checkNotNull (mediaSource );
561
560
}
@@ -565,6 +564,7 @@ private void addPublicMediaSources(
565
564
}
566
565
mediaSourcesPublic .addAll (index , mediaSourceHolders );
567
566
if (playbackThreadHandler != null && !mediaSources .isEmpty ()) {
567
+ @ Nullable
568
568
HandlerAndRunnable callbackAction = createOnCompletionAction (handler , onCompletionAction );
569
569
playbackThreadHandler
570
570
.obtainMessage (MSG_ADD , new MessageData <>(index , mediaSourceHolders , callbackAction ))
@@ -581,9 +581,10 @@ private void removePublicMediaSources(
581
581
@ Nullable Handler handler ,
582
582
@ Nullable Runnable onCompletionAction ) {
583
583
Assertions .checkArgument ((handler == null ) == (onCompletionAction == null ));
584
- Handler playbackThreadHandler = this .playbackThreadHandler ;
584
+ @ Nullable Handler playbackThreadHandler = this .playbackThreadHandler ;
585
585
Util .removeRange (mediaSourcesPublic , fromIndex , toIndex );
586
586
if (playbackThreadHandler != null ) {
587
+ @ Nullable
587
588
HandlerAndRunnable callbackAction = createOnCompletionAction (handler , onCompletionAction );
588
589
playbackThreadHandler
589
590
.obtainMessage (MSG_REMOVE , new MessageData <>(fromIndex , toIndex , callbackAction ))
@@ -600,9 +601,10 @@ private void movePublicMediaSource(
600
601
@ Nullable Handler handler ,
601
602
@ Nullable Runnable onCompletionAction ) {
602
603
Assertions .checkArgument ((handler == null ) == (onCompletionAction == null ));
603
- Handler playbackThreadHandler = this .playbackThreadHandler ;
604
+ @ Nullable Handler playbackThreadHandler = this .playbackThreadHandler ;
604
605
mediaSourcesPublic .add (newIndex , mediaSourcesPublic .remove (currentIndex ));
605
606
if (playbackThreadHandler != null ) {
607
+ @ Nullable
606
608
HandlerAndRunnable callbackAction = createOnCompletionAction (handler , onCompletionAction );
607
609
playbackThreadHandler
608
610
.obtainMessage (MSG_MOVE , new MessageData <>(currentIndex , newIndex , callbackAction ))
@@ -616,7 +618,7 @@ private void movePublicMediaSource(
616
618
private void setPublicShuffleOrder (
617
619
ShuffleOrder shuffleOrder , @ Nullable Handler handler , @ Nullable Runnable onCompletionAction ) {
618
620
Assertions .checkArgument ((handler == null ) == (onCompletionAction == null ));
619
- Handler playbackThreadHandler = this .playbackThreadHandler ;
621
+ @ Nullable Handler playbackThreadHandler = this .playbackThreadHandler ;
620
622
if (playbackThreadHandler != null ) {
621
623
int size = getSize ();
622
624
if (shuffleOrder .getLength () != size ) {
@@ -625,6 +627,7 @@ private void setPublicShuffleOrder(
625
627
.cloneAndClear ()
626
628
.cloneAndInsert (/* insertionIndex= */ 0 , /* insertionCount= */ size );
627
629
}
630
+ @ Nullable
628
631
HandlerAndRunnable callbackAction = createOnCompletionAction (handler , onCompletionAction );
629
632
playbackThreadHandler
630
633
.obtainMessage (
@@ -772,9 +775,6 @@ private void addMediaSourceInternal(int newIndex, MediaSourceHolder newMediaSour
772
775
}
773
776
774
777
private void updateMediaSourceInternal (MediaSourceHolder mediaSourceHolder , Timeline timeline ) {
775
- if (mediaSourceHolder == null ) {
776
- throw new IllegalArgumentException ();
777
- }
778
778
if (mediaSourceHolder .childIndex + 1 < mediaSourceHolders .size ()) {
779
779
MediaSourceHolder nextHolder = mediaSourceHolders .get (mediaSourceHolder .childIndex + 1 );
780
780
int windowOffsetUpdate =
@@ -947,7 +947,7 @@ protected int getChildIndexByWindowIndex(int windowIndex) {
947
947
948
948
@ Override
949
949
protected int getChildIndexByChildUid (Object childUid ) {
950
- Integer index = childIndexByUid .get (childUid );
950
+ @ Nullable Integer index = childIndexByUid .get (childUid );
951
951
return index == null ? C .INDEX_UNSET : index ;
952
952
}
953
953
@@ -1002,7 +1002,7 @@ protected void releaseSourceInternal() {
1002
1002
}
1003
1003
1004
1004
@ Override
1005
- public void maybeThrowSourceInfoRefreshError () throws IOException {
1005
+ public void maybeThrowSourceInfoRefreshError () {
1006
1006
// Do nothing.
1007
1007
}
1008
1008
0 commit comments