mirror of
https://github.com/samsonjs/media.git
synced 2026-04-03 10:55:48 +00:00
Prevent deletion of unprepared periods.
When a new Timeline arrives in the Player, we check whether we can keep existing MediaPeriods. This check currently involves a condition that checks if the MediaPeriod is already prepared. The only reason we do that is to avoid calling MediaPeriod.seekToUs, which is not allowed on an unprepared MediaPeriod. It's better to keep the MediaPeriod to prevent restarting the preparation process. The prepration check can move further down to the place right before we would call seekToUs. PiperOrigin-RevId: 297812584
This commit is contained in:
parent
3ef0015817
commit
91a87b3fa0
1 changed files with 9 additions and 4 deletions
|
|
@ -971,11 +971,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
setState(Player.STATE_BUFFERING);
|
||||
}
|
||||
|
||||
// Find the requested period if it's already prepared.
|
||||
// Find the requested period if it already exists.
|
||||
@Nullable MediaPeriodHolder oldPlayingPeriodHolder = queue.getPlayingPeriod();
|
||||
@Nullable MediaPeriodHolder newPlayingPeriodHolder = oldPlayingPeriodHolder;
|
||||
while (newPlayingPeriodHolder != null) {
|
||||
if (periodId.equals(newPlayingPeriodHolder.info.id) && newPlayingPeriodHolder.prepared) {
|
||||
if (periodId.equals(newPlayingPeriodHolder.info.id)) {
|
||||
break;
|
||||
}
|
||||
newPlayingPeriodHolder = newPlayingPeriodHolder.getNext();
|
||||
|
|
@ -1004,7 +1004,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
// Do the actual seeking.
|
||||
if (newPlayingPeriodHolder != null) {
|
||||
queue.removeAfter(newPlayingPeriodHolder);
|
||||
if (newPlayingPeriodHolder.hasEnabledTracks) {
|
||||
if (!newPlayingPeriodHolder.prepared) {
|
||||
newPlayingPeriodHolder.info =
|
||||
newPlayingPeriodHolder.info.copyWithStartPositionUs(periodPositionUs);
|
||||
} else if (newPlayingPeriodHolder.hasEnabledTracks) {
|
||||
periodPositionUs = newPlayingPeriodHolder.mediaPeriod.seekToUs(periodPositionUs);
|
||||
newPlayingPeriodHolder.mediaPeriod.discardBuffer(
|
||||
periodPositionUs - backBufferDurationUs, retainBackBufferFromKeyframe);
|
||||
|
|
@ -1896,7 +1899,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
private PlaybackInfo copyWithNewPosition(
|
||||
MediaPeriodId mediaPeriodId, long positionUs, long contentPositionUs) {
|
||||
deliverPendingMessageAtStartPositionRequired =
|
||||
positionUs != playbackInfo.positionUs || !mediaPeriodId.equals(playbackInfo.periodId);
|
||||
deliverPendingMessageAtStartPositionRequired
|
||||
|| positionUs != playbackInfo.positionUs
|
||||
|| !mediaPeriodId.equals(playbackInfo.periodId);
|
||||
TrackGroupArray trackGroupArray = playbackInfo.trackGroups;
|
||||
TrackSelectorResult trackSelectorResult = playbackInfo.trackSelectorResult;
|
||||
if (playlist.isPrepared()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue