From 319854d624a95d3f71a26c96ecb4e5827d4a7f4e Mon Sep 17 00:00:00 2001 From: bachinger Date: Fri, 9 Jun 2023 10:01:53 +0000 Subject: [PATCH] Do not reset period uid when DashMediaSource is released When the source is prepared again after stop, the period uid is calculated by subtracting the `firstPeriodId` from the period uid that is passed in to `createPeriod`. When this happens after stop, the uid from the old period uid that is still stored and has the value of the last played uid. Hence the `firstPeriodId` must not be reset when released. Issue: google/ExoPlayer#10838 PiperOrigin-RevId: 539028570 --- RELEASENOTES.md | 3 +++ .../java/androidx/media3/exoplayer/dash/DashMediaSource.java | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 9c3f5b4793d..427d969451a 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -87,6 +87,9 @@ * Cronet Extension: * RTMP Extension: * DASH Extension: + * Fix a bug where re-preparing a multi-period live Dash media source + produced a `IndexOutOfBoundsException` + ([#10838](https://github.com/google/ExoPlayer/issues/10838)). * HLS Extension: * Smooth Streaming Extension: * RTSP Extension: diff --git a/libraries/exoplayer_dash/src/main/java/androidx/media3/exoplayer/dash/DashMediaSource.java b/libraries/exoplayer_dash/src/main/java/androidx/media3/exoplayer/dash/DashMediaSource.java index aa476b7db92..fede790776e 100644 --- a/libraries/exoplayer_dash/src/main/java/androidx/media3/exoplayer/dash/DashMediaSource.java +++ b/libraries/exoplayer_dash/src/main/java/androidx/media3/exoplayer/dash/DashMediaSource.java @@ -525,7 +525,7 @@ public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long star DrmSessionEventListener.EventDispatcher drmEventDispatcher = createDrmEventDispatcher(id); DashMediaPeriod mediaPeriod = new DashMediaPeriod( - firstPeriodId + periodIndex, + /* id= */ firstPeriodId + periodIndex, manifest, baseUrlExclusionList, periodIndex, @@ -573,7 +573,6 @@ protected void releaseSourceInternal() { elapsedRealtimeOffsetMs = C.TIME_UNSET; staleManifestReloadAttempt = 0; expiredManifestPublishTimeUs = C.TIME_UNSET; - firstPeriodId = 0; periodsById.clear(); baseUrlExclusionList.reset(); drmSessionManager.release();