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
This commit is contained in:
parent
a506d245d1
commit
975910a494
@ -169,6 +169,10 @@
|
|||||||
a fallback value.
|
a fallback value.
|
||||||
* Remove `(Simple)ExoPlayer.setThrowsWhenUsingWrongThread`. Opting out of
|
* Remove `(Simple)ExoPlayer.setThrowsWhenUsingWrongThread`. Opting out of
|
||||||
the thread enforcement is no longer possible.
|
the thread enforcement is no longer possible.
|
||||||
|
* Change the following `IntDefs` to `@Target(TYPE_USE)` only. This may break
|
||||||
|
the compilation of usages in Kotlin, which can be fixed by moving the
|
||||||
|
annotation to annotate the type (`Int`).
|
||||||
|
* `@C.SelectionReason`
|
||||||
|
|
||||||
### 2.16.1 (2021-11-18)
|
### 2.16.1 (2021-11-18)
|
||||||
|
|
||||||
|
@ -729,6 +729,7 @@ public final class C {
|
|||||||
*/
|
*/
|
||||||
@Documented
|
@Documented
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@Target(TYPE_USE)
|
||||||
@IntDef(
|
@IntDef(
|
||||||
open = true,
|
open = true,
|
||||||
value = {
|
value = {
|
||||||
|
@ -41,7 +41,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.
|
||||||
|
@ -546,7 +546,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSelectionReason() {
|
public @C.SelectionReason int getSelectionReason() {
|
||||||
return trackSelection.getSelectionReason();
|
return trackSelection.getSelectionReason();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +313,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;
|
||||||
|
|
||||||
@ -446,7 +446,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) {
|
||||||
@ -484,7 +484,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSelectionReason() {
|
public @C.SelectionReason int getSelectionReason() {
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +122,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. */
|
||||||
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
/** A {@link TrackSelection} consisting of a single track. */
|
/** A {@link TrackSelection} consisting of a single track. */
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,7 +53,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;
|
||||||
@ -75,7 +79,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;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSelectionReason() {
|
public @C.SelectionReason int getSelectionReason() {
|
||||||
return C.SELECTION_REASON_UNKNOWN;
|
return C.SELECTION_REASON_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user