mirror of
https://github.com/androidx/media.git
synced 2025-05-09 16:40:55 +08:00
Avoid track group array error-prone reference quality check in CastPlayer.
Also replaced the duplicated EMPTY track group array with the one already defined in TrackGroupArray. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=175670266
This commit is contained in:
parent
244f7a1e33
commit
b30b786350
@ -86,7 +86,6 @@ public final class CastPlayer implements Player {
|
|||||||
private static final int RENDERER_INDEX_AUDIO = 1;
|
private static final int RENDERER_INDEX_AUDIO = 1;
|
||||||
private static final int RENDERER_INDEX_TEXT = 2;
|
private static final int RENDERER_INDEX_TEXT = 2;
|
||||||
private static final long PROGRESS_REPORT_PERIOD_MS = 1000;
|
private static final long PROGRESS_REPORT_PERIOD_MS = 1000;
|
||||||
private static final TrackGroupArray EMPTY_TRACK_GROUP_ARRAY = new TrackGroupArray();
|
|
||||||
private static final TrackSelectionArray EMPTY_TRACK_SELECTION_ARRAY =
|
private static final TrackSelectionArray EMPTY_TRACK_SELECTION_ARRAY =
|
||||||
new TrackSelectionArray(null, null, null);
|
new TrackSelectionArray(null, null, null);
|
||||||
private static final long[] EMPTY_TRACK_ID_ARRAY = new long[0];
|
private static final long[] EMPTY_TRACK_ID_ARRAY = new long[0];
|
||||||
@ -137,7 +136,7 @@ public final class CastPlayer implements Player {
|
|||||||
playbackState = STATE_IDLE;
|
playbackState = STATE_IDLE;
|
||||||
repeatMode = REPEAT_MODE_OFF;
|
repeatMode = REPEAT_MODE_OFF;
|
||||||
currentTimeline = CastTimeline.EMPTY_CAST_TIMELINE;
|
currentTimeline = CastTimeline.EMPTY_CAST_TIMELINE;
|
||||||
currentTrackGroups = EMPTY_TRACK_GROUP_ARRAY;
|
currentTrackGroups = TrackGroupArray.EMPTY;
|
||||||
currentTrackSelection = EMPTY_TRACK_SELECTION_ARRAY;
|
currentTrackSelection = EMPTY_TRACK_SELECTION_ARRAY;
|
||||||
pendingSeekWindowIndex = C.INDEX_UNSET;
|
pendingSeekWindowIndex = C.INDEX_UNSET;
|
||||||
pendingSeekPositionMs = C.TIME_UNSET;
|
pendingSeekPositionMs = C.TIME_UNSET;
|
||||||
@ -596,8 +595,8 @@ public final class CastPlayer implements Player {
|
|||||||
MediaInfo mediaInfo = mediaStatus != null ? mediaStatus.getMediaInfo() : null;
|
MediaInfo mediaInfo = mediaStatus != null ? mediaStatus.getMediaInfo() : null;
|
||||||
List<MediaTrack> castMediaTracks = mediaInfo != null ? mediaInfo.getMediaTracks() : null;
|
List<MediaTrack> castMediaTracks = mediaInfo != null ? mediaInfo.getMediaTracks() : null;
|
||||||
if (castMediaTracks == null || castMediaTracks.isEmpty()) {
|
if (castMediaTracks == null || castMediaTracks.isEmpty()) {
|
||||||
boolean hasChanged = currentTrackGroups != EMPTY_TRACK_GROUP_ARRAY;
|
boolean hasChanged = !currentTrackGroups.isEmpty();
|
||||||
currentTrackGroups = EMPTY_TRACK_GROUP_ARRAY;
|
currentTrackGroups = TrackGroupArray.EMPTY;
|
||||||
currentTrackSelection = EMPTY_TRACK_SELECTION_ARRAY;
|
currentTrackSelection = EMPTY_TRACK_SELECTION_ARRAY;
|
||||||
return hasChanged;
|
return hasChanged;
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,11 @@ public final class TrackGroupArray {
|
|||||||
* @param group The group.
|
* @param group The group.
|
||||||
* @return The index of the group, or {@link C#INDEX_UNSET} if no such group exists.
|
* @return The index of the group, or {@link C#INDEX_UNSET} if no such group exists.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("ReferenceEquality")
|
||||||
public int indexOf(TrackGroup group) {
|
public int indexOf(TrackGroup group) {
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
|
// Suppressed reference equality warning because this is looking for the index of a specific
|
||||||
|
// TrackGroup object, not the index of a potential equal TrackGroup.
|
||||||
if (trackGroups[i] == group) {
|
if (trackGroups[i] == group) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -71,6 +74,13 @@ public final class TrackGroupArray {
|
|||||||
return C.INDEX_UNSET;
|
return C.INDEX_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this track group array is empty.
|
||||||
|
*/
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return length == 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
if (hashCode == 0) {
|
if (hashCode == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user