From c7c75173224057defd031aa30bbf8346442700a6 Mon Sep 17 00:00:00 2001 From: bachinger Date: Sat, 5 Mar 2022 14:16:43 +0000 Subject: [PATCH] Ignore MetadataRenderer when evaluating SSAI period transitions This makes the reading period advance early as expected at the end of an ad period. Before this change the reading position of the metadata renderer prevented advancing the period until metadata arrived after the start position of the following period. Only then the reading position of the metadata renderer is updated and beyond the start position of the following period which is a condition to advance the reading period. Because transitioning to the next period is a virtual transition and the SharedMediaPeriod keeps reading from the same underlying sample streams, the metadata renderer can safely be ignored for this check. #minor-release PiperOrigin-RevId: 432646037 --- .../java/androidx/media3/exoplayer/ExoPlayerImplInternal.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImplInternal.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImplInternal.java index 99896816ae0..84bd8ebbf73 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImplInternal.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImplInternal.java @@ -56,6 +56,7 @@ import androidx.media3.exoplayer.analytics.AnalyticsCollector; import androidx.media3.exoplayer.analytics.PlayerId; import androidx.media3.exoplayer.drm.DrmSession; +import androidx.media3.exoplayer.metadata.MetadataRenderer; import androidx.media3.exoplayer.source.BehindLiveWindowException; import androidx.media3.exoplayer.source.MediaPeriod; import androidx.media3.exoplayer.source.MediaSource.MediaPeriodId; @@ -2228,6 +2229,7 @@ private boolean hasReachedServerSideInsertedAdsTransition( return reading.info.isFollowedByTransitionToSameStream && nextPeriod.prepared && (renderer instanceof TextRenderer // [internal: b/181312195] + || renderer instanceof MetadataRenderer || renderer.getReadingPositionUs() >= nextPeriod.getStartPositionRendererTime()); }