Commit 1cc62c65 by aquilescanta Committed by Oliver Woodman

Add @ErrorCode to local variables in ExoPlayerImplInternal

PiperOrigin-RevId: 381236418
parent cca4ac73
...@@ -33,6 +33,7 @@ import androidx.annotation.DoNotInline; ...@@ -33,6 +33,7 @@ import androidx.annotation.DoNotInline;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.DefaultMediaClock.PlaybackParametersListener; import com.google.android.exoplayer2.DefaultMediaClock.PlaybackParametersListener;
import com.google.android.exoplayer2.PlaybackException.ErrorCode;
import com.google.android.exoplayer2.Player.DiscontinuityReason; import com.google.android.exoplayer2.Player.DiscontinuityReason;
import com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason; import com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason;
import com.google.android.exoplayer2.Player.PlaybackSuppressionReason; import com.google.android.exoplayer2.Player.PlaybackSuppressionReason;
...@@ -581,7 +582,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -581,7 +582,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
} }
} catch (FileDataSource.FileDataSourceException e) { } catch (FileDataSource.FileDataSourceException e) {
@Nullable Throwable cause = e.getCause(); @Nullable Throwable cause = e.getCause();
int errorCode = PlaybackException.ERROR_CODE_IO_UNSPECIFIED; @ErrorCode int errorCode;
if (cause instanceof FileNotFoundException) { if (cause instanceof FileNotFoundException) {
if (Util.SDK_INT >= 21 && ErrnoExceptionWrapperV21.isPermissionError(cause.getCause())) { if (Util.SDK_INT >= 21 && ErrnoExceptionWrapperV21.isPermissionError(cause.getCause())) {
errorCode = PlaybackException.ERROR_CODE_IO_NO_PERMISSION; errorCode = PlaybackException.ERROR_CODE_IO_NO_PERMISSION;
...@@ -590,10 +591,12 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -590,10 +591,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
} }
} else if (cause instanceof SecurityException) { } else if (cause instanceof SecurityException) {
errorCode = PlaybackException.ERROR_CODE_IO_NO_PERMISSION; errorCode = PlaybackException.ERROR_CODE_IO_NO_PERMISSION;
} else {
errorCode = PlaybackException.ERROR_CODE_IO_UNSPECIFIED;
} }
handleIoException(e, errorCode); handleIoException(e, errorCode);
} catch (ParserException e) { } catch (ParserException e) {
int errorCode = PlaybackException.ERROR_CODE_UNSPECIFIED; @ErrorCode int errorCode;
if (e.dataType == C.DATA_TYPE_MEDIA) { if (e.dataType == C.DATA_TYPE_MEDIA) {
errorCode = errorCode =
e.contentIsMalformed e.contentIsMalformed
...@@ -604,12 +607,14 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -604,12 +607,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
e.contentIsMalformed e.contentIsMalformed
? PlaybackException.ERROR_CODE_PARSING_MANIFEST_MALFORMED ? PlaybackException.ERROR_CODE_PARSING_MANIFEST_MALFORMED
: PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED; : PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED;
} else {
errorCode = PlaybackException.ERROR_CODE_UNSPECIFIED;
} }
handleIoException(e, errorCode); handleIoException(e, errorCode);
} catch (HttpDataSource.InvalidResponseCodeException e) { } catch (HttpDataSource.InvalidResponseCodeException e) {
handleIoException(e, PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS); handleIoException(e, PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS);
} catch (HttpDataSource.HttpDataSourceException e) { } catch (HttpDataSource.HttpDataSourceException e) {
int errorCode; @ErrorCode int errorCode;
if (e.getCause() instanceof UnknownHostException) { if (e.getCause() instanceof UnknownHostException) {
errorCode = PlaybackException.ERROR_CODE_IO_DNS_FAILED; errorCode = PlaybackException.ERROR_CODE_IO_DNS_FAILED;
} else { } else {
...@@ -632,7 +637,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -632,7 +637,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
// Private methods. // Private methods.
private void handleIoException(IOException e, @PlaybackException.ErrorCode int errorCode) { private void handleIoException(IOException e, @ErrorCode int errorCode) {
ExoPlaybackException error = ExoPlaybackException.createForSource(e, errorCode); ExoPlaybackException error = ExoPlaybackException.createForSource(e, errorCode);
@Nullable MediaPeriodHolder playingPeriod = queue.getPlayingPeriod(); @Nullable MediaPeriodHolder playingPeriod = queue.getPlayingPeriod();
if (playingPeriod != null) { if (playingPeriod != null) {
......
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