Commit 66c1aede by aquilescanta Committed by Oliver Woodman

Assign ERROR_CODE_BEHIND_LIVE_WINDOW to BehindLiveWindowExceptions

PiperOrigin-RevId: 374425179
parent 73f28d48
...@@ -114,7 +114,18 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -114,7 +114,18 @@ public final class ExoPlaybackException extends PlaybackException {
* @return The created instance. * @return The created instance.
*/ */
public static ExoPlaybackException createForSource(IOException cause) { public static ExoPlaybackException createForSource(IOException cause) {
return new ExoPlaybackException(TYPE_SOURCE, cause, ERROR_CODE_UNSPECIFIED); return createForSource(cause, ERROR_CODE_UNSPECIFIED);
}
/**
* Creates an instance of type {@link #TYPE_SOURCE}.
*
* @param cause The cause of the failure.
* @param errorCode See {@link #errorCode}.
* @return The created instance.
*/
public static ExoPlaybackException createForSource(IOException cause, int errorCode) {
return new ExoPlaybackException(TYPE_SOURCE, cause, errorCode);
} }
/** /**
......
...@@ -35,6 +35,7 @@ import com.google.android.exoplayer2.Player.PlaybackSuppressionReason; ...@@ -35,6 +35,7 @@ import com.google.android.exoplayer2.Player.PlaybackSuppressionReason;
import com.google.android.exoplayer2.Player.RepeatMode; import com.google.android.exoplayer2.Player.RepeatMode;
import com.google.android.exoplayer2.analytics.AnalyticsCollector; import com.google.android.exoplayer2.analytics.AnalyticsCollector;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.source.BehindLiveWindowException;
import com.google.android.exoplayer2.source.MediaPeriod; import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.SampleStream; import com.google.android.exoplayer2.source.SampleStream;
...@@ -570,16 +571,10 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -570,16 +571,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
stopInternal(/* forceResetRenderers= */ true, /* acknowledgeStop= */ false); stopInternal(/* forceResetRenderers= */ true, /* acknowledgeStop= */ false);
playbackInfo = playbackInfo.copyWithPlaybackError(e); playbackInfo = playbackInfo.copyWithPlaybackError(e);
} }
} catch (BehindLiveWindowException e) {
handleIoException(e, PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW);
} catch (IOException e) { } catch (IOException e) {
ExoPlaybackException error = ExoPlaybackException.createForSource(e); handleIoException(e, PlaybackException.ERROR_CODE_UNSPECIFIED);
@Nullable MediaPeriodHolder playingPeriod = queue.getPlayingPeriod();
if (playingPeriod != null) {
// We ensure that all IOException throwing methods are only executed for the playing period.
error = error.copyWithMediaPeriodId(playingPeriod.info.id);
}
Log.e(TAG, "Playback error", error);
stopInternal(/* forceResetRenderers= */ false, /* acknowledgeStop= */ false);
playbackInfo = playbackInfo.copyWithPlaybackError(error);
} catch (RuntimeException e) { } catch (RuntimeException e) {
ExoPlaybackException error = ExoPlaybackException.createForUnexpected(e); ExoPlaybackException error = ExoPlaybackException.createForUnexpected(e);
Log.e(TAG, "Playback error", error); Log.e(TAG, "Playback error", error);
...@@ -592,6 +587,18 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -592,6 +587,18 @@ import java.util.concurrent.atomic.AtomicBoolean;
// Private methods. // Private methods.
private void handleIoException(IOException e, @PlaybackException.ErrorCode int errorCode) {
ExoPlaybackException error = ExoPlaybackException.createForSource(e, errorCode);
@Nullable MediaPeriodHolder playingPeriod = queue.getPlayingPeriod();
if (playingPeriod != null) {
// We ensure that all IOException throwing methods are only executed for the playing period.
error = error.copyWithMediaPeriodId(playingPeriod.info.id);
}
Log.e(TAG, "Playback error", error);
stopInternal(/* forceResetRenderers= */ false, /* acknowledgeStop= */ false);
playbackInfo = playbackInfo.copyWithPlaybackError(error);
}
/** /**
* Blocks the current thread until a condition becomes true or the specified amount of time has * Blocks the current thread until a condition becomes true or the specified amount of time has
* elapsed. * elapsed.
......
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