mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Add Format field to AudioSink.InitializationException
#exofixit PiperOrigin-RevId: 344232362
This commit is contained in:
parent
ee36e648e3
commit
8c9b92efc1
@ -167,11 +167,18 @@ public interface AudioSink {
|
||||
public final int audioTrackState;
|
||||
/** If the exception can be recovered by recreating the sink. */
|
||||
public final boolean isRecoverable;
|
||||
/** The input {@link Format} of the sink when the error occurs. */
|
||||
public final Format format;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param audioTrackState The underlying {@link AudioTrack}'s state.
|
||||
* @param sampleRate The requested sample rate in Hz.
|
||||
* @param channelConfig The requested channel configuration.
|
||||
* @param bufferSize The requested buffer size in bytes.
|
||||
* @param format The input format of the sink when the error occurs.
|
||||
* @param isRecoverable Whether the exception can be recovered by recreating the sink.
|
||||
* @param audioTrackException Exception thrown during the creation of the {@link AudioTrack}.
|
||||
*/
|
||||
public InitializationException(
|
||||
@ -179,6 +186,7 @@ public interface AudioSink {
|
||||
int sampleRate,
|
||||
int channelConfig,
|
||||
int bufferSize,
|
||||
Format format,
|
||||
boolean isRecoverable,
|
||||
@Nullable Exception audioTrackException) {
|
||||
super(
|
||||
@ -190,8 +198,8 @@ public interface AudioSink {
|
||||
audioTrackException);
|
||||
this.audioTrackState = audioTrackState;
|
||||
this.isRecoverable = isRecoverable;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Thrown when a failure occurs writing to the sink. */
|
||||
|
@ -305,7 +305,7 @@ public abstract class DecoderAudioRenderer<
|
||||
} catch (AudioSink.ConfigurationException e) {
|
||||
throw createRendererException(e, e.format);
|
||||
} catch (AudioSink.InitializationException e) {
|
||||
throw createRendererException(e, inputFormat, e.isRecoverable);
|
||||
throw createRendererException(e, e.format, e.isRecoverable);
|
||||
} catch (AudioSink.WriteException e) {
|
||||
throw createRendererException(e, inputFormat, e.isRecoverable);
|
||||
}
|
||||
|
@ -1960,6 +1960,7 @@ public final class DefaultAudioSink implements AudioSink {
|
||||
outputSampleRate,
|
||||
outputChannelConfig,
|
||||
bufferSize,
|
||||
inputFormat,
|
||||
/* isRecoverable= */ outputModeIsOffload(),
|
||||
e);
|
||||
}
|
||||
@ -1977,6 +1978,7 @@ public final class DefaultAudioSink implements AudioSink {
|
||||
outputSampleRate,
|
||||
outputChannelConfig,
|
||||
bufferSize,
|
||||
inputFormat,
|
||||
/* isRecoverable= */ outputModeIsOffload(),
|
||||
/* audioTrackException= */ null);
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
||||
try {
|
||||
fullyConsumed = audioSink.handleBuffer(buffer, bufferPresentationTimeUs, sampleCount);
|
||||
} catch (InitializationException e) {
|
||||
throw createRendererException(e, format, e.isRecoverable);
|
||||
throw createRendererException(e, e.format, e.isRecoverable);
|
||||
} catch (WriteException e) {
|
||||
throw createRendererException(e, format, e.isRecoverable);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user