Change default value of throwWhenStuckBuffering to true.

This change caused no problems and can be enabled by default.

PiperOrigin-RevId: 325264859
This commit is contained in:
tonihei 2020-08-06 18:54:58 +01:00 committed by kim-vde
parent 092c66fac3
commit eee9b312dc
6 changed files with 12 additions and 30 deletions

View File

@ -215,6 +215,7 @@ public interface ExoPlayer extends Player {
useLazyPreparation = true;
seekParameters = SeekParameters.DEFAULT;
clock = Clock.DEFAULT;
throwWhenStuckBuffering = true;
}
/**
@ -411,8 +412,8 @@ public interface ExoPlayer extends Player {
if (releaseTimeoutMs > 0) {
player.experimental_setReleaseTimeoutMs(releaseTimeoutMs);
}
if (throwWhenStuckBuffering) {
player.experimental_throwWhenStuckBuffering();
if (!throwWhenStuckBuffering) {
player.experimental_disableThrowWhenStuckBuffering();
}
return player;

View File

@ -200,13 +200,13 @@ import java.util.concurrent.TimeoutException;
}
/**
* Configures the player to throw when it detects it's stuck buffering.
* Configures the player to not throw when it detects it's stuck buffering.
*
* <p>This method is experimental, and will be renamed or removed in a future release. It should
* only be called before the player is used.
*/
public void experimental_throwWhenStuckBuffering() {
internalPlayer.experimental_throwWhenStuckBuffering();
public void experimental_disableThrowWhenStuckBuffering() {
internalPlayer.experimental_disableThrowWhenStuckBuffering();
}
@Override

View File

@ -224,6 +224,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
this.pauseAtEndOfWindow = pauseAtEndOfWindow;
this.clock = clock;
throwWhenStuckBuffering = true;
backBufferDurationUs = loadControl.getBackBufferDurationUs();
retainBackBufferFromKeyframe = loadControl.retainBackBufferFromKeyframe();
@ -257,8 +258,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
this.releaseTimeoutMs = releaseTimeoutMs;
}
public void experimental_throwWhenStuckBuffering() {
throwWhenStuckBuffering = true;
public void experimental_disableThrowWhenStuckBuffering() {
throwWhenStuckBuffering = false;
}
public void experimental_enableOffloadScheduling(boolean enableOffloadScheduling) {

View File

@ -206,6 +206,7 @@ public class SimpleExoPlayer extends BasePlayer
useLazyPreparation = true;
seekParameters = SeekParameters.DEFAULT;
clock = Clock.DEFAULT;
throwWhenStuckBuffering = true;
}
/**
@ -618,8 +619,8 @@ public class SimpleExoPlayer extends BasePlayer
wifiLockManager = new WifiLockManager(builder.context);
wifiLockManager.setEnabled(builder.wakeMode == C.WAKE_MODE_NETWORK);
deviceInfo = createDeviceInfo(streamVolumeManager);
if (builder.throwWhenStuckBuffering) {
player.experimental_throwWhenStuckBuffering();
if (!builder.throwWhenStuckBuffering) {
player.experimental_disableThrowWhenStuckBuffering();
}
sendRendererMessage(C.TRACK_TYPE_AUDIO, Renderer.MSG_SET_AUDIO_ATTRIBUTES, audioAttributes);

View File

@ -115,7 +115,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatcher;
@ -4588,8 +4587,6 @@ public final class ExoPlayerTest {
testRunner.blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
}
// Disabled until the flag to throw exceptions for [internal: b/144538905] is enabled by default.
@Ignore
@Test
public void loadControlNeverWantsToLoad_throwsIllegalStateException() {
LoadControl neverLoadingLoadControl =
@ -4697,7 +4694,6 @@ public final class ExoPlayerTest {
new TestExoPlayer.Builder(context)
.setRenderers(rendererWaitingForData)
.setLoadControl(loadControlWithMaxBufferUs)
.experimental_setThrowWhenStuckBuffering(true)
.build();
player.setMediaSource(mediaSourceWithLoadInProgress);
player.prepare();
@ -7334,8 +7330,6 @@ public final class ExoPlayerTest {
assertThat(positionAfterPause.get()).isEqualTo(10_000);
}
// Disabled until the flag to throw exceptions for [internal: b/144538905] is enabled by default.
@Ignore
@Test
public void
infiniteLoading_withSmallAllocations_oomIsPreventedByLoadControl_andThrowsStuckBufferingIllegalStateException() {

View File

@ -61,7 +61,6 @@ public class TestExoPlayer {
@Nullable private Renderer[] renderers;
@Nullable private RenderersFactory renderersFactory;
private boolean useLazyPreparation;
private boolean throwWhenStuckBuffering;
private @MonotonicNonNull Looper looper;
public Builder(Context context) {
@ -231,19 +230,6 @@ public class TestExoPlayer {
return looper;
}
/**
* Sets whether the player should throw when it detects it's stuck buffering.
*
* <p>This method is experimental, and will be renamed or removed in a future release.
*
* @param throwWhenStuckBuffering Whether to throw when the player detects it's stuck buffering.
* @return This builder.
*/
public Builder experimental_setThrowWhenStuckBuffering(boolean throwWhenStuckBuffering) {
this.throwWhenStuckBuffering = throwWhenStuckBuffering;
return this;
}
/**
* Builds an {@link SimpleExoPlayer} using the provided values or their defaults.
*
@ -278,7 +264,6 @@ public class TestExoPlayer {
.setClock(clock)
.setUseLazyPreparation(useLazyPreparation)
.setLooper(looper)
.experimental_setThrowWhenStuckBuffering(throwWhenStuckBuffering)
.build();
}
}