Define CueGroup.EMPTY_TIME_ZERO for convenience

We create an empty CueGroup in many places as default or
where none is needed. Instead, we can define a constant
for this purpose and reuse it.

PiperOrigin-RevId: 467944841
(cherry picked from commit 29208ec1ed4d78fa86af33b81a2b32f3151b9004)
This commit is contained in:
tonihei 2022-08-16 16:27:56 +00:00 committed by microkatz
parent c5b4cbed75
commit d5710d3171
3 changed files with 8 additions and 5 deletions

View File

@ -111,8 +111,6 @@ public final class CastPlayer extends BasePlayer {
private static final long PROGRESS_REPORT_PERIOD_MS = 1000; private static final long PROGRESS_REPORT_PERIOD_MS = 1000;
private static final long[] EMPTY_TRACK_ID_ARRAY = new long[0]; private static final long[] EMPTY_TRACK_ID_ARRAY = new long[0];
private static final CueGroup EMPTY_CUE_GROUP =
new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0);
private final CastContext castContext; private final CastContext castContext;
private final MediaItemConverter mediaItemConverter; private final MediaItemConverter mediaItemConverter;
@ -726,7 +724,7 @@ public final class CastPlayer extends BasePlayer {
/** This method is not supported and returns an empty {@link CueGroup}. */ /** This method is not supported and returns an empty {@link CueGroup}. */
@Override @Override
public CueGroup getCurrentCues() { public CueGroup getCurrentCues() {
return EMPTY_CUE_GROUP; return CueGroup.EMPTY_TIME_ZERO;
} }
/** This method is not supported and always returns {@link DeviceInfo#UNKNOWN}. */ /** This method is not supported and always returns {@link DeviceInfo#UNKNOWN}. */

View File

@ -34,6 +34,11 @@ import java.util.List;
/** Class to represent the state of active {@link Cue Cues} at a particular time. */ /** Class to represent the state of active {@link Cue Cues} at a particular time. */
public final class CueGroup implements Bundleable { public final class CueGroup implements Bundleable {
/** An empty group with no {@link Cue Cues} and presentation time of zero. */
public static final CueGroup EMPTY_TIME_ZERO =
new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0);
/** /**
* The cues in this group. * The cues in this group.
* *

View File

@ -345,7 +345,7 @@ import java.util.concurrent.TimeoutException;
} else { } else {
audioSessionId = Util.generateAudioSessionIdV21(applicationContext); audioSessionId = Util.generateAudioSessionIdV21(applicationContext);
} }
currentCueGroup = new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0); currentCueGroup = CueGroup.EMPTY_TIME_ZERO;
throwsWhenUsingWrongThread = true; throwsWhenUsingWrongThread = true;
addListener(analyticsCollector); addListener(analyticsCollector);
@ -990,7 +990,7 @@ import java.util.concurrent.TimeoutException;
checkNotNull(priorityTaskManager).remove(C.PRIORITY_PLAYBACK); checkNotNull(priorityTaskManager).remove(C.PRIORITY_PLAYBACK);
isPriorityTaskManagerRegistered = false; isPriorityTaskManagerRegistered = false;
} }
currentCueGroup = new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0); currentCueGroup = CueGroup.EMPTY_TIME_ZERO;
playerReleased = true; playerReleased = true;
} }