From 45a5a7584d43c5dcd0d55c03e07fce8f39da72de Mon Sep 17 00:00:00 2001 From: christosts Date: Wed, 17 Nov 2021 14:22:59 +0000 Subject: [PATCH] Enable immediate codec start after flush We verified there is a race condition in the AsynchronousMediaCodecAdapter when flushing the adapter multiple times. The race condition results in calling MediaCodec.start() and MediaCodec.flush() in parallel and that makes the MediaCodec raise an exception. This changes the default behavior to call MediaCodec.start() on the same thread after MediaCodec.flush() to avoid the race condition. #minor-release PiperOrigin-RevId: 410509388 --- .../exoplayer2/mediacodec/DefaultMediaCodecAdapterFactory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/DefaultMediaCodecAdapterFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/DefaultMediaCodecAdapterFactory.java index 2f12468f9e..9679bb0eab 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/DefaultMediaCodecAdapterFactory.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/DefaultMediaCodecAdapterFactory.java @@ -51,6 +51,7 @@ public final class DefaultMediaCodecAdapterFactory implements MediaCodecAdapter. public DefaultMediaCodecAdapterFactory() { asynchronousMode = MODE_DEFAULT; + enableImmediateCodecStartAfterFlush = true; } /** @@ -92,7 +93,7 @@ public final class DefaultMediaCodecAdapterFactory implements MediaCodecAdapter. * 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. + *

By default, this feature is enabled. * *

This method is experimental, and will be renamed or removed in a future release. *