Commit a302e349 by aquilescanta Committed by kim-vde

Remove ExoPlaybackException factory method that doesn't take errorCode

PiperOrigin-RevId: 383379334
parent 74f26261
...@@ -122,34 +122,6 @@ public final class ExoPlaybackException extends PlaybackException { ...@@ -122,34 +122,6 @@ public final class ExoPlaybackException extends PlaybackException {
} }
/** /**
* Creates an instance of type {@link #TYPE_RENDERER} in which {@link #isRecoverable} is {@code
* false} and {@link #errorCode} is {@link #ERROR_CODE_UNSPECIFIED}.
*
* @param cause The cause of the failure.
* @param rendererIndex The index of the renderer in which the failure occurred.
* @param rendererFormat The {@link Format} the renderer was using at the time of the exception,
* or null if the renderer wasn't using a {@link Format}.
* @param rendererFormatSupport The {@link FormatSupport} of the renderer for {@code
* rendererFormat}. Ignored if {@code rendererFormat} is null.
* @return The created instance.
*/
public static ExoPlaybackException createForRenderer(
Throwable cause,
String rendererName,
int rendererIndex,
@Nullable Format rendererFormat,
@FormatSupport int rendererFormatSupport) {
return createForRenderer(
cause,
rendererName,
rendererIndex,
rendererFormat,
rendererFormatSupport,
/* isRecoverable= */ false,
ERROR_CODE_UNSPECIFIED);
}
/**
* Creates an instance of type {@link #TYPE_RENDERER}. * Creates an instance of type {@link #TYPE_RENDERER}.
* *
* @param cause The cause of the failure. * @param cause The cause of the failure.
......
...@@ -37,6 +37,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; ...@@ -37,6 +37,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.RendererConfiguration; import com.google.android.exoplayer2.RendererConfiguration;
import com.google.android.exoplayer2.drm.DrmSessionEventListener; import com.google.android.exoplayer2.drm.DrmSessionEventListener;
import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.DrmSessionManager;
...@@ -243,7 +244,9 @@ public class MediaCodecAudioRendererTest { ...@@ -243,7 +244,9 @@ public class MediaCodecAudioRendererTest {
"rendererName", "rendererName",
/* rendererIndex= */ 0, /* rendererIndex= */ 0,
format, format,
C.FORMAT_HANDLED)); C.FORMAT_HANDLED,
/* isRecoverable= */ false,
PlaybackException.ERROR_CODE_UNSPECIFIED));
} }
} }
}; };
......
...@@ -28,6 +28,7 @@ import com.google.android.exoplayer2.C; ...@@ -28,6 +28,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.FormatHolder; import com.google.android.exoplayer2.FormatHolder;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.audio.AudioProcessor; import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.android.exoplayer2.audio.AudioProcessor.AudioFormat; import com.google.android.exoplayer2.audio.AudioProcessor.AudioFormat;
import com.google.android.exoplayer2.audio.SonicAudioProcessor; import com.google.android.exoplayer2.audio.SonicAudioProcessor;
...@@ -345,7 +346,8 @@ import java.nio.ByteBuffer; ...@@ -345,7 +346,8 @@ import java.nio.ByteBuffer;
outputAudioFormat = sonicAudioProcessor.configure(outputAudioFormat); outputAudioFormat = sonicAudioProcessor.configure(outputAudioFormat);
flushSonicAndSetSpeed(currentSpeed); flushSonicAndSetSpeed(currentSpeed);
} catch (AudioProcessor.UnhandledAudioFormatException e) { } catch (AudioProcessor.UnhandledAudioFormatException e) {
throw createRendererException(e); // TODO(internal b/192864511): Assign an adequate error code.
throw createRendererException(e, PlaybackException.ERROR_CODE_UNSPECIFIED);
} }
} }
try { try {
...@@ -358,7 +360,8 @@ import java.nio.ByteBuffer; ...@@ -358,7 +360,8 @@ import java.nio.ByteBuffer;
.setAverageBitrate(DEFAULT_ENCODER_BITRATE) .setAverageBitrate(DEFAULT_ENCODER_BITRATE)
.build()); .build());
} catch (IOException e) { } catch (IOException e) {
throw createRendererException(e); // TODO(internal b/192864511): Assign an adequate error code.
throw createRendererException(e, PlaybackException.ERROR_CODE_UNSPECIFIED);
} }
encoderInputAudioFormat = outputAudioFormat; encoderInputAudioFormat = outputAudioFormat;
return true; return true;
...@@ -382,7 +385,8 @@ import java.nio.ByteBuffer; ...@@ -382,7 +385,8 @@ import java.nio.ByteBuffer;
try { try {
decoder = MediaCodecAdapterWrapper.createForAudioDecoding(inputFormat); decoder = MediaCodecAdapterWrapper.createForAudioDecoding(inputFormat);
} catch (IOException e) { } catch (IOException e) {
throw createRendererException(e); // TODO (internal b/184262323): Assign an adequate error code.
throw createRendererException(e, PlaybackException.ERROR_CODE_UNSPECIFIED);
} }
speedProvider = new SegmentSpeedProvider(inputFormat); speedProvider = new SegmentSpeedProvider(inputFormat);
currentSpeed = speedProvider.getSpeed(0); currentSpeed = speedProvider.getSpeed(0);
...@@ -405,9 +409,15 @@ import java.nio.ByteBuffer; ...@@ -405,9 +409,15 @@ import java.nio.ByteBuffer;
sonicAudioProcessor.flush(); sonicAudioProcessor.flush();
} }
private ExoPlaybackException createRendererException(Throwable cause) { private ExoPlaybackException createRendererException(Throwable cause, int errorCode) {
return ExoPlaybackException.createForRenderer( return ExoPlaybackException.createForRenderer(
cause, TAG, getIndex(), inputFormat, /* rendererFormatSupport= */ C.FORMAT_HANDLED); cause,
TAG,
getIndex(),
inputFormat,
/* rendererFormatSupport= */ C.FORMAT_HANDLED,
/* isRecoverable= */ false,
errorCode);
} }
private static long getBufferDurationUs(long bytesWritten, int bytesPerFrame, int sampleRate) { private static long getBufferDurationUs(long bytesWritten, int bytesPerFrame, int sampleRate) {
......
...@@ -21,6 +21,7 @@ import com.google.android.exoplayer2.C; ...@@ -21,6 +21,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.FormatHolder; import com.google.android.exoplayer2.FormatHolder;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RendererCapabilities; import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer; import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
...@@ -107,7 +108,9 @@ public class FakeRenderer extends BaseRenderer { ...@@ -107,7 +108,9 @@ public class FakeRenderer extends BaseRenderer {
getName(), getName(),
getIndex(), getIndex(),
format, format,
C.FORMAT_UNSUPPORTED_TYPE); C.FORMAT_UNSUPPORTED_TYPE,
/* isRecoverable= */ false,
PlaybackException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
} }
formatsRead.add(format); formatsRead.add(format);
onFormatChanged(format); onFormatChanged(format);
......
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