Remove createRendererException which doesn't take errorCode

And assign error codes to all callers.

PiperOrigin-RevId: 383118513
This commit is contained in:
aquilescanta 2021-07-05 13:19:12 +01:00 committed by kim-vde
parent 0df0df9aee
commit 5bb2d0386f
4 changed files with 30 additions and 23 deletions

View File

@ -332,18 +332,6 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
return index;
}
/**
* Creates an {@link ExoPlaybackException} of type {@link ExoPlaybackException#TYPE_RENDERER} for
* this renderer.
*
* <p>Equivalent to {@link #createRendererException(Throwable, Format, int)
* createRendererException(cause, format, PlaybackException.ERROR_CODE_UNSPECIFIED)}.
*/
protected final ExoPlaybackException createRendererException(
Throwable cause, @Nullable Format format) {
return createRendererException(cause, format, PlaybackException.ERROR_CODE_UNSPECIFIED);
}
/**
* Creates an {@link ExoPlaybackException} of type {@link ExoPlaybackException#TYPE_RENDERER} for
* this renderer.

View File

@ -559,7 +559,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
try {
mediaCrypto = new MediaCrypto(sessionMediaCrypto.uuid, sessionMediaCrypto.sessionId);
} catch (MediaCryptoException e) {
throw createRendererException(e, inputFormat);
throw createRendererException(
e, inputFormat, PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR);
}
mediaCryptoRequiresSecureDecoder =
!sessionMediaCrypto.forceAllowInsecureDecoderComponents
@ -569,7 +570,12 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
if (FrameworkMediaCrypto.WORKAROUND_DEVICE_NEEDS_KEYS_TO_CONFIGURE_CODEC) {
@DrmSession.State int drmSessionState = codecDrmSession.getState();
if (drmSessionState == DrmSession.STATE_ERROR) {
throw createRendererException(codecDrmSession.getError(), inputFormat);
// TODO(internal b/184262323): Assign a proper error code, once we attach that information
// to DrmSessionException.
throw createRendererException(
codecDrmSession.getError(),
inputFormat,
PlaybackException.ERROR_CODE_DRM_UNSPECIFIED);
} else if (drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS) {
// Wait for keys.
return;
@ -1295,7 +1301,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
resetInputBuffer();
}
} catch (CryptoException e) {
throw createRendererException(e, inputFormat);
throw createRendererException(
e, inputFormat, C.getErrorCodeCorrespondingToPlatformDrmErrorCode(e.getErrorCode()));
}
return false;
}
@ -1365,7 +1372,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
inputIndex, /* offset= */ 0, buffer.data.limit(), presentationTimeUs, /* flags= */ 0);
}
} catch (CryptoException e) {
throw createRendererException(e, inputFormat);
throw createRendererException(
e, inputFormat, C.getErrorCodeCorrespondingToPlatformDrmErrorCode(e.getErrorCode()));
}
resetInputBuffer();
@ -2151,7 +2159,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
try {
mediaCrypto.setMediaDrmSession(getFrameworkMediaCrypto(sourceDrmSession).sessionId);
} catch (MediaCryptoException e) {
throw createRendererException(e, inputFormat);
throw createRendererException(e, inputFormat, PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR);
}
setCodecDrmSession(sourceDrmSession);
codecDrainState = DRAIN_STATE_NONE;
@ -2167,7 +2175,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
// selection.
throw createRendererException(
new IllegalArgumentException("Expecting FrameworkMediaCrypto but found: " + mediaCrypto),
inputFormat);
inputFormat,
PlaybackException.ERROR_CODE_DRM_SCHEME_UNSUPPORTED);
}
return (FrameworkMediaCrypto) mediaCrypto;
}

View File

@ -7185,7 +7185,9 @@ public final class ExoPlayerTest {
if (audioRendererEnableCount.incrementAndGet() == 2) {
// Fail when enabling the renderer for the second time during the playlist update.
throw createRendererException(
new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT);
new IllegalStateException(),
ExoPlayerTestRunner.AUDIO_FORMAT,
PlaybackException.ERROR_CODE_UNSPECIFIED);
}
}
};
@ -8704,7 +8706,9 @@ public final class ExoPlayerTest {
// Fail when enabling the renderer. This will happen during the period
// transition while the reading and playing period are different.
throw createRendererException(
new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT);
new IllegalStateException(),
ExoPlayerTestRunner.AUDIO_FORMAT,
PlaybackException.ERROR_CODE_UNSPECIFIED);
}
}
};

View File

@ -1550,7 +1550,9 @@ public final class AnalyticsCollectorTest {
throws ExoPlaybackException {
// Fail when enabling the renderer. This will happen during the period transition.
throw createRendererException(
new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT);
new IllegalStateException(),
ExoPlayerTestRunner.AUDIO_FORMAT,
PlaybackException.ERROR_CODE_UNSPECIFIED);
}
}
};
@ -1582,7 +1584,9 @@ public final class AnalyticsCollectorTest {
// Fail when rendering the audio stream. This will happen during the period
// transition.
throw createRendererException(
new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT);
new IllegalStateException(),
ExoPlayerTestRunner.AUDIO_FORMAT,
PlaybackException.ERROR_CODE_UNSPECIFIED);
}
}
};
@ -1617,7 +1621,9 @@ public final class AnalyticsCollectorTest {
// period transition (as the first time is when enabling the stream initially).
if (++streamChangeCount == 2) {
throw createRendererException(
new IllegalStateException(), ExoPlayerTestRunner.AUDIO_FORMAT);
new IllegalStateException(),
ExoPlayerTestRunner.AUDIO_FORMAT,
PlaybackException.ERROR_CODE_UNSPECIFIED);
}
}
}