Commit b3e8ee45 by ibaker Committed by Ian Baker

Mark @C.SelectionReason as TYPE_USE (only) and use it in more places

This is not backwards compatible if the @SelectionReason annotation is
used in Kotlin code, but before this change there aren't many library
surfaces that return a value annotated with @SelectionReason, so it
seems relatively unlikely that it is in use in any/many apps.

A follow-up change will fix the positions of existing usages to match
this new config.

#minor-release

PiperOrigin-RevId: 426409877
parent 6733f15f
...@@ -745,6 +745,7 @@ public final class C { ...@@ -745,6 +745,7 @@ public final class C {
@UnstableApi @UnstableApi
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target(TYPE_USE)
@IntDef( @IntDef(
open = true, open = true,
value = { value = {
......
...@@ -43,7 +43,7 @@ public final class MediaLoadData { ...@@ -43,7 +43,7 @@ public final class MediaLoadData {
* One of the {@link SelectionReason selection reasons} if the data belongs to a track. {@link * One of the {@link SelectionReason selection reasons} if the data belongs to a track. {@link
* C#SELECTION_REASON_UNKNOWN} otherwise. * C#SELECTION_REASON_UNKNOWN} otherwise.
*/ */
public final int trackSelectionReason; public final @C.SelectionReason int trackSelectionReason;
/** /**
* Optional data associated with the selection of the track to which the data belongs. Null if the * Optional data associated with the selection of the track to which the data belongs. Null if the
* data does not belong to a track. * data does not belong to a track.
......
...@@ -548,7 +548,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -548,7 +548,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
@Override @Override
public int getSelectionReason() { public @C.SelectionReason int getSelectionReason() {
return trackSelection.getSelectionReason(); return trackSelection.getSelectionReason();
} }
......
...@@ -316,7 +316,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection { ...@@ -316,7 +316,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
private float playbackSpeed; private float playbackSpeed;
private int selectedIndex; private int selectedIndex;
private int reason; private @C.SelectionReason int reason;
private long lastBufferEvaluationMs; private long lastBufferEvaluationMs;
@Nullable private MediaChunk lastBufferEvaluationMediaChunk; @Nullable private MediaChunk lastBufferEvaluationMediaChunk;
...@@ -449,7 +449,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection { ...@@ -449,7 +449,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
} }
int previousSelectedIndex = selectedIndex; int previousSelectedIndex = selectedIndex;
int previousReason = reason; @C.SelectionReason int previousReason = reason;
int formatIndexOfPreviousChunk = int formatIndexOfPreviousChunk =
queue.isEmpty() ? C.INDEX_UNSET : indexOf(Iterables.getLast(queue).trackFormat); queue.isEmpty() ? C.INDEX_UNSET : indexOf(Iterables.getLast(queue).trackFormat);
if (formatIndexOfPreviousChunk != C.INDEX_UNSET) { if (formatIndexOfPreviousChunk != C.INDEX_UNSET) {
...@@ -487,7 +487,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection { ...@@ -487,7 +487,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
} }
@Override @Override
public int getSelectionReason() { public @C.SelectionReason int getSelectionReason() {
return reason; return reason;
} }
......
...@@ -125,6 +125,7 @@ public interface ExoTrackSelection extends TrackSelection { ...@@ -125,6 +125,7 @@ public interface ExoTrackSelection extends TrackSelection {
int getSelectedIndex(); int getSelectedIndex();
/** Returns the reason for the current track selection. */ /** Returns the reason for the current track selection. */
@C.SelectionReason
int getSelectionReason(); int getSelectionReason();
/** Returns optional data associated with the current track selection. */ /** Returns optional data associated with the current track selection. */
......
...@@ -28,7 +28,7 @@ import java.util.List; ...@@ -28,7 +28,7 @@ import java.util.List;
@UnstableApi @UnstableApi
public final class FixedTrackSelection extends BaseTrackSelection { public final class FixedTrackSelection extends BaseTrackSelection {
private final int reason; private final @C.SelectionReason int reason;
@Nullable private final Object data; @Nullable private final Object data;
/** /**
...@@ -56,7 +56,11 @@ public final class FixedTrackSelection extends BaseTrackSelection { ...@@ -56,7 +56,11 @@ public final class FixedTrackSelection extends BaseTrackSelection {
* @param data Optional data associated with the track selection. * @param data Optional data associated with the track selection.
*/ */
public FixedTrackSelection( public FixedTrackSelection(
TrackGroup group, int track, @Type int type, int reason, @Nullable Object data) { TrackGroup group,
int track,
@Type int type,
@C.SelectionReason int reason,
@Nullable Object data) {
super(group, /* tracks= */ new int[] {track}, type); super(group, /* tracks= */ new int[] {track}, type);
this.reason = reason; this.reason = reason;
this.data = data; this.data = data;
...@@ -78,7 +82,7 @@ public final class FixedTrackSelection extends BaseTrackSelection { ...@@ -78,7 +82,7 @@ public final class FixedTrackSelection extends BaseTrackSelection {
} }
@Override @Override
public int getSelectionReason() { public @C.SelectionReason int getSelectionReason() {
return reason; return reason;
} }
......
...@@ -915,7 +915,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -915,7 +915,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
@Override @Override
public int getSelectionReason() { public @C.SelectionReason int getSelectionReason() {
return C.SELECTION_REASON_UNKNOWN; return C.SELECTION_REASON_UNKNOWN;
} }
......
...@@ -116,7 +116,7 @@ public final class FakeTrackSelection implements ExoTrackSelection { ...@@ -116,7 +116,7 @@ public final class FakeTrackSelection implements ExoTrackSelection {
} }
@Override @Override
public int getSelectionReason() { public @C.SelectionReason int getSelectionReason() {
return C.SELECTION_REASON_UNKNOWN; return C.SELECTION_REASON_UNKNOWN;
} }
......
...@@ -240,7 +240,7 @@ public final class MediaPeriodAsserts { ...@@ -240,7 +240,7 @@ public final class MediaPeriodAsserts {
} }
@Override @Override
public int getSelectionReason() { public @C.SelectionReason int getSelectionReason() {
return C.SELECTION_REASON_UNKNOWN; return C.SELECTION_REASON_UNKNOWN;
} }
......
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