-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
MaskingMediaSource needs to resolve the prepare position set for a MaskingPeriod while the source was still unprepared to the first actual prepare position. It currently assumes that the period-window offset and the default position is zero. This assumption is correct when a PlaceholderTimeline is used, but it may not be true if the real timeline is already known (e.g. when re-preparing a live stream after a playback error). Fix this by using the known timeline at the time of the preparation. Also: - Update a test that should have caught this to use lazy re-preparation. - Change the demo app code to use the recommended way to restart playback after a BehindLiveWindowException. Issue: #8675 PiperOrigin-RevId: 361604191
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,13 +178,17 @@ protected void onChildSourceInfoRefreshed( | |
// anyway. | ||
newTimeline.getWindow(/* windowIndex= */ 0, window); | ||
long windowStartPositionUs = window.getDefaultPositionUs(); | ||
Object windowUid = window.uid; | ||
if (unpreparedMaskingMediaPeriod != null) { | ||
long periodPreparePositionUs = unpreparedMaskingMediaPeriod.getPreparePositionUs(); | ||
if (periodPreparePositionUs != 0) { | ||
windowStartPositionUs = periodPreparePositionUs; | ||
timeline.getPeriodByUid(unpreparedMaskingMediaPeriod.id.periodUid, period); | ||
long windowPreparePositionUs = period.getPositionInWindowUs() + periodPreparePositionUs; | ||
long oldWindowDefaultPositionUs = | ||
timeline.getWindow(/* windowIndex= */ 0, window).getDefaultPositionUs(); | ||
if (windowPreparePositionUs != oldWindowDefaultPositionUs) { | ||
windowStartPositionUs = windowPreparePositionUs; | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
stevemayhew
Contributor
|
||
} | ||
Object windowUid = window.uid; | ||
Pair<Object, Long> periodPosition = | ||
newTimeline.getPeriodPosition( | ||
window, period, /* windowIndex= */ 0, windowStartPositionUs); | ||
|
This if test incorrectly fails to override the default window start position with the initial seek if the seek is to position 0. This is because the default position was never set in the masking period and the "unset" value is also 0.