From 25e56804152ddd86ab782286a550ab34a3b7dd31 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 --- RELEASENOTES.md | 2 ++ .../com/google/android/exoplayer2/ExoPlayerImplInternal.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index abbc034835..2cde6c31c7 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -32,6 +32,8 @@ * RTSP: * Add RTP reader for HEVC ([#36](https://github.com/androidx/media/pull/36)). +* Ad playback: + * Fix audio underruns between ad periods in live HLS SSAI streams. * Remove deprecated symbols: * Remove `Player.Listener.onTracksChanged`. Use `Player.Listener.onTracksInfoChanged` instead. diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java index cfa929af56..74e0d386f0 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java @@ -39,6 +39,7 @@ import com.google.android.exoplayer2.analytics.AnalyticsCollector; import com.google.android.exoplayer2.analytics.PlayerId; import com.google.android.exoplayer2.drm.DrmSession; import com.google.android.exoplayer2.metadata.Metadata; +import com.google.android.exoplayer2.metadata.MetadataRenderer; import com.google.android.exoplayer2.source.BehindLiveWindowException; import com.google.android.exoplayer2.source.MediaPeriod; import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; @@ -2220,6 +2221,7 @@ import java.util.concurrent.atomic.AtomicBoolean; return reading.info.isFollowedByTransitionToSameStream && nextPeriod.prepared && (renderer instanceof TextRenderer // [internal: b/181312195] + || renderer instanceof MetadataRenderer || renderer.getReadingPositionUs() >= nextPeriod.getStartPositionRendererTime()); }