diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java index 230fc2e03b..b817109c2b 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java @@ -171,25 +171,6 @@ public class DefaultRenderersFactory implements RenderersFactory { return this; } - /** - * Enable calling {@link MediaCodec#start} immediately after {@link MediaCodec#flush} on the - * playback thread, when operating the codec in asynchronous mode. If disabled, {@link - * MediaCodec#start} will be called by the callback thread after pending callbacks are handled. - * - *
By default, this feature is disabled. - * - *
This method is experimental, and will be renamed or removed in a future release.
- *
- * @param enabled Whether {@link MediaCodec#start} will be called on the playback thread
- * immediately after {@link MediaCodec#flush}.
- * @return This factory, for convenience.
- */
- public DefaultRenderersFactory experimentalSetImmediateCodecStartAfterFlushEnabled(
- boolean enabled) {
- codecAdapterFactory.experimentalSetImmediateCodecStartAfterFlushEnabled(enabled);
- return this;
- }
-
/**
* Sets whether to enable fallback to lower-priority decoders if decoder initialization fails.
* This may result in using a decoder that is less efficient or slower than the primary decoder.
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapter.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapter.java
index e013c4b990..91aa86ca06 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapter.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapter.java
@@ -54,7 +54,6 @@ import java.nio.ByteBuffer;
private final Supplier By default, this feature is enabled.
- *
- * This method is experimental, and will be renamed or removed in a future release.
- *
- * @param enabled Whether {@link MediaCodec#start()} will be called on the playback thread
- * immediately after {@link MediaCodec#flush}.
- */
- public void experimentalSetImmediateCodecStartAfterFlushEnabled(boolean enabled) {
- enableImmediateCodecStartAfterFlush = enabled;
- }
-
@Override
public MediaCodecAdapter createAdapter(MediaCodecAdapter.Configuration configuration)
throws IOException {
@@ -124,9 +105,7 @@ public final class DefaultMediaCodecAdapterFactory implements MediaCodecAdapter.
+ Util.getTrackTypeString(trackType));
AsynchronousMediaCodecAdapter.Factory factory =
new AsynchronousMediaCodecAdapter.Factory(
- trackType,
- enableSynchronizeCodecInteractionsWithQueueing,
- enableImmediateCodecStartAfterFlush);
+ trackType, enableSynchronizeCodecInteractionsWithQueueing);
return factory.createAdapter(configuration);
}
return new SynchronousMediaCodecAdapter.Factory().createAdapter(configuration);
diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapterTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapterTest.java
index 0401f95e1d..98707a3226 100644
--- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapterTest.java
+++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapterTest.java
@@ -54,8 +54,7 @@ public class AsynchronousMediaCodecAdapterTest {
new AsynchronousMediaCodecAdapter.Factory(
/* callbackThreadSupplier= */ () -> callbackThread,
/* queueingThreadSupplier= */ () -> queueingThread,
- /* synchronizeCodecInteractionsWithQueueing= */ false,
- /* enableImmediateCodecStartAfterFlush= */ false)
+ /* synchronizeCodecInteractionsWithQueueing= */ false)
.createAdapter(configuration);
bufferInfo = new MediaCodec.BufferInfo();
// After starting the MediaCodec, the ShadowMediaCodec offers input buffer 0. We advance the
diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecCallbackTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecCallbackTest.java
index fea229347e..81df9fd6fb 100644
--- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecCallbackTest.java
+++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecCallbackTest.java
@@ -94,7 +94,7 @@ public class AsynchronousMediaCodecCallbackTest {
asynchronousMediaCodecCallback.onInputBufferAvailable(codec, 0);
asynchronousMediaCodecCallback.onInputBufferAvailable(codec, 1);
callbackHandler.post(() -> beforeFlushCompletes.set(true));
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
callbackHandler.post(() -> flushCompleted.set(true));
while (!beforeFlushCompletes.get()) {
shadowCallbackLooper.runOneTask();
@@ -113,7 +113,7 @@ public class AsynchronousMediaCodecCallbackTest {
// Send two input buffers to the callback and then flush().
asynchronousMediaCodecCallback.onInputBufferAvailable(codec, 0);
asynchronousMediaCodecCallback.onInputBufferAvailable(codec, 1);
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
new Handler(callbackThreadLooper).post(() -> flushCompleted.set(true));
// Progress the callback thread so that flush() completes.
shadowOf(callbackThreadLooper).idle();
@@ -132,7 +132,7 @@ public class AsynchronousMediaCodecCallbackTest {
// another input buffer.
asynchronousMediaCodecCallback.onInputBufferAvailable(codec, 0);
asynchronousMediaCodecCallback.onInputBufferAvailable(codec, 1);
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
new Handler(callbackThreadLooper).post(() -> flushCompleted.set(true));
// Progress the callback thread to complete flush.
shadowOf(callbackThread.getLooper()).idle();
@@ -207,7 +207,7 @@ public class AsynchronousMediaCodecCallbackTest {
asynchronousMediaCodecCallback.onOutputBufferAvailable(codec, 0, bufferInfo);
asynchronousMediaCodecCallback.onOutputBufferAvailable(codec, 1, bufferInfo);
callbackHandler.post(() -> beforeFlushCompletes.set(true));
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
callbackHandler.post(() -> flushCompleted.set(true));
while (beforeFlushCompletes.get()) {
shadowCallbackLooper.runOneTask();
@@ -227,7 +227,7 @@ public class AsynchronousMediaCodecCallbackTest {
MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
asynchronousMediaCodecCallback.onOutputBufferAvailable(codec, 0, bufferInfo);
asynchronousMediaCodecCallback.onOutputBufferAvailable(codec, 1, bufferInfo);
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
new Handler(callbackThreadLooper).post(() -> flushCompleted.set(true));
// Progress the callback looper so that flush() completes.
shadowOf(callbackThreadLooper).idle();
@@ -248,7 +248,7 @@ public class AsynchronousMediaCodecCallbackTest {
asynchronousMediaCodecCallback.onOutputFormatChanged(codec, createMediaFormat("format0"));
asynchronousMediaCodecCallback.onOutputBufferAvailable(codec, 0, bufferInfo);
asynchronousMediaCodecCallback.onOutputBufferAvailable(codec, 1, bufferInfo);
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
new Handler(callbackThreadLooper).post(() -> flushCompleted.set(true));
// Progress the callback looper so that flush() completes.
shadowOf(callbackThreadLooper).idle();
@@ -275,7 +275,7 @@ public class AsynchronousMediaCodecCallbackTest {
MediaFormat pendingMediaFormat = new MediaFormat();
asynchronousMediaCodecCallback.onOutputFormatChanged(codec, pendingMediaFormat);
// flush() should not discard the last format.
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
new Handler(callbackThreadLooper).post(() -> flushCompleted.set(true));
// Progress the callback looper so that flush() completes.
shadowOf(callbackThreadLooper).idle();
@@ -302,7 +302,7 @@ public class AsynchronousMediaCodecCallbackTest {
MediaFormat pendingMediaFormat = new MediaFormat();
asynchronousMediaCodecCallback.onOutputFormatChanged(codec, pendingMediaFormat);
// flush() should not discard the last format.
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
new Handler(callbackThreadLooper).post(() -> flushCompleted.set(true));
// Progress the callback looper so that flush() completes.
shadowOf(callbackThreadLooper).idle();
@@ -367,7 +367,7 @@ public class AsynchronousMediaCodecCallbackTest {
asynchronousMediaCodecCallback.onOutputFormatChanged(codec, format);
asynchronousMediaCodecCallback.dequeueOutputBufferIndex(new MediaCodec.BufferInfo());
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
new Handler(callbackThreadLooper).post(() -> flushCompleted.set(true));
// Progress the callback looper so that flush() completes.
shadowOf(callbackThreadLooper).idle();
@@ -390,7 +390,7 @@ public class AsynchronousMediaCodecCallbackTest {
asynchronousMediaCodecCallback.onOutputFormatChanged(codec, createMediaFormat("format1"));
asynchronousMediaCodecCallback.onOutputBufferAvailable(
codec, /* index= */ 1, new MediaCodec.BufferInfo());
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
new Handler(callbackThreadLooper).post(() -> flushCompleted.set(true));
// Progress the looper so that flush is completed
shadowCallbackLooper.idle();
@@ -419,11 +419,11 @@ public class AsynchronousMediaCodecCallbackTest {
asynchronousMediaCodecCallback.onOutputBufferAvailable(
codec, /* index= */ 0, new MediaCodec.BufferInfo());
// Flush and progress the looper so that flush is completed.
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
callbackThreadHandler.post(flushCompleted::incrementAndGet);
shadowCallbackLooper.idle();
// Flush again, the pending format from the first flush should remain as pending.
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
callbackThreadHandler.post(flushCompleted::incrementAndGet);
shadowCallbackLooper.idle();
asynchronousMediaCodecCallback.onOutputBufferAvailable(
@@ -441,7 +441,7 @@ public class AsynchronousMediaCodecCallbackTest {
public void flush_withPendingError_resetsError() throws Exception {
asynchronousMediaCodecCallback.onError(codec, createCodecException());
// Calling flush should clear any pending error.
- asynchronousMediaCodecCallback.flush(/* codec= */ null);
+ asynchronousMediaCodecCallback.flush();
assertThat(asynchronousMediaCodecCallback.dequeueInputBufferIndex())
.isEqualTo(MediaCodec.INFO_TRY_AGAIN_LATER);