mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Handle dead object error during writing buffer to AudioTrack
PiperOrigin-RevId: 514989776
This commit is contained in:
parent
87d1c3e624
commit
bb9ac21434
2 changed files with 9 additions and 2 deletions
|
|
@ -904,7 +904,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attemptRendererErrorRecovery() throws ExoPlaybackException {
|
private void attemptRendererErrorRecovery() throws ExoPlaybackException {
|
||||||
seekToCurrentPosition(/* sendDiscontinuity= */ true);
|
reselectTracksInternalAndSeek();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlaybackPositions() throws ExoPlaybackException {
|
private void updatePlaybackPositions() throws ExoPlaybackException {
|
||||||
|
|
@ -1688,6 +1688,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
enabledRendererCount--;
|
enabledRendererCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reselectTracksInternalAndSeek() throws ExoPlaybackException {
|
||||||
|
reselectTracksInternal();
|
||||||
|
seekToCurrentPosition(/* sendDiscontinuity= */ true);
|
||||||
|
}
|
||||||
|
|
||||||
private void reselectTracksInternal() throws ExoPlaybackException {
|
private void reselectTracksInternal() throws ExoPlaybackException {
|
||||||
float playbackSpeed = mediaClock.getPlaybackParameters().speed;
|
float playbackSpeed = mediaClock.getPlaybackParameters().speed;
|
||||||
// Reselect tracks on each period in turn, until the selection changes.
|
// Reselect tracks on each period in turn, until the selection changes.
|
||||||
|
|
|
||||||
|
|
@ -453,7 +453,6 @@ public final class DefaultAudioSink implements AudioSink {
|
||||||
@GuardedBy("releaseExecutorLock")
|
@GuardedBy("releaseExecutorLock")
|
||||||
private static int pendingReleaseCount;
|
private static int pendingReleaseCount;
|
||||||
|
|
||||||
private final AudioCapabilities audioCapabilities;
|
|
||||||
private final com.google.android.exoplayer2.audio.AudioProcessorChain audioProcessorChain;
|
private final com.google.android.exoplayer2.audio.AudioProcessorChain audioProcessorChain;
|
||||||
private final boolean enableFloatOutput;
|
private final boolean enableFloatOutput;
|
||||||
private final ChannelMappingAudioProcessor channelMappingAudioProcessor;
|
private final ChannelMappingAudioProcessor channelMappingAudioProcessor;
|
||||||
|
|
@ -478,6 +477,7 @@ public final class DefaultAudioSink implements AudioSink {
|
||||||
private @MonotonicNonNull Configuration configuration;
|
private @MonotonicNonNull Configuration configuration;
|
||||||
private @MonotonicNonNull AudioProcessingPipeline audioProcessingPipeline;
|
private @MonotonicNonNull AudioProcessingPipeline audioProcessingPipeline;
|
||||||
@Nullable private AudioTrack audioTrack;
|
@Nullable private AudioTrack audioTrack;
|
||||||
|
private AudioCapabilities audioCapabilities;
|
||||||
|
|
||||||
private AudioAttributes audioAttributes;
|
private AudioAttributes audioAttributes;
|
||||||
@Nullable private MediaPositionParameters afterDrainParameters;
|
@Nullable private MediaPositionParameters afterDrainParameters;
|
||||||
|
|
@ -1128,6 +1128,8 @@ public final class DefaultAudioSink implements AudioSink {
|
||||||
listener.onAudioSinkError(e);
|
listener.onAudioSinkError(e);
|
||||||
}
|
}
|
||||||
if (e.isRecoverable) {
|
if (e.isRecoverable) {
|
||||||
|
// Change to the audio capabilities supported by all the devices during the error recovery.
|
||||||
|
audioCapabilities = DEFAULT_AUDIO_CAPABILITIES;
|
||||||
throw e; // Do not delay the exception if it can be recovered at higher level.
|
throw e; // Do not delay the exception if it can be recovered at higher level.
|
||||||
}
|
}
|
||||||
writeExceptionPendingExceptionHolder.throwExceptionIfDeadlineIsReached(e);
|
writeExceptionPendingExceptionHolder.throwExceptionIfDeadlineIsReached(e);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue