Commit c4171d50 by bachinger Committed by Oliver Woodman

Remove MediaSourceList.maybeThrowSourceInfoRefreshError

The method has been called from two call sites in EPII triggered by EPII.updatePeriods(). The first call site was calling it when the MediaSourceList is empty or not yet prepared. This can be removed because if empty or not prepared no source ever could have thrown yet.

The second call site was checking for potential source refresh exceptions when queue.getNextMediaPeriodInfo() returns null when trying to getting the next loading period. Looking into all reasons for why the method returns null, none of them is caused by an exception of a media source. The reasons are:

- if we are at the last period of the timeline
- if the defaultPosition of the next period in the timeline is null (if the window.durationUs == C.TIME_UNSET or defaultPositionProjectionUs is projected beyond the duration of the window)
- if we are waiting for an ad uri to arrive (period.isAdAvailable(...) == false)
- if we are waiting for the ad group count to be updated (adCountInCurrentAdGroup == C.LENGTH_UNSET)

The above reasons are not caused by a source error and may be resolved when doSomeWork is called the next time. Hence it is save to remove the calls to maybeThrowSourceInfoRefreshError().

Beside this, an actual sourceInfoRefreshError will be reported by maskingMediaSource.maybeThrowPrepareError(), which is called each time doSomeWork() is called and the playing period is not yet prepared (EPII:L836). So the player is notified by source errors that way, which confirms removing the above calls is fine.

PiperOrigin-RevId: 321331777
parent aa676850
...@@ -1627,19 +1627,6 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -1627,19 +1627,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|| !shouldPlayWhenReady()); || !shouldPlayWhenReady());
} }
private void maybeThrowSourceInfoRefreshError() throws IOException {
MediaPeriodHolder loadingPeriodHolder = queue.getLoadingPeriod();
if (loadingPeriodHolder != null) {
// Defer throwing until we read all available media periods.
for (Renderer renderer : renderers) {
if (isRendererEnabled(renderer) && !renderer.hasReadStreamToEnd()) {
return;
}
}
}
mediaSourceList.maybeThrowSourceInfoRefreshError();
}
private void handleMediaSourceListInfoRefreshed(Timeline timeline) throws ExoPlaybackException { private void handleMediaSourceListInfoRefreshed(Timeline timeline) throws ExoPlaybackException {
PositionUpdateForPlaylistChange positionUpdate = PositionUpdateForPlaylistChange positionUpdate =
resolvePositionForPlaylistChange( resolvePositionForPlaylistChange(
...@@ -1733,8 +1720,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -1733,8 +1720,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
private void updatePeriods() throws ExoPlaybackException, IOException { private void updatePeriods() throws ExoPlaybackException, IOException {
if (playbackInfo.timeline.isEmpty() || !mediaSourceList.isPrepared()) { if (playbackInfo.timeline.isEmpty() || !mediaSourceList.isPrepared()) {
// We're waiting to get information about periods. // No periods available.
mediaSourceList.maybeThrowSourceInfoRefreshError();
return; return;
} }
maybeUpdateLoadingPeriod(); maybeUpdateLoadingPeriod();
...@@ -1743,13 +1729,12 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -1743,13 +1729,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
maybeUpdatePlayingPeriod(); maybeUpdatePlayingPeriod();
} }
private void maybeUpdateLoadingPeriod() throws ExoPlaybackException, IOException { private void maybeUpdateLoadingPeriod() throws ExoPlaybackException {
queue.reevaluateBuffer(rendererPositionUs); queue.reevaluateBuffer(rendererPositionUs);
if (queue.shouldLoadNextMediaPeriod()) { if (queue.shouldLoadNextMediaPeriod()) {
@Nullable
MediaPeriodInfo info = queue.getNextMediaPeriodInfo(rendererPositionUs, playbackInfo); MediaPeriodInfo info = queue.getNextMediaPeriodInfo(rendererPositionUs, playbackInfo);
if (info == null) { if (info != null) {
maybeThrowSourceInfoRefreshError();
} else {
MediaPeriodHolder mediaPeriodHolder = MediaPeriodHolder mediaPeriodHolder =
queue.enqueueNextMediaPeriodHolder( queue.enqueueNextMediaPeriodHolder(
rendererCapabilities, rendererCapabilities,
......
...@@ -575,6 +575,7 @@ import com.google.common.collect.ImmutableList; ...@@ -575,6 +575,7 @@ import com.google.common.collect.ImmutableList;
/** /**
* Returns the first {@link MediaPeriodInfo} to play, based on the specified playback position. * Returns the first {@link MediaPeriodInfo} to play, based on the specified playback position.
*/ */
@Nullable
private MediaPeriodInfo getFirstMediaPeriodInfo(PlaybackInfo playbackInfo) { private MediaPeriodInfo getFirstMediaPeriodInfo(PlaybackInfo playbackInfo) {
return getMediaPeriodInfo( return getMediaPeriodInfo(
playbackInfo.timeline, playbackInfo.timeline,
...@@ -729,6 +730,7 @@ import com.google.common.collect.ImmutableList; ...@@ -729,6 +730,7 @@ import com.google.common.collect.ImmutableList;
} }
} }
@Nullable
private MediaPeriodInfo getMediaPeriodInfo( private MediaPeriodInfo getMediaPeriodInfo(
Timeline timeline, MediaPeriodId id, long requestedContentPositionUs, long startPositionUs) { Timeline timeline, MediaPeriodId id, long requestedContentPositionUs, long startPositionUs) {
timeline.getPeriodByUid(id.periodUid, period); timeline.getPeriodByUid(id.periodUid, period);
......
...@@ -342,13 +342,6 @@ import java.util.Set; ...@@ -342,13 +342,6 @@ import java.util.Set;
isPrepared = false; isPrepared = false;
} }
/** Throws any pending error encountered while loading or refreshing. */
public void maybeThrowSourceInfoRefreshError() throws IOException {
for (MediaSourceAndListener childSource : childSources.values()) {
childSource.mediaSource.maybeThrowSourceInfoRefreshError();
}
}
/** Creates a timeline reflecting the current state of the playlist. */ /** Creates a timeline reflecting the current state of the playlist. */
public Timeline createTimeline() { public Timeline createTimeline() {
if (mediaSourceHolders.isEmpty()) { if (mediaSourceHolders.isEmpty()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment