Use consistent naming for 'offload scheduling enabled'

PiperOrigin-RevId: 326413842
This commit is contained in:
andrewlewis 2020-08-13 11:16:32 +01:00 committed by kim-vde
parent cde795ea98
commit 61abe5951a
8 changed files with 33 additions and 32 deletions

View File

@ -242,8 +242,8 @@ public class DefaultRenderersFactory implements RenderersFactory {
* Sets whether audio should be played using the offload path. * Sets whether audio should be played using the offload path.
* *
* <p>Audio offload disables ExoPlayer audio processing, but significantly reduces the energy * <p>Audio offload disables ExoPlayer audio processing, but significantly reduces the energy
* consumption of the playback when {@link ExoPlayer#experimentalEnableOffloadScheduling(boolean)} * consumption of the playback when {@link
* is enabled. * ExoPlayer#experimentalSetOffloadSchedulingEnabled(boolean) offload scheduling} is enabled.
* *
* <p>Most Android devices can only support one offload {@link android.media.AudioTrack} at a time * <p>Most Android devices can only support one offload {@link android.media.AudioTrack} at a time
* and can invalidate it at any time. Thus an app can never be guaranteed that it will be able to * and can invalidate it at any time. Thus an app can never be guaranteed that it will be able to

View File

@ -602,12 +602,12 @@ public interface ExoPlayer extends Player {
boolean getPauseAtEndOfMediaItems(); boolean getPauseAtEndOfMediaItems();
/** /**
* Enables audio offload scheduling, which runs ExoPlayer's main loop as rarely as possible when * Sets whether audio offload scheduling is enabled. If enabled, ExoPlayer's main loop will as
* playing an audio stream using audio offload. * rarely as possible when playing an audio stream using audio offload.
* *
* <p>Only use this scheduling mode if the player is not displaying anything to the user. For * <p>Only use this scheduling mode if the player is not displaying anything to the user. For
* example when the application is in the background, or the screen is off. The player state * example when the application is in the background, or the screen is off. The player state
* (including position) is rarely updated (between 10s and 1min). * (including position) is rarely updated (roughly between every 10 seconds and 1 minute).
* *
* <p>While offload scheduling is enabled, player events may be delivered severely delayed and * <p>While offload scheduling is enabled, player events may be delivered severely delayed and
* apps should not interact with the player. When returning to the foreground, disable offload * apps should not interact with the player. When returning to the foreground, disable offload
@ -626,7 +626,7 @@ public interface ExoPlayer extends Player {
* DefaultRenderersFactory#setEnableAudioOffload} or the equivalent option passed to {@link * DefaultRenderersFactory#setEnableAudioOffload} or the equivalent option passed to {@link
* com.google.android.exoplayer2.audio.DefaultAudioSink#DefaultAudioSink(AudioCapabilities, * com.google.android.exoplayer2.audio.DefaultAudioSink#DefaultAudioSink(AudioCapabilities,
* DefaultAudioSink.AudioProcessorChain, boolean, boolean, boolean)}. * DefaultAudioSink.AudioProcessorChain, boolean, boolean, boolean)}.
* <li>an audio track is playing in a format which the device supports offloading (for example * <li>an audio track is playing in a format which the device supports offloading (for example,
* MP3 or AAC). * MP3 or AAC).
* <li>The {@link com.google.android.exoplayer2.audio.AudioSink} is playing with an offload * <li>The {@link com.google.android.exoplayer2.audio.AudioSink} is playing with an offload
* {@link android.media.AudioTrack}. * {@link android.media.AudioTrack}.
@ -634,7 +634,7 @@ public interface ExoPlayer extends Player {
* *
* <p>This method is experimental, and will be renamed or removed in a future release. * <p>This method is experimental, and will be renamed or removed in a future release.
* *
* @param enableOffloadScheduling Whether to enable offload scheduling. * @param offloadSchedulingEnabled Whether to enable offload scheduling.
*/ */
void experimentalEnableOffloadScheduling(boolean enableOffloadScheduling); void experimentalSetOffloadSchedulingEnabled(boolean offloadSchedulingEnabled);
} }

View File

@ -210,8 +210,8 @@ import java.util.concurrent.TimeoutException;
} }
@Override @Override
public void experimentalEnableOffloadScheduling(boolean enableOffloadScheduling) { public void experimentalSetOffloadSchedulingEnabled(boolean offloadSchedulingEnabled) {
internalPlayer.experimentalEnableOffloadScheduling(enableOffloadScheduling); internalPlayer.experimentalSetOffloadSchedulingEnabled(offloadSchedulingEnabled);
} }
@Override @Override
@ -1366,7 +1366,7 @@ import java.util.concurrent.TimeoutException;
private final boolean playbackSuppressionReasonChanged; private final boolean playbackSuppressionReasonChanged;
private final boolean isPlayingChanged; private final boolean isPlayingChanged;
private final boolean playbackSpeedChanged; private final boolean playbackSpeedChanged;
private final boolean offloadSchedulingChanged; private final boolean offloadSchedulingEnabledChanged;
public PlaybackInfoUpdate( public PlaybackInfoUpdate(
PlaybackInfo playbackInfo, PlaybackInfo playbackInfo,
@ -1405,7 +1405,7 @@ import java.util.concurrent.TimeoutException;
previousPlaybackInfo.playbackSuppressionReason != playbackInfo.playbackSuppressionReason; previousPlaybackInfo.playbackSuppressionReason != playbackInfo.playbackSuppressionReason;
isPlayingChanged = isPlaying(previousPlaybackInfo) != isPlaying(playbackInfo); isPlayingChanged = isPlaying(previousPlaybackInfo) != isPlaying(playbackInfo);
playbackSpeedChanged = previousPlaybackInfo.playbackSpeed != playbackInfo.playbackSpeed; playbackSpeedChanged = previousPlaybackInfo.playbackSpeed != playbackInfo.playbackSpeed;
offloadSchedulingChanged = offloadSchedulingEnabledChanged =
previousPlaybackInfo.offloadSchedulingEnabled != playbackInfo.offloadSchedulingEnabled; previousPlaybackInfo.offloadSchedulingEnabled != playbackInfo.offloadSchedulingEnabled;
} }
@ -1484,7 +1484,7 @@ import java.util.concurrent.TimeoutException;
if (seekProcessed) { if (seekProcessed) {
invokeAll(listenerSnapshot, EventListener::onSeekProcessed); invokeAll(listenerSnapshot, EventListener::onSeekProcessed);
} }
if (offloadSchedulingChanged) { if (offloadSchedulingEnabledChanged) {
invokeAll( invokeAll(
listenerSnapshot, listenerSnapshot,
listener -> listener ->

View File

@ -141,7 +141,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
private static final int MSG_SET_SHUFFLE_ORDER = 21; private static final int MSG_SET_SHUFFLE_ORDER = 21;
private static final int MSG_PLAYLIST_UPDATE_REQUESTED = 22; private static final int MSG_PLAYLIST_UPDATE_REQUESTED = 22;
private static final int MSG_SET_PAUSE_AT_END_OF_WINDOW = 23; private static final int MSG_SET_PAUSE_AT_END_OF_WINDOW = 23;
private static final int MSG_SET_OFFLOAD_SCHEDULING = 24; private static final int MSG_SET_OFFLOAD_SCHEDULING_ENABLED = 24;
private static final int ACTIVE_INTERVAL_MS = 10; private static final int ACTIVE_INTERVAL_MS = 10;
private static final int IDLE_INTERVAL_MS = 1000; private static final int IDLE_INTERVAL_MS = 1000;
@ -188,7 +188,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
private boolean shuffleModeEnabled; private boolean shuffleModeEnabled;
private boolean foregroundMode; private boolean foregroundMode;
private boolean requestForRendererSleep; private boolean requestForRendererSleep;
private boolean enableOffloadScheduling; private boolean offloadSchedulingEnabled;
private int enabledRendererCount; private int enabledRendererCount;
@Nullable private SeekPosition pendingInitialSeekPosition; @Nullable private SeekPosition pendingInitialSeekPosition;
@ -263,9 +263,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
throwWhenStuckBuffering = false; throwWhenStuckBuffering = false;
} }
public void experimentalEnableOffloadScheduling(boolean enableOffloadScheduling) { public void experimentalSetOffloadSchedulingEnabled(boolean offloadSchedulingEnabled) {
handler handler
.obtainMessage(MSG_SET_OFFLOAD_SCHEDULING, enableOffloadScheduling ? 1 : 0, /* unused */ 0) .obtainMessage(
MSG_SET_OFFLOAD_SCHEDULING_ENABLED, offloadSchedulingEnabled ? 1 : 0, /* unused */ 0)
.sendToTarget(); .sendToTarget();
} }
@ -518,7 +519,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
case MSG_SET_PAUSE_AT_END_OF_WINDOW: case MSG_SET_PAUSE_AT_END_OF_WINDOW:
setPauseAtEndOfWindowInternal(msg.arg1 != 0); setPauseAtEndOfWindowInternal(msg.arg1 != 0);
break; break;
case MSG_SET_OFFLOAD_SCHEDULING: case MSG_SET_OFFLOAD_SCHEDULING_ENABLED:
setOffloadSchedulingEnabledInternal(msg.arg1 == 1); setOffloadSchedulingEnabledInternal(msg.arg1 == 1);
break; break;
case MSG_RELEASE: case MSG_RELEASE:
@ -739,14 +740,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
handleLoadingMediaPeriodChanged(/* loadingTrackSelectionChanged= */ false); handleLoadingMediaPeriodChanged(/* loadingTrackSelectionChanged= */ false);
} }
private void setOffloadSchedulingEnabledInternal(boolean enableOffloadScheduling) { private void setOffloadSchedulingEnabledInternal(boolean offloadSchedulingEnabled) {
if (enableOffloadScheduling == this.enableOffloadScheduling) { if (offloadSchedulingEnabled == this.offloadSchedulingEnabled) {
return; return;
} }
this.enableOffloadScheduling = enableOffloadScheduling; this.offloadSchedulingEnabled = offloadSchedulingEnabled;
@Player.State int state = playbackInfo.playbackState; @Player.State int state = playbackInfo.playbackState;
if (enableOffloadScheduling || state == Player.STATE_ENDED || state == Player.STATE_IDLE) { if (offloadSchedulingEnabled || state == Player.STATE_ENDED || state == Player.STATE_IDLE) {
playbackInfo = playbackInfo.copyWithOffloadSchedulingEnabled(enableOffloadScheduling); playbackInfo = playbackInfo.copyWithOffloadSchedulingEnabled(offloadSchedulingEnabled);
} else { } else {
handler.sendEmptyMessage(MSG_DO_SOME_WORK); handler.sendEmptyMessage(MSG_DO_SOME_WORK);
} }
@ -953,8 +954,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
throw new IllegalStateException("Playback stuck buffering and not loading"); throw new IllegalStateException("Playback stuck buffering and not loading");
} }
} }
if (enableOffloadScheduling != playbackInfo.offloadSchedulingEnabled) { if (offloadSchedulingEnabled != playbackInfo.offloadSchedulingEnabled) {
playbackInfo = playbackInfo.copyWithOffloadSchedulingEnabled(enableOffloadScheduling); playbackInfo = playbackInfo.copyWithOffloadSchedulingEnabled(offloadSchedulingEnabled);
} }
if ((shouldPlayWhenReady() && playbackInfo.playbackState == Player.STATE_READY) if ((shouldPlayWhenReady() && playbackInfo.playbackState == Player.STATE_READY)
@ -976,7 +977,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
} }
private void maybeScheduleWakeup(long operationStartTimeMs, long intervalMs) { private void maybeScheduleWakeup(long operationStartTimeMs, long intervalMs) {
if (enableOffloadScheduling && requestForRendererSleep) { if (offloadSchedulingEnabled && requestForRendererSleep) {
return; return;
} }
@ -1304,7 +1305,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
startPositionUs, startPositionUs,
/* totalBufferedDurationUs= */ 0, /* totalBufferedDurationUs= */ 0,
startPositionUs, startPositionUs,
enableOffloadScheduling); offloadSchedulingEnabled);
if (releaseMediaSourceList) { if (releaseMediaSourceList) {
mediaSourceList.release(); mediaSourceList.release();
} }

View File

@ -65,7 +65,7 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
@PlaybackSuppressionReason public final int playbackSuppressionReason; @PlaybackSuppressionReason public final int playbackSuppressionReason;
/** The playback speed. */ /** The playback speed. */
public final float playbackSpeed; public final float playbackSpeed;
/** Whether the player is in offloadScheduling. */ /** Whether offload scheduling is enabled for the main player loop. */
public final boolean offloadSchedulingEnabled; public final boolean offloadSchedulingEnabled;
/** /**

View File

@ -607,7 +607,7 @@ public interface Player {
/** /**
* Called when the player has started or stopped offload scheduling after a call to {@link * Called when the player has started or stopped offload scheduling after a call to {@link
* ExoPlayer#experimentalEnableOffloadScheduling(boolean)}. * ExoPlayer#experimentalSetOffloadSchedulingEnabled(boolean)}.
* *
* <p>This method is experimental, and will be renamed or removed in a future release. * <p>This method is experimental, and will be renamed or removed in a future release.
*/ */

View File

@ -630,8 +630,8 @@ public class SimpleExoPlayer extends BasePlayer
} }
@Override @Override
public void experimentalEnableOffloadScheduling(boolean enableOffloadScheduling) { public void experimentalSetOffloadSchedulingEnabled(boolean offloadSchedulingEnabled) {
player.experimentalEnableOffloadScheduling(enableOffloadScheduling); player.experimentalSetOffloadSchedulingEnabled(offloadSchedulingEnabled);
} }
@Override @Override

View File

@ -467,7 +467,7 @@ public abstract class StubExoPlayer extends BasePlayer implements ExoPlayer {
} }
@Override @Override
public void experimentalEnableOffloadScheduling(boolean enableOffloadScheduling) { public void experimentalSetOffloadSchedulingEnabled(boolean offloadSchedulingEnabled) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
} }