From ff46a87d3921a7dc5127fbbb79274a14b229ee69 Mon Sep 17 00:00:00 2001 From: olly Date: Mon, 15 Feb 2021 15:44:30 +0000 Subject: [PATCH] Remove track selection override reason and data These have limited value, and are confusing because they're only actually used if the override only selects a single track (if the override is an adaptive selection then the values are never used). The simpliest path forward is to remove them. PiperOrigin-RevId: 357573186 --- .../trackselection/DefaultTrackSelector.java | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java index 627df86cf6..81b054b36b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/DefaultTrackSelector.java @@ -1507,29 +1507,15 @@ public class DefaultTrackSelector extends MappingTrackSelector { public final int groupIndex; public final int[] tracks; public final int length; - public final int reason; - public final int data; /** * @param groupIndex The overriding track group index. * @param tracks The overriding track indices within the track group. */ public SelectionOverride(int groupIndex, int... tracks) { - this(groupIndex, tracks, C.SELECTION_REASON_MANUAL, /* data= */ 0); - } - - /** - * @param groupIndex The overriding track group index. - * @param tracks The overriding track indices within the track group. - * @param reason The reason for the override. One of the {@link C} SELECTION_REASON_ constants. - * @param data Optional data associated with this override. - */ - public SelectionOverride(int groupIndex, int[] tracks, int reason, int data) { this.groupIndex = groupIndex; this.tracks = Arrays.copyOf(tracks, tracks.length); this.length = tracks.length; - this.reason = reason; - this.data = data; Arrays.sort(this.tracks); } @@ -1538,8 +1524,6 @@ public class DefaultTrackSelector extends MappingTrackSelector { length = in.readByte(); tracks = new int[length]; in.readIntArray(tracks); - reason = in.readInt(); - data = in.readInt(); } /** Returns whether this override contains the specified track index. */ @@ -1554,9 +1538,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { @Override public int hashCode() { - int hash = 31 * groupIndex + Arrays.hashCode(tracks); - hash = 31 * hash + reason; - return 31 * hash + data; + return 31 * groupIndex + Arrays.hashCode(tracks); } @Override @@ -1568,10 +1550,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { return false; } SelectionOverride other = (SelectionOverride) obj; - return groupIndex == other.groupIndex - && Arrays.equals(tracks, other.tracks) - && reason == other.reason - && data == other.data; + return groupIndex == other.groupIndex && Arrays.equals(tracks, other.tracks); } // Parcelable implementation. @@ -1586,8 +1565,6 @@ public class DefaultTrackSelector extends MappingTrackSelector { dest.writeInt(groupIndex); dest.writeInt(tracks.length); dest.writeIntArray(tracks); - dest.writeInt(reason); - dest.writeInt(data); } public static final Parcelable.Creator CREATOR = @@ -1731,8 +1708,8 @@ public class DefaultTrackSelector extends MappingTrackSelector { : new ExoTrackSelection.Definition( rendererTrackGroups.get(override.groupIndex), override.tracks, - override.reason, - override.data); + C.SELECTION_REASON_MANUAL, + /* data= */ null); } }