mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add Format field to AudioSink.InitializationException
#exofixit PiperOrigin-RevId: 344232362
This commit is contained in:
parent
ee36e648e3
commit
8c9b92efc1
4 changed files with 13 additions and 3 deletions
|
|
@ -167,11 +167,18 @@ public interface AudioSink {
|
||||||
public final int audioTrackState;
|
public final int audioTrackState;
|
||||||
/** If the exception can be recovered by recreating the sink. */
|
/** If the exception can be recovered by recreating the sink. */
|
||||||
public final boolean isRecoverable;
|
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 sampleRate The requested sample rate in Hz.
|
||||||
* @param channelConfig The requested channel configuration.
|
* @param channelConfig The requested channel configuration.
|
||||||
* @param bufferSize The requested buffer size in bytes.
|
* @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}.
|
* @param audioTrackException Exception thrown during the creation of the {@link AudioTrack}.
|
||||||
*/
|
*/
|
||||||
public InitializationException(
|
public InitializationException(
|
||||||
|
|
@ -179,6 +186,7 @@ public interface AudioSink {
|
||||||
int sampleRate,
|
int sampleRate,
|
||||||
int channelConfig,
|
int channelConfig,
|
||||||
int bufferSize,
|
int bufferSize,
|
||||||
|
Format format,
|
||||||
boolean isRecoverable,
|
boolean isRecoverable,
|
||||||
@Nullable Exception audioTrackException) {
|
@Nullable Exception audioTrackException) {
|
||||||
super(
|
super(
|
||||||
|
|
@ -190,8 +198,8 @@ public interface AudioSink {
|
||||||
audioTrackException);
|
audioTrackException);
|
||||||
this.audioTrackState = audioTrackState;
|
this.audioTrackState = audioTrackState;
|
||||||
this.isRecoverable = isRecoverable;
|
this.isRecoverable = isRecoverable;
|
||||||
|
this.format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Thrown when a failure occurs writing to the sink. */
|
/** Thrown when a failure occurs writing to the sink. */
|
||||||
|
|
|
||||||
|
|
@ -305,7 +305,7 @@ public abstract class DecoderAudioRenderer<
|
||||||
} catch (AudioSink.ConfigurationException e) {
|
} catch (AudioSink.ConfigurationException e) {
|
||||||
throw createRendererException(e, e.format);
|
throw createRendererException(e, e.format);
|
||||||
} catch (AudioSink.InitializationException e) {
|
} catch (AudioSink.InitializationException e) {
|
||||||
throw createRendererException(e, inputFormat, e.isRecoverable);
|
throw createRendererException(e, e.format, e.isRecoverable);
|
||||||
} catch (AudioSink.WriteException e) {
|
} catch (AudioSink.WriteException e) {
|
||||||
throw createRendererException(e, inputFormat, e.isRecoverable);
|
throw createRendererException(e, inputFormat, e.isRecoverable);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1960,6 +1960,7 @@ public final class DefaultAudioSink implements AudioSink {
|
||||||
outputSampleRate,
|
outputSampleRate,
|
||||||
outputChannelConfig,
|
outputChannelConfig,
|
||||||
bufferSize,
|
bufferSize,
|
||||||
|
inputFormat,
|
||||||
/* isRecoverable= */ outputModeIsOffload(),
|
/* isRecoverable= */ outputModeIsOffload(),
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
|
|
@ -1977,6 +1978,7 @@ public final class DefaultAudioSink implements AudioSink {
|
||||||
outputSampleRate,
|
outputSampleRate,
|
||||||
outputChannelConfig,
|
outputChannelConfig,
|
||||||
bufferSize,
|
bufferSize,
|
||||||
|
inputFormat,
|
||||||
/* isRecoverable= */ outputModeIsOffload(),
|
/* isRecoverable= */ outputModeIsOffload(),
|
||||||
/* audioTrackException= */ null);
|
/* audioTrackException= */ null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -608,7 +608,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
||||||
try {
|
try {
|
||||||
fullyConsumed = audioSink.handleBuffer(buffer, bufferPresentationTimeUs, sampleCount);
|
fullyConsumed = audioSink.handleBuffer(buffer, bufferPresentationTimeUs, sampleCount);
|
||||||
} catch (InitializationException e) {
|
} catch (InitializationException e) {
|
||||||
throw createRendererException(e, format, e.isRecoverable);
|
throw createRendererException(e, e.format, e.isRecoverable);
|
||||||
} catch (WriteException e) {
|
} catch (WriteException e) {
|
||||||
throw createRendererException(e, format, e.isRecoverable);
|
throw createRendererException(e, format, e.isRecoverable);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue